diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-08 09:29:08 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-08 09:29:08 +0200 |
| commit | 2007054d77b5bc40c943a9fd64874e850c750f2d (patch) | |
| tree | 8345f22f6943b2498caa49634866a17d4179c3af | |
| parent | 4f4c6422d0d5f8038bf918fd3da28b24428e0078 (diff) | |
task: parse ssh remote host with SplitHostPort (task 374)
| -rw-r--r-- | internal/server/server.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index 1dd0121..943defa 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "net" - "strings" "time" "github.com/mimecast/dtail/internal/config" @@ -282,8 +281,13 @@ func (s *Server) Callback(c gossh.ConnMetadata, } authInfo := string(authPayload) - splitted := strings.Split(c.RemoteAddr().String(), ":") - remoteIP := splitted[0] + remoteAddr := c.RemoteAddr().String() + remoteIP, _, splitErr := net.SplitHostPort(remoteAddr) + if splitErr != nil { + dlog.Server.Debug(user, "Unable to split remote address host/port, using raw address", + "remoteAddr", remoteAddr, "error", splitErr) + remoteIP = remoteAddr + } if strategy, found := s.authStrategies[user.Name]; found && strategy(user, authInfo, remoteIP) { return nil, nil |
