oschwald / maxminddb-golang

MaxMind DB Reader for Go
ISC License
576 stars 99 forks source link

ASN panic in valid mmdb file #76

Closed mhf-ir closed 3 years ago

mhf-ir commented 3 years ago
$ mmdblookup --version

  mmdblookup version 1.4.2

$ mmdblookup --file dbip-asn.mmdb --ip 1.1.1.1

  {
    "autonomous_system_number": 
      13335 <uint32>
    "autonomous_system_organization": 
      "Cloudflare, Inc." <utf8_string>
  }

mmdb file:

https://db-ip.com/db/download/ip-to-asn-lite

Failed on my code:

package main

import (
    "fmt"
    "net"

    mmdb "github.com/oschwald/geoip2-golang"
)

func main() {

    mmdbASN, err := mmdb.Open("dbip-asn.mmdb")
    if err != nil {
        panic(err) // HERE the panic
    }
    ipParsed := net.ParseIP("1.1.1.1")
    asnData, asnErr := mmdbASN.ASN(ipParsed)
    if asnErr != nil {
        fmt.Println(asnData)
    }

    return
}
$ panic: geoip2: reader does not support the "DBIP-ASN-Lite (compat=GeoLite2-ASN)" database type

goroutine 1 [running]:
main.main()
        main.go:14 +0x11b
mhf-ir commented 3 years ago

Seems problem for mapping in https://github.com/oschwald/geoip2-golang