Skip to content
Permalink
Browse files

Make GetASN() return a netmask

(this isn't actually used, I think, but the interface{} says
it should be returned...)
  • Loading branch information
abh committed Dec 28, 2019
1 parent 011d8cf commit 00c59363d1324f54aed322a5ad205fbb2286b118
Showing with 7 additions and 3 deletions.
  1. +7 −3 targeting/geoip2/geoip2.go
@@ -145,10 +145,10 @@ func (g *GeoIP2) HasASN() (bool, error) {
return false, err
}

// GetASN returns the ASN for the IP (as a "as123" string and
// an integer)
// GetASN returns the ASN for the IP (as a "as123" string) and the netmask
func (g *GeoIP2) GetASN(ip net.IP) (string, int, error) {
r, err := g.get(asnDB, "")
log.Printf("GetASN for %s, got DB? %s", ip, err)
if err != nil {
return "", 0, err
}
@@ -158,7 +158,11 @@ func (g *GeoIP2) GetASN(ip net.IP) (string, int, error) {
return "", 0, fmt.Errorf("lookup ASN for '%s': %s", ip.String(), err)
}
asn := c.AutonomousSystemNumber
return fmt.Sprintf("as%d", asn), 0, nil
netmask := 24
if ip.To4() != nil {
netmask = 48
}
return fmt.Sprintf("as%d", asn), netmask, nil
}

// HasCountry checks if the GeoIP country database is available

0 comments on commit 00c5936

Please sign in to comment.
You can’t perform that action at this time.