From fa9077969c917c5d1f753d5b1e831ea29451cdf3 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Mon, 10 Dec 2018 11:00:52 +0800 Subject: [PATCH] Fix: dns crash & remove unused debug log --- config/config.go | 7 +++---- dns/client.go | 2 -- tunnel/tunnel.go | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index f2ac2dbb..b9de6ed9 100644 --- a/config/config.go +++ b/config/config.go @@ -68,7 +68,7 @@ type rawConfig struct { ExternalController string `yaml:"external-controller"` Secret string `yaml:"secret"` - DNS *rawDNS `yaml:"dns"` + DNS rawDNS `yaml:"dns"` Proxy []map[string]interface{} `yaml:"Proxy"` ProxyGroup []map[string]interface{} `yaml:"Proxy Group"` Rule []string `yaml:"Rule"` @@ -95,7 +95,7 @@ func readConfig(path string) (*rawConfig, error) { Rule: []string{}, Proxy: []map[string]interface{}{}, ProxyGroup: []map[string]interface{}{}, - DNS: &rawDNS{ + DNS: rawDNS{ Enable: false, }, } @@ -353,7 +353,6 @@ func hostWithDefaultPort(host string, defPort string) (string, error) { func parseNameServer(servers []string) ([]dns.NameServer, error) { nameservers := []dns.NameServer{} - log.Debugln("%#v", servers) for idx, server := range servers { // parse without scheme .e.g 8.8.8.8:53 @@ -387,7 +386,7 @@ func parseNameServer(servers []string) ([]dns.NameServer, error) { return nameservers, nil } -func parseDNS(cfg *rawDNS) (*DNS, error) { +func parseDNS(cfg rawDNS) (*DNS, error) { if cfg.Enable && len(cfg.NameServer) == 0 { return nil, fmt.Errorf("If DNS configuration is turned on, NameServer cannot be empty") } diff --git a/dns/client.go b/dns/client.go index dad0ff2f..f8c711b1 100644 --- a/dns/client.go +++ b/dns/client.go @@ -244,8 +244,6 @@ func New(config Config) *Resolver { mmdb, _ = geoip2.Open(C.Path.MMDB()) }) - println(config.EnhancedMode) - r := &Resolver{ main: transform(config.Main), ipv6: config.IPv6, diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 930bd070..0b4e4ff0 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -120,8 +120,6 @@ func (t *Tunnel) handleConn(localConn C.ServerAdapter) { log.Debugln("[DNS] %s --> %s", metadata.Host, ip.String()) metadata.IP = &ip } - } else { - log.Debugln("[DNS] unknown%#v", metadata) } var proxy C.Proxy