| 1070 | } |
| 1071 | |
| 1072 | func (s *Server) handleConn(l net.Listener, c net.Conn) { |
| 1073 | logger := s.logger.With( |
| 1074 | slog.F("remote_addr", c.RemoteAddr()), |
| 1075 | slog.F("local_addr", c.LocalAddr()), |
| 1076 | slog.F("listen_addr", l.Addr())) |
| 1077 | defer c.Close() |
| 1078 | |
| 1079 | if !s.trackConn(l, c, true) { |
| 1080 | // Server is closed or we no longer want |
| 1081 | // connections from this listener. |
| 1082 | logger.Info(context.Background(), "received connection after server closed") |
| 1083 | return |
| 1084 | } |
| 1085 | defer s.trackConn(l, c, false) |
| 1086 | logger.Info(context.Background(), "started serving ssh connection") |
| 1087 | // note: srv.ConnectionCompleteCallback logs completion of the connection |
| 1088 | s.srv.HandleConn(c) |
| 1089 | } |
| 1090 | |
| 1091 | // trackListener registers the listener with the server. If the server is |
| 1092 | // closing, the function will block until the server is closed. |