From 4bbffa9cd54cd0af8e415fbb12dd87115853e3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Fri, 23 Mar 2018 12:10:38 +0100 Subject: [PATCH] Add geoip command line tool --- cmd/ooni/main.go | 1 + utils/geoip.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/ooni/main.go b/cmd/ooni/main.go index 9925661..a7a7d20 100644 --- a/cmd/ooni/main.go +++ b/cmd/ooni/main.go @@ -4,6 +4,7 @@ import ( // commands "github.com/apex/log" + _ "github.com/openobservatory/gooni/internal/cli/geoip" _ "github.com/openobservatory/gooni/internal/cli/info" _ "github.com/openobservatory/gooni/internal/cli/list" _ "github.com/openobservatory/gooni/internal/cli/nettest" diff --git a/utils/geoip.go b/utils/geoip.go index 1b91f76..1bb7730 100644 --- a/utils/geoip.go +++ b/utils/geoip.go @@ -4,7 +4,6 @@ import ( "archive/tar" "compress/gzip" "encoding/json" - "fmt" "io" "io/ioutil" "math/rand" @@ -97,8 +96,7 @@ func DownloadGeoIPDatabaseFiles(dir string) error { // LookupLocation resolves an IP to a location according to the Maxmind DB func LookupLocation(dbPath string, ipStr string) (LocationInfo, error) { - loc := LocationInfo{} - fmt.Printf("Opening %s", filepath.Join(dbPath, "GeoLite2-ASN.mmdb")) + loc := LocationInfo{IP: ipStr} asnDB, err := geoip2.Open(filepath.Join(dbPath, "GeoLite2-ASN.mmdb")) if err != nil {