summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorkali <kali@win>2020-09-25 17:46:50 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-09-25 21:00:08 +0200
commit5d102497e80f17056ce97bcc58a4906cf8a05c28 (patch)
tree3052ed39a403fc4f73d7d73f60597caaca9d2a75 /pkg
parent5518645dfdfd1250dcabd98bda5d71d18eb4edcc (diff)
[bug] workaround for helper path in windows
Diffstat (limited to 'pkg')
-rw-r--r--pkg/helper/helper.go4
-rw-r--r--pkg/helper/windows.go18
2 files changed, 15 insertions, 7 deletions
diff --git a/pkg/helper/helper.go b/pkg/helper/helper.go
index 9d0b330..691fc6e 100644
--- a/pkg/helper/helper.go
+++ b/pkg/helper/helper.go
@@ -29,9 +29,9 @@ import (
)
var (
- AppName = "DemoLibVPN"
+ AppName = "DemoLibVPN"
BinaryName = "bitmask"
- Version = "git"
+ Version = "git"
)
type openvpnT struct {
diff --git a/pkg/helper/windows.go b/pkg/helper/windows.go
index ef4f271..44ac6f5 100644
--- a/pkg/helper/windows.go
+++ b/pkg/helper/windows.go
@@ -33,8 +33,10 @@ import (
var (
svcName = BinaryName + `-helper-v2`
+
+ // XXX this is set to c:\WINDOWS\system32 on initialization. Do not use it, use a function call instead.
appPath = getExecDir()
- LogFolder = appPath
+ LogFolder = getExecDir()
openvpnPath = path.Join(appPath, "openvpn.exe")
chocoOpenvpnPath = `C:\Program Files\OpenVPN\bin\openvpn.exe`
platformOpenvpnFlags = []string{
@@ -47,9 +49,11 @@ var (
func getExecDir() string {
ex, err := os.Executable()
if err != nil {
- log.Fatal("Cannot find executable path")
+ log.Println("Cannot find executable path")
+ return ""
}
- return path.Dir(ex)
+ /* XXX filepath.Abs is buggy, maybe because of spaces in the path. fuck it, this is good enough for now */
+ return strings.Replace(ex, "\\helper.exe", "", 1)
}
type httpConf struct {
@@ -131,11 +135,15 @@ func daemonize() {}
func runServer(port int) {}
func getOpenvpnPath() string {
- if _, err := os.Stat(openvpnPath); !os.IsNotExist(err) {
- return openvpnPath
+ openvpn := path.Join(getExecDir(), "openvpn.exe")
+ if _, err := os.Stat(openvpn); !os.IsNotExist(err) {
+ log.Println("DEBUG: openvpnpath found,", openvpnPath)
+ return openvpn
} else if _, err := os.Stat(chocoOpenvpnPath); !os.IsNotExist(err) {
+ log.Println("DEBUG: choco openvpn found,", chocoOpenvpnPath)
return chocoOpenvpnPath
}
+ log.Println("DEBUG: did not find system-wide openvpn...")
return "openvpn.exe"
}