Fix bug with throttlespeed in ssh conn

This commit is contained in:
Torjus Håkestad 2022-09-28 12:45:55 +02:00
parent e9d2f3581c
commit ca96115fe2
No known key found for this signature in database
GPG Key ID: C6FD38B820D295FC
2 changed files with 3 additions and 2 deletions

View File

@ -21,7 +21,7 @@ HostKeyPath = ""
# Log level for SSH Honeypot # Log level for SSH Honeypot
# Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE" # Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"
# Default: "INFO" # Default: "INFO"
LogLevel = "INFO" LogLevel = "DEBUG"
# Address and port to listen to # Address and port to listen to
# Default: ":2222" # Default: ":2222"
ListenAddr = ":2222" ListenAddr = ":2222"

View File

@ -60,6 +60,8 @@ func NewHoneypotServer(cfg config.HoneypotConfig, store store.LoginAttemptStore)
hs.sshServer.AddHostKey(signer) hs.sshServer.AddHostKey(signer)
} }
hs.throttleSpeed = 1024 * 1024
return &hs, nil return &hs, nil
} }
@ -116,7 +118,6 @@ func (hs *HoneypotServer) passwordHandler(ctx sshlib.Context, password string) b
func (s *HoneypotServer) connCallback(ctx sshlib.Context, conn net.Conn) net.Conn { func (s *HoneypotServer) connCallback(ctx sshlib.Context, conn net.Conn) net.Conn {
s.Logger.Debugw("Connection received.", "remote_addr", conn.RemoteAddr()) s.Logger.Debugw("Connection received.", "remote_addr", conn.RemoteAddr())
conn.RemoteAddr()
throttledConn := newThrottledConn(conn) throttledConn := newThrottledConn(conn)
throttledConn.SetSpeed(s.throttleSpeed) throttledConn.SetSpeed(s.throttleSpeed)