summaryrefslogtreecommitdiff
path: root/pkg/vpn
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-09-08 03:32:46 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-09-08 20:09:48 +0200
commita0e67fe3feb5b3a2d6d0f8e5f33ff96007955b17 (patch)
treecda0ca1934af399385c21a67fe56b55577c7c2a5 /pkg/vpn
parente591c3147e3c504611ff612e8918018125ffa2eb (diff)
[feat] lookup the config vars at runtime
- Resolves: #326
Diffstat (limited to 'pkg/vpn')
-rw-r--r--pkg/vpn/bonafide/bonafide.go10
-rw-r--r--pkg/vpn/bonafide/eip_service.go7
-rw-r--r--pkg/vpn/launcher_linux.go5
3 files changed, 9 insertions, 13 deletions
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go
index 6630352..e65e193 100644
--- a/pkg/vpn/bonafide/bonafide.go
+++ b/pkg/vpn/bonafide/bonafide.go
@@ -40,10 +40,6 @@ const (
certPathv1 = "1/cert"
certPathv3 = "3/cert"
authPathv3 = "3/auth"
-
- certAPI = config.APIURL + certPathv1
- certAPI3 = config.APIURL + certPathv3
- authAPI = config.APIURL + authPathv3
)
type Bonafide struct {
@@ -185,11 +181,11 @@ func (b *Bonafide) getURL(object string) string {
if b.apiURL == "" {
switch object {
case "cert":
- return certAPI
+ return config.APIURL + certPathv1
case "certv3":
- return certAPI3
+ return config.APIURL + certPathv3
case "auth":
- return authAPI
+ return config.APIURL + authPathv3
}
} else {
switch object {
diff --git a/pkg/vpn/bonafide/eip_service.go b/pkg/vpn/bonafide/eip_service.go
index 961ac40..21cc8e8 100644
--- a/pkg/vpn/bonafide/eip_service.go
+++ b/pkg/vpn/bonafide/eip_service.go
@@ -14,11 +14,6 @@ import (
"0xacab.org/leap/bitmask-vpn/pkg/config"
)
-const (
- eip1API = config.APIURL + "1/config/eip-service.json"
- eip3API = config.APIURL + "3/config/eip-service.json"
-)
-
type eipService struct {
Gateways []gatewayV3
Locations map[string]location
@@ -83,6 +78,7 @@ func (b *Bonafide) setupAuthentication(i interface{}) {
}
func (b *Bonafide) fetchEipJSON() error {
+ eip3API := config.APIURL + "3/config/eip-service.json"
resp, err := b.client.Post(eip3API, "", nil)
for err != nil {
log.Printf("Error fetching eip v3 json: %v", err)
@@ -98,6 +94,7 @@ func (b *Bonafide) fetchEipJSON() error {
buf := make([]byte, 128)
resp.Body.Read(buf)
log.Printf("Error fetching eip v3 json")
+ eip1API := config.APIURL + "1/config/eip-service.json"
resp, err = b.client.Post(eip1API, "", nil)
if err != nil {
return err
diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go
index 1280eae..3a29789 100644
--- a/pkg/vpn/launcher_linux.go
+++ b/pkg/vpn/launcher_linux.go
@@ -29,7 +29,10 @@ import (
)
const (
- systemOpenvpnPath = "/usr/sbin/openvpn"
+ systemOpenvpnPath = "/usr/sbin/openvpn"
+)
+
+var (
snapOpenvpnPath = "/snap/bin/" + config.BinaryName + ".openvpn"
snapBitmaskRootPath = "/snap/bin/" + config.BinaryName + ".bitmask-root"
)