diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 6f7869e..5038e21 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -50,22 +50,22 @@ main() { fi if [ -n "$MTU" ]; then - ARGS="--mtu $MTU" + ARGS="-mtu $MTU" fi if [ -n "$STATS" ]; then - ARGS="$ARGS --stats $STATS" + ARGS="$ARGS -stats $STATS" fi if [ -n "$TOKEN" ]; then - ARGS="$ARGS --token $TOKEN" + ARGS="$ARGS -token $TOKEN" fi exec tun2socks \ - --loglevel "$LOGLEVEL" \ - --fwmark "$FWMARK" \ - --device "$TUN" \ - --proxy "$PROXY" \ + -loglevel "$LOGLEVEL" \ + -fwmark "$FWMARK" \ + -device "$TUN" \ + -proxy "$PROXY" \ $ARGS } diff --git a/engine/engine.go b/engine/engine.go index d007968..3c21353 100755 --- a/engine/engine.go +++ b/engine/engine.go @@ -30,7 +30,7 @@ func Insert(k *Key) { } type Key struct { - MTU uint32 + MTU int Mark int Proxy string Stats string @@ -138,7 +138,7 @@ func (e *engine) setDevice() (err error) { return errors.New("empty device") } - e.device, err = parseDevice(e.Device, e.MTU) + e.device, err = parseDevice(e.Device, uint32(e.MTU)) return } diff --git a/go.mod b/go.mod index 50eb1be..0461556 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/gofrs/uuid v4.0.0+incompatible github.com/gorilla/websocket v1.4.2 github.com/sirupsen/logrus v1.7.0 - github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.5.1 go.uber.org/atomic v1.7.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect diff --git a/main.go b/main.go index eb5323a..844345e 100755 --- a/main.go +++ b/main.go @@ -1,28 +1,27 @@ package main import ( + "flag" "os" "os/signal" "syscall" "github.com/xjasonlyu/tun2socks/engine" "github.com/xjasonlyu/tun2socks/log" - - flag "github.com/spf13/pflag" ) var key = new(engine.Key) func init() { - flag.StringVarP(&key.Device, "device", "d", "", "use this device [driver://]name") - flag.IntVar(&key.Mark, "fwmark", 0, "set firewall MARK (Linux only)") - flag.StringVarP(&key.Interface, "interface", "i", "", "use network INTERFACE (Linux/MacOS only)") - flag.StringVarP(&key.LogLevel, "loglevel", "l", "info", "log level [debug|info|warn|error|silent]") - flag.Uint32VarP(&key.MTU, "mtu", "m", 0, "set device maximum transmission unit (MTU)") - flag.StringVarP(&key.Proxy, "proxy", "p", "", "use this proxy [protocol://]host[:port]") + flag.IntVar(&key.Mark, "fwmark", 0, "Set firewall MARK (Linux only)") + flag.IntVar(&key.MTU, "mtu", 0, "Set device maximum transmission unit (MTU)") + flag.BoolVar(&key.Version, "version", false, "Show version information and quit") + flag.StringVar(&key.Device, "device", "", "Use this device [driver://]name") + flag.StringVar(&key.Interface, "interface", "", "Use network INTERFACE (Linux/MacOS only)") + flag.StringVar(&key.LogLevel, "loglevel", "info", "Log level [debug|info|warn|error|silent]") + flag.StringVar(&key.Proxy, "proxy", "", "Use this proxy [protocol://]host[:port]") flag.StringVar(&key.Stats, "stats", "", "HTTP statistic server listen address") flag.StringVar(&key.Token, "token", "", "HTTP statistic server auth token") - flag.BoolVarP(&key.Version, "version", "v", false, "show version information and quit") flag.Parse() }