diff --git a/dns/dns.go b/dns/dns.go index d5b27bc..f7ced5d 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -21,8 +21,8 @@ var DefaultDialer = net.Dialer{ } type dnsstat struct { - A string - E bool + a string + e bool } type DNSList struct { @@ -32,14 +32,14 @@ type DNSList struct { } type DNSConfig struct { - Servers map[string][]string // Servers map[dot.com]ip:ports - Fallbacks map[string][]string // Fallbacks map[domain]ips + Servers map[string][]string `yaml:"Servers"` // Servers map[dot.com]ip:ports + Fallbacks map[string][]string `yaml:"Fallbacks"` // Fallbacks map[domain]ips } // hasrecord no lock, use under lock func hasrecord(lst []*dnsstat, a string) bool { for _, addr := range lst { - if addr.A == a { + if addr.a == a { return true } } @@ -117,12 +117,12 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra var conn net.Conn for host, addrs := range ds.m { for _, addr := range addrs { - if !addr.E { + if !addr.e { continue } - conn, err = dialer.DialContext(ctx, "tcp", addr.A) + conn, err = dialer.DialContext(ctx, "tcp", addr.a) if err != nil { - addr.E = false // no need to acquire write lock + addr.e = false // no need to acquire write lock continue } tlsConn = tls.Client(conn, &tls.Config{ServerName: host}) @@ -131,7 +131,7 @@ func (ds *DNSList) DialContext(ctx context.Context, dialer *net.Dialer, firstFra return } _ = tlsConn.Close() - addr.E = false // no need to acquire write lock + addr.e = false // no need to acquire write lock } } return diff --git a/dns/dns_test.go b/dns/dns_test.go index b17280c..11ba18c 100644 --- a/dns/dns_test.go +++ b/dns/dns_test.go @@ -79,11 +79,11 @@ func (ds *DNSList) test() { defer ds.RUnlock() for host, addrs := range ds.m { for _, addr := range addrs { - if !addr.E { + if !addr.e { continue } - fmt.Println("dial:", host, addr.A) - conn, err := net.Dial("tcp", addr.A) + fmt.Println("dial:", host, addr.a) + conn, err := net.Dial("tcp", addr.a) if err != nil { continue } @@ -91,10 +91,10 @@ func (ds *DNSList) test() { err = terasu.Use(tlsConn).Handshake(4) _ = tlsConn.Close() if err == nil { - fmt.Println("succ:", host, addr.A) + fmt.Println("succ:", host, addr.a) continue } - fmt.Println("fail:", host, addr.A) + fmt.Println("fail:", host, addr.a) } } }