Improve logging
This commit is contained in:
parent
76de4ad82c
commit
a60190e6ac
@ -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
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user