(remoteAddr string)
| 287 | } |
| 288 | |
| 289 | func normalizeLoginIP(remoteAddr string) string { |
| 290 | ipValue := strings.TrimSpace(remoteAddr) |
| 291 | if host, _, err := net.SplitHostPort(ipValue); err == nil { |
| 292 | ipValue = host |
| 293 | } |
| 294 | ipValue = strings.Trim(ipValue, "[]") |
| 295 | |
| 296 | parsedIP := net.ParseIP(ipValue) |
| 297 | if parsedIP == nil { |
| 298 | return ipValue |
| 299 | } |
| 300 | if parsedIP.IsLoopback() { |
| 301 | return loginIPLocalAddress |
| 302 | } |
| 303 | if ipv4 := parsedIP.To4(); ipv4 != nil { |
| 304 | return ipv4.String() |
| 305 | } |
| 306 | return parsedIP.String() |
| 307 | } |
| 308 | |
| 309 | func getLoginIPArea(ipValue string) string { |
| 310 | parsedIP := net.ParseIP(ipValue) |
no outgoing calls