Skip to content

Commit

Permalink
fix redundant WindowsDNS (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestL18 authored Aug 20, 2024
1 parent ba605b6 commit 58efe08
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dns/system_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func dnsReadConfig() (servers []string, err error) {
if err != nil {
return
}

uniqueIPs := make(map[string]struct{})

for _, aa := range aas {
for dns := aa.FirstDnsServerAddress; dns != nil; dns = dns.Next {
sa, err := dns.Address.Sockaddr.Sockaddr()
Expand All @@ -40,9 +43,16 @@ func dnsReadConfig() (servers []string, err error) {
// Unexpected type.
continue
}
servers = append(servers, ip.String())

uniqueIPs[ip.String()] = struct{}{}
}
}

servers = make([]string, 0, len(uniqueIPs))
for ip := range uniqueIPs {
servers = append(servers, ip)
}

return
}

Expand Down

0 comments on commit 58efe08

Please sign in to comment.