summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2022-02-15 23:15:15 +0100
committerkali kaneko (leap communications) <kali@leap.se>2022-02-15 23:19:55 +0100
commitc195f6b03751bbb4012f48b57b5961a10d4d4113 (patch)
treec15609258454886203f62a12f38157fd04a05e5b
parent95dcdc7d883d138d17c2e676c1e4cfae0aa2d395 (diff)
fix blank gateway arrayHEADmaster
i really should start asking someone for code reviews, or committing only after a coffee. this yolo attitude is no good for anyone. this was a silly typo on db98de9. I guess I write write err != nil too much...
-rw-r--r--main.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.go b/main.go
index 07a1ba5..5f7a66b 100644
--- a/main.go
+++ b/main.go
@@ -183,11 +183,14 @@ type GeolocationJSON struct {
func (jh *jsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ipstr := getRemoteIP(req)
- record, err := jh.geoipdb.getRecordForIP(ipstr)
sortedGateways := []string{""}
- if err != nil {
+
+ record, err := jh.geoipdb.getRecordForIP(ipstr)
+ if err == nil {
sortedGateways = jh.geoipdb.sortGateways(record.Location.Latitude, record.Location.Longitude)
hitsPerCountry.With(prometheus.Labels{"country": record.Country.IsoCode}).Inc()
+ } else {
+ log.Println("error while getting record for", ipstr)
}
data := &GeolocationJSON{
ipstr,