in remoteip/parser.go [127:156]
func (p *RemoteIPParser) parseIP(addr string) string {
// Trim whitespace
addr = strings.TrimSpace(addr)
if addr == "" {
return ""
}
// Try to use SplitHostPort to handle IP:port format
host := addr
h, _, err := net.SplitHostPort(addr)
if err == nil {
host = h
} else if strings.HasPrefix(addr, "[") && strings.HasSuffix(addr, "]") {
// Could be IPv6 with brackets but no port: "[IPv6]"
host = addr[1 : len(addr)-1]
}
// Parse the IP address
ip := net.ParseIP(host)
if ip == nil {
return ""
}
// Check if it has a netmask by looking for slash
if strings.Contains(addr, "/") {
return "" // Reject CIDR notation
}
return ip.String()
}