...
Source file
src/net/dnsconfig_windows.go
Documentation: net
1
2
3
4
5 package net
6
7 import (
8 "internal/syscall/windows"
9 "syscall"
10 "time"
11 )
12
13 func dnsReadConfig(ignoredFilename string) (conf *dnsConfig) {
14 conf = &dnsConfig{
15 ndots: 1,
16 timeout: 5 * time.Second,
17 attempts: 2,
18 }
19 defer func() {
20 if len(conf.servers) == 0 {
21 conf.servers = defaultNS
22 }
23 }()
24 aas, err := adapterAddresses()
25 if err != nil {
26 return
27 }
28
29
30
31
32 for _, aa := range aas {
33 for dns := aa.FirstDnsServerAddress; dns != nil; dns = dns.Next {
34
35 if aa.OperStatus != windows.IfOperStatusUp {
36 continue
37 }
38 sa, err := dns.Address.Sockaddr.Sockaddr()
39 if err != nil {
40 continue
41 }
42 var ip IP
43 switch sa := sa.(type) {
44 case *syscall.SockaddrInet4:
45 ip = IPv4(sa.Addr[0], sa.Addr[1], sa.Addr[2], sa.Addr[3])
46 case *syscall.SockaddrInet6:
47 ip = make(IP, IPv6len)
48 copy(ip, sa.Addr[:])
49 if ip[0] == 0xfe && ip[1] == 0xc0 {
50
51
52
53 continue
54 }
55 default:
56
57 continue
58 }
59 conf.servers = append(conf.servers, JoinHostPort(ip.String(), "53"))
60 }
61 }
62 return conf
63 }
64
View as plain text