MCPcopy
hub / github.com/gliderlabs/ssh / HandleConn

Method HandleConn

server.go:275–320  ·  view source on GitHub ↗
(newConn net.Conn)

Source from the content-addressed store, hash-verified

273}
274
275func (srv *Server) HandleConn(newConn net.Conn) {
276 ctx, cancel := newContext(srv)
277 if srv.ConnCallback != nil {
278 cbConn := srv.ConnCallback(ctx, newConn)
279 if cbConn == nil {
280 newConn.Close()
281 return
282 }
283 newConn = cbConn
284 }
285 conn := &serverConn{
286 Conn: newConn,
287 idleTimeout: srv.IdleTimeout,
288 closeCanceler: cancel,
289 }
290 if srv.MaxTimeout > 0 {
291 conn.maxDeadline = time.Now().Add(srv.MaxTimeout)
292 }
293 defer conn.Close()
294 sshConn, chans, reqs, err := gossh.NewServerConn(conn, srv.config(ctx))
295 if err != nil {
296 if srv.ConnectionFailedCallback != nil {
297 srv.ConnectionFailedCallback(conn, err)
298 }
299 return
300 }
301
302 srv.trackConn(sshConn, true)
303 defer srv.trackConn(sshConn, false)
304
305 ctx.SetValue(ContextKeyConn, sshConn)
306 applyConnMetadata(ctx, sshConn)
307 //go gossh.DiscardRequests(reqs)
308 go srv.handleRequests(ctx, reqs)
309 for ch := range chans {
310 handler := srv.ChannelHandlers[ch.ChannelType()]
311 if handler == nil {
312 handler = srv.ChannelHandlers["default"]
313 }
314 if handler == nil {
315 ch.Reject(gossh.UnknownChannelType, "unsupported channel type")
316 continue
317 }
318 go handler(srv, sshConn, ch, ctx)
319 }
320}
321
322func (srv *Server) handleRequests(ctx Context, in <-chan *gossh.Request) {
323 for req := range in {

Callers 2

ServeMethod · 0.95
serveOnceMethod · 0.95

Calls 8

CloseMethod · 0.95
configMethod · 0.95
trackConnMethod · 0.95
handleRequestsMethod · 0.95
newContextFunction · 0.85
applyConnMetadataFunction · 0.85
SetValueMethod · 0.65
CloseMethod · 0.45

Tested by 1

serveOnceMethod · 0.76