Skip to content
Snippets Groups Projects
Verified Commit c5f84872 authored by Pea Nut's avatar Pea Nut
Browse files

Add STUNServers countryCodeLookupURL fields to provider config (geolocation lookup)

- add new fields STUNServers and countryCodeLookupURL in providers/vendor.conf (required for the geolocation lookup)
- load new fields STUNServers and countryCodeLookupURL from providers json
- update gen-providers-json script to support geolocation lookup (the STUN servers should be separated with , in providers/vendor.conf)
parent 5be04133
Branches
Tags
2 merge requests!264[check-ci] [donot merge] Update bitmask-core dependency,!253Add geolocation lookup feature, fixes #902
......@@ -24,9 +24,11 @@ def getProviderData(provider, config):
keys = ('name', 'applicationName', 'binaryName', 'auth', 'authEmptyPass',
'providerURL', 'tosURL', 'helpURL',
'askForDonations', 'donateURL', 'apiURL',
'apiVersion', 'geolocationAPI', 'caCertString')
'apiVersion', 'geolocationAPI', 'caCertString',
'STUNServers', 'countryCodeLookupURL')
boolValues = ['askForDonations', 'authEmptyPass']
intValues = ['apiVersion', ]
listValues = ['STUNServers']
for value in keys:
if value not in c:
......@@ -36,6 +38,13 @@ def getProviderData(provider, config):
d[value] = bool(d[value])
elif value in intValues:
d[value] = int(d[value])
elif value in listValues:
if d[value].strip() == "":
d[value] = []
else:
d[value] = d[value].split(",")
# remove spaces
d[value] = [x.strip() for x in d[value]]
d['timeStamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(
datetime.datetime.now())
......
......@@ -29,20 +29,22 @@ type ProviderInfo struct {
}
type ProviderOpts struct {
Provider string `json:"name"`
AppName string `json:"applicationName"`
BinaryName string `json:"binaryName"`
Auth string `json:"auth"`
AuthEmptyPass bool `json:"authEmptyPass"`
ProviderURL string `json:"providerURL"`
DonateURL string `json:"donateURL"`
ApiURL string `json:"apiURL"`
TosURL string `json:"tosURL"`
HelpURL string `json:"helpURL"`
GeolocationURL string `json:"geolocationAPI"`
AskForDonations bool `json:"askForDonations"`
CaCert string `json:"caCertString"`
ApiVersion int `json:"apiVersion"`
Provider string `json:"name"`
AppName string `json:"applicationName"`
BinaryName string `json:"binaryName"`
Auth string `json:"auth"`
AuthEmptyPass bool `json:"authEmptyPass"`
ProviderURL string `json:"providerURL"`
DonateURL string `json:"donateURL"`
ApiURL string `json:"apiURL"`
TosURL string `json:"tosURL"`
HelpURL string `json:"helpURL"`
GeolocationURL string `json:"geolocationAPI"`
AskForDonations bool `json:"askForDonations"`
CaCert string `json:"caCertString"`
ApiVersion int `json:"apiVersion"`
STUNServers []string `json:"STUNServers"`
CountryCodeLookupURL string `json:"countryCodeLookupURL"`
}
func GetConfiguredProvider() *ProviderInfo {
......@@ -60,6 +62,8 @@ func ConfigureProvider(opts *ProviderOpts) {
config.APIURL = opts.ApiURL
config.CaCert = []byte(opts.CaCert)
config.ApiVersion = opts.ApiVersion
config.STUNServers = opts.STUNServers
config.CountryCodeLookupURL = opts.CountryCodeLookupURL
}
func InitializeBitmask(conf *config.Config) (Bitmask, error) {
......
package config
var (
Provider = ""
ApplicationName = ""
BinaryName = ""
Auth = ""
APIURL = ""
GeolocationAPI = ""
ApiVersion = -1
CaCert = []byte("")
Provider = ""
ApplicationName = ""
BinaryName = ""
Auth = ""
APIURL = ""
GeolocationAPI = ""
ApiVersion = -1
CaCert = []byte("")
STUNServers = []string{}
CountryCodeLookupURL = ""
)
......@@ -38,6 +38,8 @@ func New() (*Menshen, error) {
if err != nil {
return nil, err
}
cfg.STUNServers = config.STUNServers
cfg.CountryCodeLookupURL = config.CountryCodeLookupURL
api, err := bootstrap.NewAPI(cfg)
if err != nil {
......
......@@ -22,6 +22,9 @@ geolocationAPI = https://api.black.riseup.net:9001/json
askForDonations = true
donateURL = https://riseup.net/vpn/donate
STUNServers =
countryCodeLookupURL =
[riseupbeta]
name = RiseupBeta
......@@ -42,6 +45,9 @@ geolocationAPI = https://menshen.float.hexacab.org/json
askForDonations = true
donateURL = https://riseup.net/vpn/donate
STUNServers =
countryCodeLookupURL =
[calyx]
name = Calyx
......@@ -61,6 +67,9 @@ geolocationAPI = https://api.black.riseup.net:9001/json
askForDonations = false
donateURL =
STUNServers =
countryCodeLookupURL =
[demolib]
......@@ -83,6 +92,9 @@ geolocationAPI = https://getmyip.vpnlib.bitmask.net/json
askForDonations = false
donateURL =
STUNServers =
countryCodeLookupURL =
[floatdemo]
name = floatdemo
......@@ -103,6 +115,9 @@ geolocationAPI = https://menshen.float.bitmask.net/json
askForDonations = false
donateURL =
STUNServers =
countryCodeLookupURL =
[bitmask]
......@@ -123,3 +138,6 @@ helpURL = https://demo.bitmask.net/support
geolocationAPI = https://menshen.demo.bitmask.net/json
askForDonations = false
donateURL =
STUNServers =
countryCodeLookupURL =
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment