5
5
"encoding/hex"
6
6
"net"
7
7
"sync"
8
- "time"
9
8
10
9
gossh "golang.org/x/crypto/ssh"
11
10
)
@@ -93,8 +92,8 @@ type Context interface {
93
92
}
94
93
95
94
type sshContext struct {
96
- ctx context.Context
97
- mtx * sync.RWMutex
95
+ context.Context
96
+ * sync.Mutex
98
97
99
98
values map [interface {}]interface {}
100
99
valuesMu sync.Mutex
@@ -107,9 +106,9 @@ var _ sync.Locker = &sshContext{}
107
106
func newContext (srv * Server ) (* sshContext , context.CancelFunc ) {
108
107
innerCtx , cancel := context .WithCancel (context .Background ())
109
108
ctx := & sshContext {
110
- ctx : innerCtx ,
111
- mtx : & sync.RWMutex {},
112
- values : make (map [interface {}]interface {}),
109
+ Context : innerCtx ,
110
+ Mutex : & sync.Mutex {},
111
+ values : make (map [interface {}]interface {}),
113
112
}
114
113
ctx .SetValue (ContextKeyServer , srv )
115
114
perms := & Permissions {& gossh.Permissions {}}
@@ -137,7 +136,7 @@ func (ctx *sshContext) Value(key interface{}) interface{} {
137
136
if v , ok := ctx .values [key ]; ok {
138
137
return v
139
138
}
140
- return ctx .ctx .Value (key )
139
+ return ctx .Context .Value (key )
141
140
}
142
141
143
142
func (ctx * sshContext ) SetValue (key , value interface {}) {
@@ -146,36 +145,6 @@ func (ctx *sshContext) SetValue(key, value interface{}) {
146
145
ctx .values [key ] = value
147
146
}
148
147
149
- func (ctx * sshContext ) Done () <- chan struct {} {
150
- ctx .mtx .RLock ()
151
- defer ctx .mtx .RUnlock ()
152
- return ctx .ctx .Done ()
153
- }
154
-
155
- // Deadline implements context.Context.
156
- func (ctx * sshContext ) Deadline () (deadline time.Time , ok bool ) {
157
- ctx .mtx .RLock ()
158
- defer ctx .mtx .RUnlock ()
159
- return ctx .ctx .Deadline ()
160
- }
161
-
162
- // Err implements context.Context.
163
- func (ctx * sshContext ) Err () error {
164
- ctx .mtx .RLock ()
165
- defer ctx .mtx .RUnlock ()
166
- return ctx .ctx .Err ()
167
- }
168
-
169
- // Lock implements sync.Locker.
170
- func (ctx * sshContext ) Lock () {
171
- ctx .mtx .Lock ()
172
- }
173
-
174
- // Unlock implements sync.Locker.
175
- func (ctx * sshContext ) Unlock () {
176
- ctx .mtx .Unlock ()
177
- }
178
-
179
148
func (ctx * sshContext ) User () string {
180
149
return ctx .Value (ContextKeyUser ).(string )
181
150
}
0 commit comments