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:
parent
1e7384d1cc
commit
110a11828b
23 changed files with 224 additions and 211 deletions
|
|
@ -37,7 +37,7 @@ func stunIPLookup(ctx context.Context, config stunConfig) (string, error) {
|
|||
}
|
||||
clnt, err := dial("udp", config.Endpoint)
|
||||
if err != nil {
|
||||
return DefaultProbeIP, err
|
||||
return model.DefaultProbeIP, err
|
||||
}
|
||||
defer clnt.Close()
|
||||
message := stun.MustBuild(stun.TransactionID, stun.BindingRequest)
|
||||
|
|
@ -55,20 +55,20 @@ func stunIPLookup(ctx context.Context, config stunConfig) (string, error) {
|
|||
ipch <- xorAddr.IP.String()
|
||||
})
|
||||
if err != nil {
|
||||
return DefaultProbeIP, err
|
||||
return model.DefaultProbeIP, err
|
||||
}
|
||||
select {
|
||||
case err := <-errch:
|
||||
return DefaultProbeIP, err
|
||||
return model.DefaultProbeIP, err
|
||||
case ip := <-ipch:
|
||||
return ip, nil
|
||||
case <-ctx.Done():
|
||||
return DefaultProbeIP, ctx.Err()
|
||||
return model.DefaultProbeIP, ctx.Err()
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
config.Logger.Debugf("STUNIPLookup: failure using %s: %+v", config.Endpoint, err)
|
||||
return DefaultProbeIP, err
|
||||
return model.DefaultProbeIP, err
|
||||
}
|
||||
return ip, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue