Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Stop crash with invalid/missing geoip data. Fixes #414

Gabe Kangas2b25c940220b
diff --git a/geoip/geoip.go b/geoip/geoip.go
index 4898396a31..417ca17bc9 100644
--- a/geoip/geoip.go
+++ b/geoip/geoip.go
@@ -29,6 +29,14 @@ func GetGeoFromIP(ip string) *GeoDetails {
return &cachedGeoDetails
}
+ if ip == "::1" || ip == "127.0.0.1" {
+ return &GeoDetails{
+ CountryCode: "N/A",
+ RegionName: "Localhost",
+ TimeZone: "",
+ }
+ }
+
return nil
}
@@ -72,9 +80,16 @@ func FetchGeoForIP(ip string) {
return
}
+ var regionName = "Unknown"
+ if len(record.Subdivisions) > 0 {
+ if region, ok := record.Subdivisions[0].Names["en"]; ok {
+ regionName = region
+ }
+ }
+
response := GeoDetails{
CountryCode: record.Country.IsoCode,
- RegionName: record.Subdivisions[0].Names["en"],
+ RegionName: regionName,
TimeZone: record.Location.TimeZone,
}