diff options
author | Ruben Pollan <meskio@sindominio.net> | 2019-01-15 17:19:19 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2019-01-15 17:26:06 +0100 |
commit | 52d7fa7c91dd5bad49f07e33956681b5e341c6fa (patch) | |
tree | 0cd14b39203ef5652ee2c76ac27320db4abb4ef8 /pkg/standalone | |
parent | 80b6aef1206fb63f1a2985f003f6b484a23bb949 (diff) |
[feat] move provider configuration into a set of constants
Diffstat (limited to 'pkg/standalone')
-rw-r--r-- | pkg/standalone/bonafide.go | 46 | ||||
-rw-r--r-- | pkg/standalone/launcher_linux.go | 9 | ||||
-rw-r--r-- | pkg/standalone/main.go | 3 |
3 files changed, 14 insertions, 44 deletions
diff --git a/pkg/standalone/bonafide.go b/pkg/standalone/bonafide.go index c4d588e..a0ed3b6 100644 --- a/pkg/standalone/bonafide.go +++ b/pkg/standalone/bonafide.go @@ -29,50 +29,16 @@ import ( "strconv" "strings" "time" + + "0xacab.org/leap/bitmask-systray/pkg/config" ) const ( - certAPI = "https://api.black.riseup.net/1/cert" - eipAPI = "https://api.black.riseup.net/1/config/eip-service.json" - geolocationAPI = "https://api.black.riseup.net:9001/json" + certAPI = config.APIURL + "1/cert" + eipAPI = config.APIURL + "1/config/eip-service.json" secondsPerHour = 60 * 60 ) -var ( - caCert = []byte(`-----BEGIN CERTIFICATE----- -MIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl -dXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE -AwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw -NDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM -Emh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv -b3Q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V2ZWDzHQO4hMkiTQ -4ZckuaL201F68YpiItBNnJ9N5nHr1MRiGyApHmLXY/wvlrOpclh95qn+lG6/2jk7 -3AmihLOKYMlPwPakJg4PYczm3icFLgTpjV5sq2md9bRyAg3oPGfAuWHmKj2Ikqch -Td5CHKGxEEWbGUWEMP0s1A/JHWiCbDigc4Cfxhy56CWG4q0tYtnc2GMw8OAUO6Wf -Xu5pYKNkzKSEtT/MrNJt44tTZWbKV/Pi/N2Fx36my7TgTUj7g3xcE9eF4JV2H/sg -tsK3pwE0FEqGnT4qMFbixQmc8bGyuakr23wjMvfO7eZUxBuWYR2SkcP26sozF9PF -tGhbZHQVGZUTVPyvwahMUEhbPGVerOW0IYpxkm0x/eaWdTc4vPpf/rIlgbAjarnJ -UN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp -0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO ------END CERTIFICATE-----`) -) - type bonafide struct { client httpClient tzOffsetHours int @@ -121,7 +87,7 @@ type geoLocation struct { func newBonafide() *bonafide { certs := x509.NewCertPool() - certs.AppendCertsFromPEM(caCert) + certs.AppendCertsFromPEM(config.CaCert) client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ @@ -195,7 +161,7 @@ func (b *bonafide) getOpenvpnArgs() ([]string, error) { } func (b *bonafide) fetchGeolocation() ([]string, error) { - resp, err := b.client.Post(geolocationAPI, "", nil) + resp, err := b.client.Post(config.GeolocationAPI, "", nil) if err != nil { return nil, err } diff --git a/pkg/standalone/launcher_linux.go b/pkg/standalone/launcher_linux.go index 672eb1f..b7e5f3d 100644 --- a/pkg/standalone/launcher_linux.go +++ b/pkg/standalone/launcher_linux.go @@ -21,11 +21,14 @@ import ( "log" "os" "os/exec" + + "0xacab.org/leap/bitmask-systray/pkg/config" ) const ( - systemOpenvpnPath = "/usr/sbin/openvpn" - snapOpenvpnPath = "/snap/bin/riseup-vpn.openvpn" + systemOpenvpnPath = "/usr/sbin/openvpn" + snapOpenvpnPath = "/snap/bin/" + config.BinaryName + ".openvpn" + snapBitmaskRootPath = "snap/bin/" + config.BinaryName + ".bitmask-root" ) var bitmaskRootPaths = []string{ @@ -118,7 +121,7 @@ func runBitmaskRoot(arg ...string) error { func bitmaskRootPath() (string, error) { if os.Getenv("SNAP") != "" { - path := "/snap/bin/riseup-vpn.bitmask-root" + path := snapBitmaskRootPath if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } diff --git a/pkg/standalone/main.go b/pkg/standalone/main.go index f7e1976..d5618e5 100644 --- a/pkg/standalone/main.go +++ b/pkg/standalone/main.go @@ -20,6 +20,7 @@ import ( "log" "os" + "0xacab.org/leap/bitmask-systray/pkg/config" "github.com/apparentlymart/go-openvpn-mgmt/openvpn" ) @@ -50,7 +51,7 @@ func Init() (*Bitmask, error) { if err != nil { return nil, err } - err = ioutil.WriteFile(b.getCaCertPath(), caCert, 0600) + err = ioutil.WriteFile(b.getCaCertPath(), config.CaCert, 0600) go b.openvpnManagement() return &b, err |