func (conn *SSHRawConnection) RemoteResolve(name string) ([]net.IP, error) { if raw, err := conn.GetClientConn(false); nil == err { dial := func(net, addr string, timeout time.Duration) (net.Conn, error) { return raw.Dial(net, addr) } options := &godns.LookupOptions{ DNSServers: godns.GoogleDNSServers, Net: "tcp", CacheTTL: godns.DNS_CACHE_TTL_SELF, DialTimeout: dial, } return godns.LookupIP(name, options) } else { return nil, err } return nil, nil }
func trustedDNSLookup(host string) (string, bool) { net := "tcp" //for DNSEncrypt if len(trustedDNS) > 0 && trustedDNS[0] == "127.0.0.1" { net = "udp" } options := &godns.LookupOptions{ DNSServers: trustedDNS, Net: net, CacheTTL: godns.DNS_CACHE_TTL_SELF, OnlyIPv4: true} if ips, err := godns.LookupIP(host, options); nil == err { for _, ip := range ips { if nil != ip.To4() { return ip.String(), true } } } return host, false }