getLocationFromIP returns basic location info (simplified; for local/private IPs returns "Local").
(ip string)
| 1174 | |
| 1175 | // getLocationFromIP returns basic location info (simplified; for local/private IPs returns "Local"). |
| 1176 | func getLocationFromIP(ip string) map[string]string { |
| 1177 | out := map[string]string{"country": "Unknown", "city": "Unknown"} |
| 1178 | if ip == "" { |
| 1179 | return out |
| 1180 | } |
| 1181 | if ip == "127.0.0.1" || ip == "::1" || strings.HasPrefix(ip, "192.168.") || strings.HasPrefix(ip, "10.") { |
| 1182 | out["country"] = "Local" |
| 1183 | out["city"] = "Local Network" |
| 1184 | } |
| 1185 | return out |
| 1186 | } |
| 1187 | |
| 1188 | // GetSessions handles GET /auth/sessions. |
| 1189 | func (h *AuthHandler) GetSessions(w http.ResponseWriter, r *http.Request) { |