(conn net.Conn, sshConfig *ssh.ServerConfig, wg *sync.WaitGroup)
| 1267 | } |
| 1268 | |
| 1269 | func handleSSHHandshake(conn net.Conn, sshConfig *ssh.ServerConfig, wg *sync.WaitGroup) { |
| 1270 | defer wg.Done() |
| 1271 | |
| 1272 | sshConn, chans, reqs, err := ssh.NewServerConn(conn, sshConfig) |
| 1273 | if err != nil { |
| 1274 | mudlog.Warn("SSH handshake failed", "remoteAddr", conn.RemoteAddr().String(), "error", err) |
| 1275 | return |
| 1276 | } |
| 1277 | defer sshConn.Close() |
| 1278 | |
| 1279 | // Discard all out-of-band requests (keepalive, etc.) |
| 1280 | go ssh.DiscardRequests(reqs) |
| 1281 | |
| 1282 | for newChan := range chans { |
| 1283 | if newChan.ChannelType() != "session" { |
| 1284 | newChan.Reject(ssh.UnknownChannelType, "unsupported channel type") |
| 1285 | continue |
| 1286 | } |
| 1287 | |
| 1288 | ch, chanReqs, err := newChan.Accept() |
| 1289 | if err != nil { |
| 1290 | mudlog.Warn("SSH channel accept failed", "error", err) |
| 1291 | return |
| 1292 | } |
| 1293 | |
| 1294 | wg.Add(1) |
| 1295 | go handleSSHConnection(connections.AddSSH(ch, sshConn.RemoteAddr()), chanReqs, wg) |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | func handleSSHConnection(connDetails *connections.ConnectionDetails, reqs <-chan *ssh.Request, wg *sync.WaitGroup) { |
| 1300 | defer wg.Done() |
no test coverage detected