Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions cmd/wireproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"github.com/landlock-lsm/go-landlock/landlock"
"log"
"net"
"net/http"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ 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 {
prefix, err := netip.ParsePrefix(str)
if err != nil {
return nil, err
}

addr := prefix.Addr()
ips = append(ips, addr)
}
Expand Down
3 changes: 2 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions routine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
Loading