summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xbranding/scripts/gen-providers-json15
-rwxr-xr-xbranding/scripts/generate-debian4
-rwxr-xr-xbranding/scripts/generate-snap4
-rwxr-xr-xbranding/scripts/generate-vendor-make4
-rwxr-xr-xbranding/scripts/getparam6
-rw-r--r--branding/scripts/provider.py5
-rw-r--r--pkg/backend/api.go16
-rw-r--r--providers/vendor.conf38
9 files changed, 53 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index d7022a3..55f04dc 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ SKIP_CACHECK ?= no
VENDOR_PATH ?= providers
APPNAME ?= $(shell VENDOR_PATH=${VENDOR_PATH} branding/scripts/getparam appname | tail -n 1)
TARGET ?= $(shell VENDOR_PATH=${VENDOR_PATH} branding/scripts/getparam binname | tail -n 1)
-PROVIDER ?= $(shell grep ^'provider =' ${VENDOR_PATH}/vendor.conf | cut -d '=' -f 2 | tr -d "[:space:]")
+PROVIDER ?= $(shell grep ^'provider =' ${VENDOR_PATH}/vendor.conf | cut -d '=' -f 2 | cut -d ',' -f 1 | tr -d "[:space:]")
VERSION ?= $(shell git describe 2> /dev/null)
ifeq ($(VERSION),)
VERSION := "unknown"
diff --git a/branding/scripts/gen-providers-json b/branding/scripts/gen-providers-json
index 0c95cb9..8fd64c6 100755
--- a/branding/scripts/gen-providers-json
+++ b/branding/scripts/gen-providers-json
@@ -5,8 +5,7 @@ import json
import os
import sys
-
-from provider import getDefaultProvider
+from provider import getDefaultProviders
from provider import getProviderData
OUTFILE = 'providers.json'
@@ -22,14 +21,14 @@ def generateProvidersJSON(configPath, outputJSONPath):
# For multi-provider, just add more providers to the dict
providers = {}
- defaultProvider = getDefaultProvider(config)
+ defaultProviders = getDefaultProviders(config)
- providers['default'] = defaultProvider
+ providers['default'] = defaultProviders[0]
providers['providers'] = []
- providerData = getProviderData(defaultProvider, config)
- addCaData(providerData, configPath)
-
- providers['providers'].append(providerData)
+ for p in defaultProviders:
+ providerData = getProviderData(p, config)
+ addCaData(providerData, configPath)
+ providers['providers'].append(providerData)
with open(outputJSONPath, 'w', encoding='utf-8') as f:
json.dump(providers, f, ensure_ascii=False, indent=4)
diff --git a/branding/scripts/generate-debian b/branding/scripts/generate-debian
index 0db1fde..7a572ce 100755
--- a/branding/scripts/generate-debian
+++ b/branding/scripts/generate-debian
@@ -6,7 +6,7 @@ import sys
import configparser
-from provider import getDefaultProvider
+from provider import getDefaultProviders
from provider import getProviderData
@@ -24,7 +24,7 @@ if __name__ == "__main__":
configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
config.read(configFile)
- provider = getDefaultProvider(config)
+ provider = getDefaultProviders(config)[0]
data = getProviderData(provider, config)
if len(sys.argv) != 2:
diff --git a/branding/scripts/generate-snap b/branding/scripts/generate-snap
index 3271d9e..0cb0f19 100755
--- a/branding/scripts/generate-snap
+++ b/branding/scripts/generate-snap
@@ -6,7 +6,7 @@ import sys
import configparser
-from provider import getDefaultProvider
+from provider import getDefaultProviders
from provider import getProviderData
@@ -25,7 +25,7 @@ if __name__ == "__main__":
configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
config.read(configFile)
- provider = getDefaultProvider(config)
+ provider = getDefaultProviders(config)[0]
data = getProviderData(provider, config)
if len(sys.argv) != 2:
diff --git a/branding/scripts/generate-vendor-make b/branding/scripts/generate-vendor-make
index 60dc180..9844e6a 100755
--- a/branding/scripts/generate-vendor-make
+++ b/branding/scripts/generate-vendor-make
@@ -8,7 +8,7 @@ import sys
import configparser
-from provider import getDefaultProvider
+from provider import getDefaultProviders
from provider import getProviderData
@@ -40,7 +40,7 @@ if __name__ == "__main__":
configFile = os.path.join(VENDOR_PATH, 'vendor.conf')
config = configparser.ConfigParser()
config.read(configFile)
- provider = getDefaultProvider(config)
+ provider = getDefaultProviders(config)[0]
data = getProviderData(provider, config)
if len(sys.argv) != 2:
diff --git a/branding/scripts/getparam b/branding/scripts/getparam
index 005abb1..100cb5d 100755
--- a/branding/scripts/getparam
+++ b/branding/scripts/getparam
@@ -8,7 +8,7 @@ import configparser
import os
import sys
-from provider import getDefaultProvider
+from provider import getDefaultProviders
from provider import getProviderData
def getData():
@@ -20,8 +20,8 @@ def getData():
sys.exit(1)
config = configparser.ConfigParser()
config.read(configPath)
- defaultProvider = getDefaultProvider(config)
- return getProviderData(getDefaultProvider(config), config)
+ defaultProvider = getDefaultProviders(config)[0]
+ return getProviderData(defaultProvider, config)
if __name__ == "__main__":
param = sys.argv[1]
diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py
index 90daa13..7900feb 100644
--- a/branding/scripts/provider.py
+++ b/branding/scripts/provider.py
@@ -2,14 +2,15 @@ import datetime
import os
-def getDefaultProvider(config):
+def getDefaultProviders(config):
+ # returns a list of providers
provider = os.environ.get('PROVIDER')
if provider:
print('[+] Got provider {} from environment'.format(provider))
else:
print('[+] Using default provider from config file')
provider = config['default']['provider']
- return provider
+ return provider.split(',')
def getProviderData(provider, config):
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index dc7cbbf..8f36f1f 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -5,7 +5,9 @@ package backend
import (
"C"
"encoding/json"
+ "fmt"
"log"
+ "os"
"strconv"
"strings"
"unsafe"
@@ -150,10 +152,20 @@ func InitOptsFromJSON(provider, providersJSON string) *InitOpts {
if err != nil {
log.Println("ERROR while parsing json:", err)
}
+ var providerOpts *bitmask.ProviderOpts
+ providerOpts = &providers.Data[0]
if len(providers.Data) != 1 {
- panic("BUG: we do not support multi-provider yet")
+ chosenProvider := os.Getenv("LEAP_PROVIDER")
+ if chosenProvider != "" {
+ for _, p := range providers.Data {
+ if p.Provider == chosenProvider {
+ log.Println("Selecting provider: " + chosenProvider)
+ return &InitOpts{ProviderOptions: &p}
+ }
+ }
+ panic("BUG: unknown provider")
+ }
}
- providerOpts := &providers.Data[0]
return &InitOpts{ProviderOptions: providerOpts}
}
diff --git a/providers/vendor.conf b/providers/vendor.conf
index fa2f60c..6eb6a5a 100644
--- a/providers/vendor.conf
+++ b/providers/vendor.conf
@@ -1,6 +1,6 @@
[default]
-provider = riseup
+provider = riseup,riseupbeta
[riseup]
@@ -21,6 +21,24 @@ geolocationAPI = https://api.black.riseup.net:9001/json
askForDonations = true
donateURL = https://riseup.net/vpn/donate
+[riseupbeta]
+
+name = RiseupBeta
+applicationName = RiseupVPN
+binaryName = riseup-vpn
+auth = anon
+
+providerURL = float.hexacab.org
+apiURL = https://api.float.hexacab.org:4430/
+caURL = https://api.float.hexacab.org/ca.crt
+
+infoURL = https://float.hexacab.org/
+tosURL = https://float.hexacab.org/
+helpURL = https://float.hexacab.org/
+
+geolocationAPI = https://menshen.float.hexacab.org/json
+askForDonations = true
+donateURL = https://riseup.net/vpn/donate
[calyx]
@@ -81,21 +99,3 @@ geolocationAPI = https://menshen.float.bitmask.net/json
askForDonations = false
donateURL =
-[riseupbeta]
-
-name = riseupbeta
-applicationName = RiseupVPN
-binaryName = riseup-vpn
-auth = anon
-
-providerURL = float.hexacab.org
-apiURL = https://api.float.hexacab.org:4430/
-caURL = https://api.float.hexacab.org/ca.crt
-
-infoURL = https://float.hexacab.org/
-tosURL = https://float.hexacab.org/
-helpURL = https://float.hexacab.org/
-
-geolocationAPI = https://menshen.float.hexacab.org/json
-askForDonations = true
-donateURL = https://riseup.net/vpn/donate