Skip to content

Improve Config/API struct (support for STUN servers, Add config as a member to API)

Geolocation lookup - new fields in provider config and implementation

New fields for provider config

location_lookup_stun_uris = [ selfHostedStunServer, optionalPublicStunServer ]
* list of authorized stun servers used for the client's IP lookup, as per definition, the first entry should be the self hosted one in case a provider has deployed one

location_lookup_geoip_uri = hostname
* URL to the geoip lookup service, it needs to follow the ooni API v1 scheme

The whole GeoLocationLookup feature is only used when location_lookup_stun_uris list is not empty and location_lookup_geoip_uri is not an empty string

Explanation

  • We don't use WebAPIs, because their APIs are different it's hard to put them in a list there
  • STUN servers can easily be blocked in coorperate networks (strange ports, use udp)
  • A provider can choose to disable the feature completely (by leaving both fields empty), to use public services or to self-host them
  • Therefore we want to implement a fallback mechanism

Implementation details

  • [DESKTOP/ANDROID] save last country code
  • [DESKTOP/ANDROID] After calling NewConfig() (bitmask-core), the client needs to set config.BaseCountry = "last saved country code"
  • Maybe add CountryCode as parameter to NewConfig(countryCode string)?
  • also for the IP2CC endpoint?
  • also for stun servers?
  • [bitmask-core] in DoGeolocationLookup, if fetching the country code fails, use the one stored in config.BaseCountry.
  • If DoGeolocationLookup fails, return an error
  • If DoGeolocationLookup succeeds, return nil for the error and the country code
  • [bitmask-core] config.BaseCountry is not an overwrite. It's a fallback.
  • [bitmask-core] DoGeolocationLookup gets a list of STUN servers as parameter. The provider can choose these are private or public. The list is not shuffled
  • [DESKTOP/ANDROID] DoGeolocationLookup is only called, when location_lookup_stun_uris list is not empty and location_lookup_geoip_uri is not an empty string

Interface changes in bitmask-core

  • API vs Config structs => save Config struct in API struct
  • func (api *API) DoGeolocationLookup(stunServers []string, IP2CCUrl string ) (countryCode string, err error)
  • calls geolocate.FindCurrentHostGeolocation(STUNServers, IP2CCUrl)
Edited by Pea Nut