Commit 2a65e3cd authored by wei.xuan's avatar wei.xuan

release:v0.0.1

parent 41ea9713
...@@ -22,7 +22,7 @@ var ( ...@@ -22,7 +22,7 @@ var (
natServer string natServer string
account string account string
dnsServer string dnsServer string
disableDns bool disableDNS bool
) )
var ( var (
...@@ -31,15 +31,13 @@ var ( ...@@ -31,15 +31,13 @@ var (
) )
func init() { func init() {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
flag.IntVar(&logLevel, "log", 1, "log logLevel") flag.IntVar(&logLevel, "log", 1, "log logLevel")
flag.BoolVar(&pprof, "pprof", false, "enable pprof") flag.BoolVar(&pprof, "pprof", false, "enable pprof")
flag.StringVar(&natServer, "natServer", common.DefNatAddr, "natServer") flag.StringVar(&natServer, "natServer", common.DefNatAddr, "natServer")
flag.StringVar(&account, "account", "unknown", "account") flag.StringVar(&account, "account", "unknown", "account")
flag.StringVar(&dnsServer, "dnsServer", common.DNSServer, "custom dns server") flag.StringVar(&dnsServer, "dnsServer", common.DNSServer, "custom dns server")
flag.BoolVar(&disableDns, "disableDns", false, "disable default dns server") flag.BoolVar(&disableDNS, "disableDns", false, "disable default dns server")
flag.Parse() flag.Parse()
} }
...@@ -54,13 +52,14 @@ func initPprof() { ...@@ -54,13 +52,14 @@ func initPprof() {
}() }()
// for android // for android
if !disableDns { if !disableDNS {
net.DefaultResolver = &net.Resolver{ net.DefaultResolver = &net.Resolver{
PreferGo: true, PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) { Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
return net.Dial("udp", dnsServer) return net.Dial("udp", dnsServer)
}, },
} }
logger.Info().Msgf("use custom dns server %s", dnsServer)
} }
} }
......
...@@ -48,7 +48,6 @@ func (client *Client) StartUp() { ...@@ -48,7 +48,6 @@ func (client *Client) StartUp() {
} }
client.connect() client.connect()
client.register() client.register()
client.Debug()
client.handleNatEvent() client.handleNatEvent()
} }
...@@ -136,11 +135,3 @@ func (client *Client) connect() { ...@@ -136,11 +135,3 @@ func (client *Client) connect() {
logger.Info().Msgf("connect to nathost %s success ...", hostPort) logger.Info().Msgf("connect to nathost %s success ...", hostPort)
client.natTunnel.Store(conn) client.natTunnel.Store(conn)
} }
func (client *Client) Debug() {
//go func() {
// for range time.Tick(time.Second) {
// logger.Warn().Msgf("removeConnection target connStore %+v", client.connStore)
// }
//}()
}
...@@ -14,7 +14,7 @@ var ( ...@@ -14,7 +14,7 @@ var (
func init() { func init() {
zerolog.SetGlobalLevel(zerolog.InfoLevel) zerolog.SetGlobalLevel(zerolog.InfoLevel)
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339, NoColor: true} output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339, NoColor: true}
logger = zerolog.New(output).With().Caller().Timestamp().Logger() logger = zerolog.New(output).With().Timestamp().Logger()
} }
var ( var (
...@@ -24,7 +24,6 @@ var ( ...@@ -24,7 +24,6 @@ var (
Debug = logger.Debug Debug = logger.Debug
) )
func SetLogLevel(level int) { func SetLogLevel(level int) {
zerolog.SetGlobalLevel(zerolog.Level(level)) zerolog.SetGlobalLevel(zerolog.Level(level))
} }
\ No newline at end of file
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment