Documentation
¶
Overview ¶
Package geolocate implements IP lookup, resolver lookup, and GeoIP location an OONI Probe instance.
Index ¶
- Variables
- func AvastIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- func IPConfigIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- func IPInfoIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- func LookupASN(path, ip string) (asn uint, org string, err error)
- func LookupAllResolverIPs(ctx context.Context, resolver HostLookupper) (ips []string, err error)
- func LookupCC(path, ip string) (cc string, err error)
- func LookupFirstResolverIP(ctx context.Context, resolver HostLookupper) (ip string, err error)
- func STUNEkigaIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- func STUNGoogleIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- func STUNIPLookup(ctx context.Context, config STUNConfig) (string, error)
- func UbuntuIPLookup(ctx context.Context, httpClient *http.Client, logger model.Logger, ...) (string, error)
- type AvastResponse
- type HostLookupper
- type IPInfoResponse
- type IPLookupClient
- type LookupFunc
- type STUNClient
- type STUNConfig
- type UbuntuResponse
Constants ¶
This section is empty.
Variables ¶
var ErrAllIPLookuppersFailed = errors.New("all IP lookuppers failed")
ErrAllIPLookuppersFailed indicates that we failed with looking up the probe IP for with all the lookuppers that we tried.
Functions ¶
func AvastIPLookup ¶
func AvastIPLookup( ctx context.Context, httpClient *http.Client, logger model.Logger, userAgent string, ) (string, error)
AvastIPLookup performs the IP lookup using Avast services.
func IPConfigIPLookup ¶ added in v0.20.0
func IPConfigIPLookup( ctx context.Context, httpClient *http.Client, logger model.Logger, userAgent string, ) (string, error)
IPConfigIPLookup performs the IP lookup using ipconfig.io.
func IPInfoIPLookup ¶ added in v0.20.0
func IPInfoIPLookup( ctx context.Context, httpClient *http.Client, logger model.Logger, userAgent string, ) (string, error)
IPInfoIPLookup performs the IP lookup using ipinfo.io
func LookupASN ¶
LookupASN maps the ip to the probe ASN and org using the MMDB database located at path, or returns an error. In case the IP is not valid, this function will fail with an error complaining that geoip2 was passed a nil IP.
func LookupAllResolverIPs ¶
func LookupAllResolverIPs(ctx context.Context, resolver HostLookupper) (ips []string, err error)
LookupAllResolverIPs returns all resolver IPs
func LookupFirstResolverIP ¶
func LookupFirstResolverIP(ctx context.Context, resolver HostLookupper) (ip string, err error)
LookupFirstResolverIP returns the first resolver IP
func STUNEkigaIPLookup ¶ added in v0.20.0
func STUNEkigaIPLookup( ctx context.Context, httpClient *http.Client, logger model.Logger, userAgent string, ) (string, error)
STUNEkigaIPLookup performs the IP lookup using ekiga.net.
func STUNGoogleIPLookup ¶ added in v0.20.0
func STUNGoogleIPLookup( ctx context.Context, httpClient *http.Client, logger model.Logger, userAgent string, ) (string, error)
STUNGoogleIPLookup performs the IP lookup using google.com.
func STUNIPLookup ¶ added in v0.20.0
func STUNIPLookup(ctx context.Context, config STUNConfig) (string, error)
STUNIPLookup performs the IP lookup using STUN.
Types ¶
type AvastResponse ¶
type AvastResponse struct {
IP string `json:"ip"`
}
AvastResponse is the response returned by Avast IP lookup services.
type HostLookupper ¶
type HostLookupper interface {
LookupHost(ctx context.Context, host string) (addrs []string, err error)
}
HostLookupper is an interface that looks up the name of a host.
type IPInfoResponse ¶ added in v0.20.0
type IPInfoResponse struct {
IP string `json:"ip"`
}
IPInfoResponse is the response returned by ipinfo.io
type IPLookupClient ¶
type IPLookupClient struct {
// HTTPClient is the HTTP client to use
HTTPClient *http.Client
// Logger is the logger to use
Logger model.Logger
// UserAgent is the user agent to use
UserAgent string
}
IPLookupClient is an iplookup client
func (IPLookupClient) Do ¶
func (c IPLookupClient) Do(ctx context.Context) (string, error)
Do performs the IP lookup.
func (IPLookupClient) DoWithCustomFunc ¶
func (c IPLookupClient) DoWithCustomFunc( ctx context.Context, fn LookupFunc, ) (string, error)
DoWithCustomFunc performs the IP lookup with a custom function.
type LookupFunc ¶
type LookupFunc func( ctx context.Context, client *http.Client, logger model.Logger, userAgent string, ) (string, error)
LookupFunc is a function for performing the IP lookup.
type STUNClient ¶ added in v0.20.0
STUNClient is the STUN client expected by this package
type STUNConfig ¶ added in v0.20.0
type STUNConfig struct {
Dial func(network string, address string) (STUNClient, error)
Endpoint string
Logger model.Logger
}
STUNConfig contains configuration for STUNIPLookup
type UbuntuResponse ¶
UbuntuResponse is the response by Ubuntu IP lookup services.