MCPcopy Index your code
hub / github.com/coder/coder / directStreamLocalHandler

Function directStreamLocalHandler

agent/agentssh/forward.go:223–246  ·  view source on GitHub ↗
(_ *ssh.Server, _ *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context)

Source from the content-addressed store, hash-verified

221}
222
223func directStreamLocalHandler(_ *ssh.Server, _ *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context) {
224 var reqPayload directStreamLocalPayload
225 err := gossh.Unmarshal(newChan.ExtraData(), &reqPayload)
226 if err != nil {
227 _ = newChan.Reject(gossh.ConnectionFailed, "could not parse direct-streamlocal@openssh.com channel payload")
228 return
229 }
230
231 var dialer net.Dialer
232 dconn, err := dialer.DialContext(ctx, "unix", reqPayload.SocketPath)
233 if err != nil {
234 _ = newChan.Reject(gossh.ConnectionFailed, fmt.Sprintf("dial unix socket %q: %+v", reqPayload.SocketPath, err.Error()))
235 return
236 }
237
238 ch, reqs, err := newChan.Accept()
239 if err != nil {
240 _ = dconn.Close()
241 return
242 }
243 go gossh.DiscardRequests(reqs)
244
245 Bicopy(ctx, ch, dconn)
246}
247
248// unlink removes files and unlike os.Remove, directories are kept.
249func unlink(path string) error {

Callers 1

NewServerFunction · 0.85

Calls 6

BicopyFunction · 0.85
DialContextMethod · 0.65
CloseMethod · 0.65
UnmarshalMethod · 0.45
ErrorMethod · 0.45
AcceptMethod · 0.45

Tested by

no test coverage detected