25 lines
346 B
Go
25 lines
346 B
Go
|
package honeypot
|
||
|
|
||
|
import (
|
||
|
_ "embed"
|
||
|
"net"
|
||
|
|
||
|
"github.com/oschwald/geoip2-golang"
|
||
|
)
|
||
|
|
||
|
//go:embed Geoacumen-Country.mmdb
|
||
|
var mmdb []byte
|
||
|
|
||
|
func LookupCountry(ip net.IP) string {
|
||
|
db, err := geoip2.FromBytes(mmdb)
|
||
|
if err != nil {
|
||
|
return "??"
|
||
|
}
|
||
|
|
||
|
country, err := db.Country(ip)
|
||
|
if err != nil {
|
||
|
return "??"
|
||
|
}
|
||
|
return country.Country.IsoCode
|
||
|
}
|