diff --git a/honeypot/geolocate.go b/honeypot/geolocate.go index f3969b0..e18c9d7 100644 --- a/honeypot/geolocate.go +++ b/honeypot/geolocate.go @@ -10,14 +10,16 @@ import ( //go:embed Geoacumen-Country.mmdb var mmdb []byte -func LookupCountry(ip net.IP) string { +func (s *HoneypotServer) LookupCountry(ip net.IP) string { db, err := geoip2.FromBytes(mmdb) if err != nil { + s.Logger.Warnw("Error opening geoip database", "error", err) return "??" } country, err := db.Country(ip) if err != nil { + s.Logger.Warnw("Error doing geoip lookup", "error", err) return "??" } return country.Country.IsoCode diff --git a/honeypot/server.go b/honeypot/server.go index a068147..35f9bd0 100644 --- a/honeypot/server.go +++ b/honeypot/server.go @@ -87,7 +87,7 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool SSHClientVersion: ctx.ClientVersion(), ConnectionUUID: sessUUID, } - country := LookupCountry(la.RemoteIP) + country := hs.LookupCountry(la.RemoteIP) la.Country = country hs.Logger.Infow("Login attempt", "remote_ip", la.RemoteIP.String(), diff --git a/web/server.go b/web/server.go index 56f20fc..93ef00f 100644 --- a/web/server.go +++ b/web/server.go @@ -195,6 +195,7 @@ func (s *Server) HandlerStats(w http.ResponseWriter, r *http.Request) { stats, err := s.store.Stats(statType, limit) if err != nil { + s.ServerLogger.Warnw("Error fetching stats", "error", err) s.WriteAPIError(w, r, http.StatusInternalServerError, "Error fetching stats") return }