-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from evidolob/replace-dns
Replace dns "resolver" calls with "dns.Exchange" func
- Loading branch information
Showing
30 changed files
with
5,029 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//go:build !windows | ||
|
||
package dns | ||
|
||
import ( | ||
"github.com/miekg/dns" | ||
) | ||
|
||
func getDNSHostAndPort() (string, string, error) { | ||
conf, err := dns.ClientConfigFromFile("/etc/resolv.conf") | ||
if err != nil { | ||
return "", "", err | ||
} | ||
// TODO: use all configured nameservers, instead just first one | ||
nameserver := conf.Servers[0] | ||
|
||
return nameserver, conf.Port, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build windows | ||
|
||
package dns | ||
|
||
import ( | ||
"net/netip" | ||
"strconv" | ||
|
||
qdmDns "github.com/qdm12/dns/v2/pkg/nameserver" | ||
) | ||
|
||
func getDNSHostAndPort() (string, string, error) { | ||
nameservers := qdmDns.GetDNSServers() | ||
|
||
var nameserver netip.AddrPort | ||
for _, n := range nameservers { | ||
// return first non ipv6 nameserver | ||
if n.Addr().Is4() { | ||
nameserver = n | ||
break | ||
} | ||
} | ||
|
||
return nameserver.Addr().String(), strconv.Itoa(int(nameserver.Port())), nil | ||
|
||
} |
Oops, something went wrong.