MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / handleSSHHandshake

Function handleSSHHandshake

main.go:1269–1297  ·  view source on GitHub ↗
(conn net.Conn, sshConfig *ssh.ServerConfig, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

1267}
1268
1269func 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
1299func handleSSHConnection(connDetails *connections.ConnectionDetails, reqs <-chan *ssh.Request, wg *sync.WaitGroup) {
1300 defer wg.Done()

Callers 1

SSHListenOnPortFunction · 0.85

Calls 7

WarnFunction · 0.92
AddSSHFunction · 0.92
handleSSHConnectionFunction · 0.85
StringMethod · 0.65
RemoteAddrMethod · 0.65
CloseMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected