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
commit 110a11828b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 224 additions and 211 deletions

View file

@ -91,10 +91,10 @@ func (c ipLookupClient) doWithCustomFunc(
defer clnt.CloseIdleConnections()
ip, err := fn(ctx, clnt, c.Logger, c.UserAgent)
if err != nil {
return DefaultProbeIP, err
return model.DefaultProbeIP, err
}
if net.ParseIP(ip) == nil {
return DefaultProbeIP, fmt.Errorf("%w: %s", ErrInvalidIPAddress, ip)
return model.DefaultProbeIP, fmt.Errorf("%w: %s", ErrInvalidIPAddress, ip)
}
c.Logger.Debugf("iplookup: IP: %s", ip)
return ip, nil
@ -110,5 +110,5 @@ func (c ipLookupClient) LookupProbeIP(ctx context.Context) (string, error) {
}
union.Add(err)
}
return DefaultProbeIP, union
return model.DefaultProbeIP, union
}