From 883d208fa040e6398ea4ef454cb13ffe9580c13e Mon Sep 17 00:00:00 2001 From: Pea Nut <peanut2@systemli.org> Date: Thu, 25 Apr 2024 11:23:03 +0200 Subject: [PATCH] Remove unused code --- pkg/backend/actions.go | 4 --- pkg/bitmask/autostart/autostart.go | 4 --- pkg/helper/ports.go | 49 ------------------------------ 3 files changed, 57 deletions(-) delete mode 100644 pkg/helper/ports.go diff --git a/pkg/backend/actions.go b/pkg/backend/actions.go index 08b2f980..091094c1 100644 --- a/pkg/backend/actions.go +++ b/pkg/backend/actions.go @@ -23,7 +23,3 @@ func stopVPN() { Msg("Could not stop VPN") } } - -func getGateway() string { - return ctx.bm.GetCurrentGateway() -} diff --git a/pkg/bitmask/autostart/autostart.go b/pkg/bitmask/autostart/autostart.go index c84ca0f4..cf48fe24 100644 --- a/pkg/bitmask/autostart/autostart.go +++ b/pkg/bitmask/autostart/autostart.go @@ -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 diff --git a/pkg/helper/ports.go b/pkg/helper/ports.go deleted file mode 100644 index 58e5856c..00000000 --- a/pkg/helper/ports.go +++ /dev/null @@ -1,49 +0,0 @@ -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 -} -- GitLab