diff --git a/cmd/wireproxy/main.go b/cmd/wireproxy/main.go index 713943a2..1a383a72 100644 --- a/cmd/wireproxy/main.go +++ b/cmd/wireproxy/main.go @@ -3,7 +3,6 @@ package main import ( "context" "fmt" - "github.com/landlock-lsm/go-landlock/landlock" "log" "net" "net/http" @@ -13,6 +12,8 @@ import ( "strconv" "syscall" + "github.com/landlock-lsm/go-landlock/landlock" + "github.com/akamensky/argparse" "github.com/pufferffish/wireproxy" "golang.zx2c4.com/wireguard/device" @@ -23,9 +24,9 @@ import ( const daemonProcess = "daemon-process" // default paths for wireproxy config file -var default_config_paths = []string { - "/etc/wireproxy/wireproxy.conf", - os.Getenv("HOME")+"/.config/wireproxy.conf", +var default_config_paths = []string{ + "/etc/wireproxy/wireproxy.conf", + os.Getenv("HOME") + "/.config/wireproxy.conf", } var version = "1.0.8-dev" @@ -59,12 +60,12 @@ func executablePath() string { // check if default config file paths exist func configFilePath() (string, bool) { - for _, path := range default_config_paths { - if _, err := os.Stat(path); err == nil { - return path, true - } - } - return "", false + for _, path := range default_config_paths { + if _, err := os.Stat(path); err == nil { + return path, true + } + } + return "", false } func lock(stage string) { @@ -193,12 +194,12 @@ func main() { } if *config == "" { - if path, config_exist := configFilePath(); config_exist { - *config = path - } else { - fmt.Println("configuration path is required") - return - } + if path, config_exist := configFilePath(); config_exist { + *config = path + } else { + fmt.Println("configuration path is required") + return + } } if !*daemon { diff --git a/config.go b/config.go index 1f6e4e4a..6322793a 100644 --- a/config.go +++ b/config.go @@ -175,7 +175,7 @@ func parseCIDRNetIP(section *ini.Section, keyName string) ([]netip.Addr, error) if len(str) == 0 { continue } - + if addr, err := netip.ParseAddr(str); err == nil { ips = append(ips, addr) } else { @@ -183,7 +183,7 @@ func parseCIDRNetIP(section *ini.Section, keyName string) ([]netip.Addr, error) if err != nil { return nil, err } - + addr := prefix.Addr() ips = append(ips, addr) } diff --git a/config_test.go b/config_test.go index 948fbf83..0e0cdc82 100644 --- a/config_test.go +++ b/config_test.go @@ -1,8 +1,9 @@ package wireproxy import ( - "github.com/go-ini/ini" "testing" + + "github.com/go-ini/ini" ) func loadIniConfig(config string) (*ini.File, error) { diff --git a/routine.go b/routine.go index edfc793b..855758a6 100644 --- a/routine.go +++ b/routine.go @@ -8,10 +8,6 @@ import ( "encoding/binary" "encoding/json" "errors" - "golang.org/x/net/icmp" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" - "golang.zx2c4.com/wireguard/device" "io" "log" "math/rand" @@ -24,6 +20,11 @@ import ( "sync" "time" + "golang.org/x/net/icmp" + "golang.org/x/net/ipv4" + "golang.org/x/net/ipv6" + "golang.zx2c4.com/wireguard/device" + "github.com/things-go/go-socks5" "github.com/things-go/go-socks5/bufferpool"