refactor: spin geoipx off geolocate (#893)

A bunch of packages (including oohelperd) just need the ability to
use MaxMind-like databases. They don't need the additional functionality
implemented by the geolocate package. Such a package, in fact, is
mostly (if not only) needed by the engine package.

Therefore, move code to query MaxMind-like databases to a separate
package, and avoid depending on geolocate in all the packages for
which it's sufficient to use geoipx.

Part of https://github.com/ooni/probe/issues/2240
This commit is contained in:
Simone Basso
2022-08-28 20:00:25 +02:00
committed by GitHub
parent 1e7384d1cc
commit 110a11828b
23 changed files with 228 additions and 215 deletions
@@ -8,7 +8,7 @@ import (
"net"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/geolocate"
"github.com/ooni/probe-cli/v3/internal/geoipx"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
@@ -289,11 +289,11 @@ func (tk *TestKeys) analysisDNSDiffASN(probeAddrs, thAddrs []string) (asns []uin
)
mapping := make(map[uint]int)
for _, addr := range probeAddrs {
asn, _, _ := geolocate.LookupASN(addr)
asn, _, _ := geoipx.LookupASN(addr)
mapping[asn] |= inProbe // including the zero ASN that means unknown
}
for _, addr := range thAddrs {
asn, _, _ := geolocate.LookupASN(addr)
asn, _, _ := geoipx.LookupASN(addr)
mapping[asn] |= inTH // including the zero ASN that means unknown
}
for asn, where := range mapping {