Add geoip command line tool
This commit is contained in:
parent
7fe1551951
commit
4bbffa9cd5
|
@ -4,6 +4,7 @@ import (
|
||||||
// commands
|
// commands
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
|
|
||||||
|
_ "github.com/openobservatory/gooni/internal/cli/geoip"
|
||||||
_ "github.com/openobservatory/gooni/internal/cli/info"
|
_ "github.com/openobservatory/gooni/internal/cli/info"
|
||||||
_ "github.com/openobservatory/gooni/internal/cli/list"
|
_ "github.com/openobservatory/gooni/internal/cli/list"
|
||||||
_ "github.com/openobservatory/gooni/internal/cli/nettest"
|
_ "github.com/openobservatory/gooni/internal/cli/nettest"
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -97,8 +96,7 @@ func DownloadGeoIPDatabaseFiles(dir string) error {
|
||||||
|
|
||||||
// LookupLocation resolves an IP to a location according to the Maxmind DB
|
// LookupLocation resolves an IP to a location according to the Maxmind DB
|
||||||
func LookupLocation(dbPath string, ipStr string) (LocationInfo, error) {
|
func LookupLocation(dbPath string, ipStr string) (LocationInfo, error) {
|
||||||
loc := LocationInfo{}
|
loc := LocationInfo{IP: ipStr}
|
||||||
fmt.Printf("Opening %s", filepath.Join(dbPath, "GeoLite2-ASN.mmdb"))
|
|
||||||
|
|
||||||
asnDB, err := geoip2.Open(filepath.Join(dbPath, "GeoLite2-ASN.mmdb"))
|
asnDB, err := geoip2.Open(filepath.Join(dbPath, "GeoLite2-ASN.mmdb"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user