From 5518645dfdfd1250dcabd98bda5d71d18eb4edcc Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 25 Sep 2020 16:49:46 +0200 Subject: [pkg] windows helper and qtinstaller --- pkg/bitmask/autostart.go | 4 +++- pkg/bitmask/init.go | 3 --- pkg/helper/helper.go | 10 ++++++++-- pkg/helper/windows.go | 32 ++++++++++++++++++++------------ 4 files changed, 31 insertions(+), 18 deletions(-) (limited to 'pkg') diff --git a/pkg/bitmask/autostart.go b/pkg/bitmask/autostart.go index f314dbc..f8f0f19 100644 --- a/pkg/bitmask/autostart.go +++ b/pkg/bitmask/autostart.go @@ -1,3 +1,5 @@ +// +build !windows + // Copyright (C) 2018 LEAP // // This program is free software: you can redistribute it and/or modify @@ -35,7 +37,7 @@ type Autostart interface { Enable() error } -// newAutostart creates a handler for the autostart of your platform +// NewAutostart creates a handler for the autostart of your platform func NewAutostart(appName string, iconPath string) Autostart { exec := os.Args if os.Getenv("SNAP") != "" { diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go index 00f145e..3e040b4 100644 --- a/pkg/bitmask/init.go +++ b/pkg/bitmask/init.go @@ -16,8 +16,6 @@ package bitmask import ( - "errors" - "fmt" "log" "os" "path" @@ -91,7 +89,6 @@ func initBitmask() (Bitmask, error) { b, err := vpn.Init() if err != nil { log.Printf("An error ocurred starting bitmask: %v", err) - err = errors.New(fmt.Sprintf(errorMsg, err)) } return b, err } diff --git a/pkg/helper/helper.go b/pkg/helper/helper.go index 4fa88b2..9d0b330 100644 --- a/pkg/helper/helper.go +++ b/pkg/helper/helper.go @@ -22,13 +22,18 @@ package helper import ( - "0xacab.org/leap/bitmask-vpn/pkg/config" "encoding/json" "log" "net/http" "os/exec" ) +var ( + AppName = "DemoLibVPN" + BinaryName = "bitmask" + Version = "git" +) + type openvpnT struct { cmd *exec.Cmd } @@ -82,6 +87,7 @@ func (openvpn *openvpnT) run(args []string) error { return err } } + log.Println("OPENVPN PATH:", getOpenvpnPath()) // TODO: if it dies we should restart it openvpn.cmd = exec.Command(getOpenvpnPath(), args...) @@ -151,7 +157,7 @@ func firewallIsUpHandler(w http.ResponseWriter, r *http.Request) { } func versionHandler(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(config.ApplicationName + "/" + config.Version + "\n")) + w.Write([]byte(AppName + "/" + Version + "\n")) w.WriteHeader(http.StatusOK) } 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. -- cgit v1.2.3