summaryrefslogtreecommitdiff
path: root/pkg/helper/windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/helper/windows.go')
-rw-r--r--pkg/helper/windows.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/pkg/helper/windows.go b/pkg/helper/windows.go
index 5eef863..ef4f271 100644
--- a/pkg/helper/windows.go
+++ b/pkg/helper/windows.go
@@ -1,5 +1,5 @@
// +build windows
-// Copyright (C) 2018 LEAP
+// Copyright (C) 2018-2020 LEAP
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -23,25 +23,20 @@ import (
"os/exec"
"strconv"
"strings"
+ "path"
- "0xacab.org/leap/bitmask-vpn/pkg/config"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
)
-const (
- svcName = config.BinaryName + `-helper-v2`
- appPath = `C:\Program Files\` + config.ApplicationName + `\`
- LogFolder = appPath
- openvpnPath = appPath + `openvpn.exe`
- chocoOpenvpnPath = `C:\Program Files\OpenVPN\bin\openvpn.exe`
-)
-type httpConf struct {
- BindAddr string
-}
var (
+ svcName = BinaryName + `-helper-v2`
+ appPath = getExecDir()
+ LogFolder = appPath
+ openvpnPath = path.Join(appPath, "openvpn.exe")
+ chocoOpenvpnPath = `C:\Program Files\OpenVPN\bin\openvpn.exe`
platformOpenvpnFlags = []string{
"--script-security", "1",
"--block-outside-dns",
@@ -49,6 +44,19 @@ var (
httpServerConf = &httpConf{}
)
+func getExecDir() string {
+ ex, err := os.Executable()
+ if err != nil {
+ log.Fatal("Cannot find executable path")
+ }
+ return path.Dir(ex)
+}
+
+type httpConf struct {
+ BindAddr string
+}
+
+
// parseCliArgs allows the helper binary to install/uninstall itself. It requires admin privileges.
// However, be warned: if you intend to use it from the command line, you will have to compile it with the Go compiler yourself.
// the version we're shipping (ie, cross-compiled with the mingw compiler) apparently is not able to output to stdout/stderr properly.