Skip to content
Snippets Groups Projects
Commit 883d208f authored by Pea Nut's avatar Pea Nut Committed by jkito
Browse files

Remove unused code

parent a46cb963
No related branches found
No related tags found
1 merge request!186Improve error handling
......@@ -23,7 +23,3 @@ func stopVPN() {
Msg("Could not stop VPN")
}
}
func getGateway() string {
return ctx.bm.GetCurrentGateway()
}
......@@ -29,10 +29,6 @@ import (
pmautostart "github.com/ProtonMail/go-autostart"
)
const (
errorMsg = `An error has ocurred initializing the VPN: %v`
)
// Autostart holds the functions to enable and disable the application autostart
type Autostart interface {
Disable() error
......
package helper
import (
"io/ioutil"
"net"
"os"
"path"
"strconv"
)
func getFirstAvailablePortFrom(port int) int {
for {
if isPortAvailable(port) {
return port
}
if port > 65535 {
return 0
}
port += 1
}
}
func isPortAvailable(port int) bool {
conn, err := net.Dial("tcp", "127.0.0.1:"+strconv.Itoa(port))
if err != nil {
return true
} else {
defer conn.Close()
return false
}
}
func writePortToFile(port int) error {
exeDir, err := getExecutableDir()
if err != nil {
return err
}
portFile := path.Join(exeDir, "port")
return ioutil.WriteFile(portFile, []byte(strconv.Itoa(port)+"\n"), 0644)
}
func getExecutableDir() (string, error) {
ex, err := os.Executable()
if err != nil {
return "", err
}
return path.Dir(ex), nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment