Skip to content

Commit

Permalink
improve log output if ip cannot be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Dec 12, 2024
1 parent af1c2b2 commit 3c48b7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/snclient/allowed_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (ahc *AllowedHostConfig) Check(remoteAddr string) bool {
return true
}

addressCopy := remoteAddr

idx := strings.LastIndex(remoteAddr, ":")
if idx != -1 {
remoteAddr = remoteAddr[:idx]
Expand All @@ -60,7 +62,7 @@ func (ahc *AllowedHostConfig) Check(remoteAddr string) bool {

addr, err := netip.ParseAddr(remoteAddr)
if err != nil {
log.Warnf("cannot parse remote address: %s: %s", remoteAddr, err.Error())
log.Warnf("cannot parse remote address: %s: %s", addressCopy, err.Error())

return false
}
Expand Down

0 comments on commit 3c48b7c

Please sign in to comment.