mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-22 07:30:25 +00:00
ssh requests: send a reply only if the client requested it
This commit is contained in:
parent
c0e09374a8
commit
aff75953e3
1 changed files with 7 additions and 5 deletions
|
@ -360,6 +360,9 @@ func canAcceptConnection(ip string) bool {
|
|||
logger.Log(logger.LevelDebug, common.ProtocolSSH, "", "connection refused, configured limit reached")
|
||||
return false
|
||||
}
|
||||
if err := common.Config.ExecutePostConnectHook(ip, common.ProtocolSSH); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -378,10 +381,7 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
|
|||
// Before beginning a handshake must be performed on the incoming net.Conn
|
||||
// we'll set a Deadline for handshake to complete, the default is 2 minutes as OpenSSH
|
||||
conn.SetDeadline(time.Now().Add(handshakeTimeout)) //nolint:errcheck
|
||||
if err := common.Config.ExecutePostConnectHook(ipAddr, common.ProtocolSSH); err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
sconn, chans, reqs, err := ssh.NewServerConn(conn, config)
|
||||
if err != nil {
|
||||
logger.Debug(logSender, "", "failed to accept an incoming connection: %v", err)
|
||||
|
@ -471,7 +471,9 @@ func (c *Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Serve
|
|||
ok = processSSHCommand(req.Payload, &connection, c.EnabledSSHCommands)
|
||||
}
|
||||
}
|
||||
req.Reply(ok, nil) //nolint:errcheck
|
||||
if req.WantReply {
|
||||
req.Reply(ok, nil) //nolint:errcheck
|
||||
}
|
||||
}
|
||||
}(requests, channelCounter)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue