Fix: replace pflag with flag

pflag was deprecated due to poor maintenance
This commit is contained in:
xjasonlyu
2021-02-11 13:06:12 +08:00
parent c96c5946c8
commit 7e55b71b30
4 changed files with 17 additions and 19 deletions

17
main.go
View File

@@ -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()
}