Add geographic coordinates to IP data and enhance map visualization
Publish telemt-api gateway Docker image / test (push) Successful in 24s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 1m55s

- Introduced latitude and longitude fields in the IP data structure to support geographic information.
- Updated the API documentation to reflect the inclusion of geographic coordinates in the unique IPs endpoint.
- Enhanced the UI to display a map of connections using Leaflet, providing a visual representation of IP locations based on the new geographic data.
- Improved the handling of GeoIP data to ensure accurate mapping and user experience when GeoIP is enabled.
This commit is contained in:
Denozordec
2026-03-30 15:26:14 +07:00
parent b69f2dd0e4
commit 452ee4f6f1
12 changed files with 197 additions and 5 deletions
+6
View File
@@ -28,6 +28,12 @@ func EnrichUniqueIPsGeo(rows []UniqueIPsRow, g *geoip.Service) {
s := res.CityName
rows[i].IPs[j].CityName = &s
}
if res.Latitude != 0 || res.Longitude != 0 {
lat := res.Latitude
lon := res.Longitude
rows[i].IPs[j].Latitude = &lat
rows[i].IPs[j].Longitude = &lon
}
if res.ASN != 0 {
a := res.ASN
rows[i].IPs[j].ASN = &a
+2
View File
@@ -115,6 +115,8 @@ type IPAssignments struct {
CountryCode *string `json:"country_code,omitempty"`
CountryName *string `json:"country_name,omitempty"`
CityName *string `json:"city_name,omitempty"`
Latitude *float64 `json:"latitude,omitempty"`
Longitude *float64 `json:"longitude,omitempty"`
ASN *uint64 `json:"asn,omitempty"` // GeoLite2-ASN
ASOrganization *string `json:"as_organization,omitempty"` // ASN org name
}
+9
View File
@@ -75,6 +75,8 @@ type Result struct {
CountryCode string
CountryName string
CityName string
Latitude float64
Longitude float64
ASN uint64
ASOrg string
}
@@ -99,6 +101,13 @@ func (s *Service) Lookup(ipStr string) (Result, bool) {
if rec.City.Names != nil {
out.CityName = rec.City.Names["en"]
}
// Coordinates are used by the UI map.
// Note: MaxMind might still return 0/0 for unknown locations.
if rec.Location.Latitude != 0 || rec.Location.Longitude != 0 {
out.Latitude = rec.Location.Latitude
out.Longitude = rec.Location.Longitude
ok = true
}
if out.CountryCode != "" || out.CountryName != "" || out.CityName != "" {
ok = true
}