Skip to content
Snippets Groups Projects
Unverified Commit 52d7fa7c authored by meskio's avatar meskio :tent:
Browse files

[feat] move provider configuration into a set of constants

parent 80b6aef1
No related branches found
No related tags found
1 merge request!50Feat/reorganize code
......@@ -23,13 +23,13 @@ import (
"os/signal"
"0xacab.org/leap/bitmask-systray/pkg/bitmask"
"0xacab.org/leap/bitmask-systray/pkg/config"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
const (
provider = "riseup.net"
logFile = "systray.log"
logFile = "systray.log"
)
var version string
......@@ -55,7 +55,7 @@ func start() {
}
defer b.Close()
err = b.StartVPN(provider)
err = b.StartVPN(config.Provider)
if err != nil {
log.Println(err)
os.Exit(1)
......
......@@ -30,9 +30,7 @@ import (
)
const (
provider = "riseup.net"
applicationName = "RiseupVPN"
logFile = "systray.log"
logFile = "systray.log"
)
var version string
......@@ -59,8 +57,6 @@ func main() {
os.Exit(0)
}
conf.Provider = provider
conf.ApplicationName = applicationName
conf.Version = version
conf.Printer = initPrinter()
systray.Run(conf)
......
package config
const (
ApplicationName = "RiseupVPN"
BinaryName = "riseup-vpn"
Provider = "riseup.net"
DonateURL = "https://riseup.net/vpn/donate"
HelpURL = "https://riseup.net/vpn/support"
TosURL = "https://riseup.net/tos"
APIURL = "https://api.black.riseup.net/"
GeolocationAPI = "https://api.black.riseup.net:9001/json"
)
var CaCert = []byte(`-----BEGIN CERTIFICATE-----
MIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl
dXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE
AwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw
NDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM
Emh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5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rM5wfl7JeEz8in+V2ZWDzHQO4hMkiTQ
4ZckuaL201F68YpiItBNnJ9N5nHr1MRiGyApHmLXY/wvlrOpclh95qn+lG6/2jk7
3AmihLOKYMlPwPakJg4PYczm3icFLgTpjV5sq2md9bRyAg3oPGfAuWHmKj2Ikqch
Td5CHKGxEEWbGUWEMP0s1A/JHWiCbDigc4Cfxhy56CWG4q0tYtnc2GMw8OAUO6Wf
Xu5pYKNkzKSEtT/MrNJt44tTZWbKV/Pi/N2Fx36my7TgTUj7g3xcE9eF4JV2H/sg
tsK3pwE0FEqGnT4qMFbixQmc8bGyuakr23wjMvfO7eZUxBuWYR2SkcP26sozF9PF
tGhbZHQVGZUTVPyvwahMUEhbPGVerOW0IYpxkm0x/eaWdTc4vPpf/rIlgbAjarnJ
UN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp
0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO
-----END CERTIFICATE-----`)
......@@ -36,11 +36,12 @@ import (
"path"
"strings"
"0xacab.org/leap/bitmask-systray/pkg/config"
"github.com/sevlyar/go-daemon"
)
const (
appPath = "/Applications/RiseupVPN.app/"
appPath = "/Applications/" + config.ApplicationName + ".app/"
helperPath = appPath + "Contents/helper/"
LogFolder = helperPath
openvpnPath = appPath + "Contents/Resources/openvpn.leap"
......
......@@ -20,6 +20,8 @@ import (
"log"
"os"
"os/exec"
"0xacab.org/leap/bitmask-systray/pkg/config"
)
const (
......@@ -27,7 +29,7 @@ const (
openvpnGroup = "nogroup"
LogFolder = "/var/log/"
systemOpenvpnPath = "/usr/sbin/openvpn"
snapOpenvpnPath = "/snap/bin/riseup-vpn.openvpn"
snapOpenvpnPath = "/snap/bin/" + config.BinaryName + ".openvpn"
)
var (
......
......@@ -20,10 +20,12 @@ import (
"log"
"os"
"os/exec"
"0xacab.org/leap/bitmask-systray/pkg/config"
)
const (
appPath = `C:\Program Files\RiseupVPN\`
appPath = `C:\Program Files\` + config.ApplicationName + `\`
LogFolder = appPath
openvpnPath = appPath + `openvpn.exe`
chocoOpenvpnPath = `C:\Program Files\OpenVPN\bin\openvpn.exe`
......
......@@ -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
b3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m
TP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a
7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE
LliFitEzwIegpMqxCIHXFuobGSCWF4N0qLHkq/SYUMoOJ96O3hmPSl1kFDRMtWXY
iw1SEKjUvpyDJpVs3NGxeLCaA7bAWhDY5s5Yb2fA1o8ICAqhowurowJpW7n5ZuLK
5VNTlNy6nZpkjt1QycYvNycffyPOFm/Q/RKDlvnorJIrihPkyniV3YY5cGgP+Qkx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aWdTc4vPpf/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
}
......
......@@ -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
}
......
......@@ -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
......
......@@ -34,21 +34,19 @@ var (
configPath = path.Join(config.Path, "systray.json")
)
// SystrayConfig holds the configuration of the systray
type SystrayConfig struct {
// Config holds the configuration of the systray
type Config struct {
LastNotification time.Time
Donated time.Time
SelectGateway bool
UserStoppedVPN bool
Provider string `json:"-"`
ApplicationName string `json:"-"`
Version string `json:"-"`
Printer *message.Printer `json:"-"`
}
// ParseConfig reads the configuration from the configuration file
func ParseConfig() *SystrayConfig {
var conf SystrayConfig
func ParseConfig() *Config {
var conf Config
f, err := os.Open(configPath)
if err != nil {
......@@ -62,30 +60,30 @@ func ParseConfig() *SystrayConfig {
return &conf
}
func (c *SystrayConfig) setUserStoppedVPN(vpnStopped bool) error {
func (c *Config) setUserStoppedVPN(vpnStopped bool) error {
c.UserStoppedVPN = vpnStopped
return c.save()
}
func (c *SystrayConfig) hasDonated() bool {
func (c *Config) hasDonated() bool {
return c.Donated.Add(oneMonth).After(time.Now())
}
func (c *SystrayConfig) needsNotification() bool {
func (c *Config) needsNotification() bool {
return !c.hasDonated() && c.LastNotification.Add(oneDay).Before(time.Now())
}
func (c *SystrayConfig) setNotification() error {
func (c *Config) setNotification() error {
c.LastNotification = time.Now()
return c.save()
}
func (c *SystrayConfig) setDonated() error {
func (c *Config) setDonated() error {
c.Donated = time.Now()
return c.save()
}
func (c *SystrayConfig) save() error {
func (c *Config) save() error {
f, err := os.Create(configPath)
if err != nil {
return err
......
......@@ -22,6 +22,7 @@ import (
"runtime"
"time"
"0xacab.org/leap/bitmask-systray/pkg/config"
"0xacab.org/leap/go-dialog"
"github.com/skratchdot/open-golang/open"
)
......@@ -30,24 +31,24 @@ const (
donationText = `The %s service is expensive to run. Because we don't want to store personal information about you, there is no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month.
Do you want to donate now?`
aboutText = `%[1]s is an easy, fast, and secure VPN service from riseup.net. %[1]s does not require a user account, keep logs, or track you in any way.
aboutText = `%[1]s is an easy, fast, and secure VPN service from %[2]s. %[1]s does not require a user account, keep logs, or track you in any way.
This service is paid for entirely by donations from users like you. Please donate at https://riseup.net/vpn/donate.
This service is paid for entirely by donations from users like you. Please donate at %[3]s.
By using this application, you agree to the Terms of Service available at https://riseup.net/tos. This service is provide as-is, without any warranty, and is intended for people who work to make the world a better place.
By using this application, you agree to the Terms of Service available at %[4]s. This service is provide as-is, without any warranty, and is intended for people who work to make the world a better place.
%[1]v version: %[2]s`
%[1]v version: %[5]s`
missingAuthAgent = `Could not find a polkit authentication agent. Please run one and try again.`
errorStartingVPN = `Can't connect to %s: %v`
svgFileName = "riseupvpn.svg"
)
type notificator struct {
conf *SystrayConfig
conf *Config
}
func newNotificator(conf *SystrayConfig) *notificator {
func newNotificator(conf *Config) *notificator {
n := notificator{conf}
go n.donations()
return &n
......@@ -57,7 +58,7 @@ func (n *notificator) donations() {
for {
time.Sleep(time.Hour)
if n.conf.needsNotification() {
letsDonate := dialog.Message(n.conf.Printer.Sprintf(donationText, n.conf.ApplicationName)).
letsDonate := dialog.Message(n.conf.Printer.Sprintf(donationText, config.ApplicationName)).
Title(n.conf.Printer.Sprintf("Donate")).
Icon(getIconPath()).
YesNo()
......@@ -77,7 +78,7 @@ func (n *notificator) about(version string) {
version = string(_version)
}
}
dialog.Message(n.conf.Printer.Sprintf(aboutText, n.conf.ApplicationName, version)).
dialog.Message(n.conf.Printer.Sprintf(aboutText, config.ApplicationName, config.Provider, config.DonateURL, config.TosURL, version)).
Title(n.conf.Printer.Sprintf("About")).
Icon(getIconPath()).
Info()
......@@ -98,7 +99,7 @@ func (n *notificator) authAgent() {
}
func (n *notificator) errorStartingVPN(err error) {
dialog.Message(n.conf.Printer.Sprintf(errorStartingVPN, n.conf.ApplicationName, err)).
dialog.Message(n.conf.Printer.Sprintf(errorStartingVPN, config.ApplicationName, err)).
Title(n.conf.Printer.Sprintf("Error starting VPN")).
Icon(getIconPath()).
Error()
......@@ -111,7 +112,7 @@ func getIconPath() string {
}
if runtime.GOOS == "windows" {
icoPath := `C:\Program Files\RiseupVPN\riseupvpn.ico`
icoPath := `C:\Program Files\` + config.ApplicationName + `\riseupvpn.ico`
if fileExist(icoPath) {
return icoPath
}
......@@ -123,7 +124,7 @@ func getIconPath() string {
}
if runtime.GOOS == "darwin" {
icnsPath := "/Applications/RiseupVPN.app/Contents/Resources/app.icns"
icnsPath := "/Applications/" + config.ApplicationName + ".app/Contents/Resources/app.icns"
if fileExist(icnsPath) {
return icnsPath
}
......@@ -145,7 +146,7 @@ func getIconPath() string {
return svgPath
}
svgPath = "/usr/share/riseupvpn/riseupvpn.svg"
svgPath = "/usr/share/" + config.BinaryName + "/riseupvpn.svg"
if fileExist(svgPath) {
return svgPath
}
......
......@@ -23,13 +23,13 @@ import (
"0xacab.org/leap/bitmask-systray/pkg/config"
)
func Run(conf *SystrayConfig) {
func Run(conf *Config) {
bt := bmTray{conf: conf}
go initialize(conf, &bt)
bt.start()
}
func initialize(conf *SystrayConfig, bt *bmTray) {
func initialize(conf *Config, bt *bmTray) {
if _, err := os.Stat(config.Path); os.IsNotExist(err) {
os.MkdirAll(config.Path, os.ModePerm)
}
......@@ -51,7 +51,7 @@ func initialize(conf *SystrayConfig, bt *bmTray) {
go checkAndStartBitmask(b, notify, conf)
go listenSignals(b)
as := bitmask.NewAutostart(conf.ApplicationName, getIconPath())
as := bitmask.NewAutostart(config.ApplicationName, getIconPath())
err = as.Enable()
if err != nil {
log.Printf("Error enabling autostart: %v", err)
......@@ -59,7 +59,7 @@ func initialize(conf *SystrayConfig, bt *bmTray) {
bt.loop(b, notify, as)
}
func checkAndStartBitmask(b bitmask.Bitmask, notify *notificator, conf *SystrayConfig) {
func checkAndStartBitmask(b bitmask.Bitmask, notify *notificator, conf *Config) {
err := checkAndInstallHelpers(b, notify)
if err != nil {
log.Printf("Is bitmask running? %v", err)
......@@ -92,12 +92,12 @@ func checkAndInstallHelpers(b bitmask.Bitmask, notify *notificator) error {
return nil
}
func maybeStartVPN(b bitmask.Bitmask, conf *SystrayConfig) error {
func maybeStartVPN(b bitmask.Bitmask, conf *Config) error {
if conf.UserStoppedVPN {
return nil
}
err := b.StartVPN(conf.Provider)
err := b.StartVPN(config.Provider)
conf.setUserStoppedVPN(false)
return err
}
......@@ -24,13 +24,14 @@ import (
"0xacab.org/leap/bitmask-systray/icon"
"0xacab.org/leap/bitmask-systray/pkg/bitmask"
"0xacab.org/leap/bitmask-systray/pkg/config"
"github.com/getlantern/systray"
"github.com/skratchdot/open-golang/open"
)
type bmTray struct {
bm bitmask.Bitmask
conf *SystrayConfig
conf *Config
notify *notificator
waitCh chan bool
mStatus *systray.MenuItem
......@@ -108,7 +109,7 @@ func (bt *bmTray) loop(bm bitmask.Bitmask, notify *notificator, as bitmask.Autos
case <-bt.mTurnOn.ClickedCh:
log.Println("on")
bt.changeStatus("starting")
bt.bm.StartVPN(bt.conf.Provider)
bt.bm.StartVPN(config.Provider)
bt.conf.setUserStoppedVPN(false)
case <-bt.mTurnOff.ClickedCh:
log.Println("off")
......@@ -117,10 +118,10 @@ func (bt *bmTray) loop(bm bitmask.Bitmask, notify *notificator, as bitmask.Autos
bt.conf.setUserStoppedVPN(true)
case <-bt.mHelp.ClickedCh:
open.Run("https://riseup.net/vpn/support")
open.Run(config.HelpURL)
case <-bt.mDonate.ClickedCh:
bt.conf.setDonated()
open.Run("https://riseup.net/vpn/donate")
open.Run(config.DonateURL)
case <-bt.mAbout.ClickedCh:
bitmaskVersion, err := bt.bm.Version()
versionStr := bt.conf.Version
......@@ -153,7 +154,7 @@ func (bt *bmTray) loop(bm bitmask.Bitmask, notify *notificator, as bitmask.Autos
}
func (bt *bmTray) addGateways() {
gatewayList, err := bt.bm.ListGateways(bt.conf.Provider)
gatewayList, err := bt.bm.ListGateways(config.Provider)
if err != nil {
log.Printf("Gateway initialization error: %v", err)
return
......@@ -162,7 +163,7 @@ func (bt *bmTray) addGateways() {
mGateway := systray.AddMenuItem(bt.conf.Printer.Sprintf("Route traffic through"), "")
mGateway.Disable()
for i, city := range gatewayList {
menuItem := systray.AddMenuItem(city, bt.conf.Printer.Sprintf("Use %s %v gateway", bt.conf.ApplicationName, city))
menuItem := systray.AddMenuItem(city, bt.conf.Printer.Sprintf("Use %s %v gateway", config.ApplicationName, city))
gateway := gatewayTray{menuItem, city}
if i == 0 {
......@@ -203,14 +204,14 @@ func (bt *bmTray) changeStatus(status string) {
case "on":
systray.SetIcon(icon.On)
bt.mTurnOff.SetTitle(printer.Sprintf("Turn off"))
statusStr = printer.Sprintf("%s on", bt.conf.ApplicationName)
statusStr = printer.Sprintf("%s on", config.ApplicationName)
bt.mTurnOn.Hide()
bt.mTurnOff.Show()
case "off":
systray.SetIcon(icon.Off)
bt.mTurnOn.SetTitle(printer.Sprintf("Turn on"))
statusStr = printer.Sprintf("%s off", bt.conf.ApplicationName)
statusStr = printer.Sprintf("%s off", config.ApplicationName)
bt.mTurnOn.Show()
bt.mTurnOff.Hide()
......@@ -218,14 +219,14 @@ func (bt *bmTray) changeStatus(status string) {
bt.waitCh = make(chan bool)
go bt.waitIcon()
bt.mTurnOff.SetTitle(printer.Sprintf("Cancel"))
statusStr = printer.Sprintf("Connecting to %s", bt.conf.ApplicationName)
statusStr = printer.Sprintf("Connecting to %s", config.ApplicationName)
bt.mTurnOn.Hide()
bt.mTurnOff.Show()
case "stopping":
bt.waitCh = make(chan bool)
go bt.waitIcon()
statusStr = printer.Sprintf("Stopping %s", bt.conf.ApplicationName)
statusStr = printer.Sprintf("Stopping %s", config.ApplicationName)
bt.mTurnOn.Hide()
bt.mTurnOff.Hide()
......@@ -233,7 +234,7 @@ func (bt *bmTray) changeStatus(status string) {
systray.SetIcon(icon.Blocked)
bt.mTurnOn.SetTitle(printer.Sprintf("Retry"))
bt.mTurnOff.SetTitle(printer.Sprintf("Turn off"))
statusStr = printer.Sprintf("%s blocking internet", bt.conf.ApplicationName)
statusStr = printer.Sprintf("%s blocking internet", config.ApplicationName)
bt.mTurnOn.Show()
bt.mTurnOff.Show()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment