Improve logging
This commit is contained in:
@@ -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(),
|
||||
|
Reference in New Issue
Block a user