MCPcopy
hub / github.com/nextdns/nextdns / init

Method init

discovery/dns.go:31–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31func (r *DNS) init() {
32 defer func() {
33 // Probe the upstream in order to detect if it's a buggy dnsmasq version
34 // returning SERVFAILs when RD flag is not provided. For those, we send
35 // the RD flag at the risk of creating DNS loops.
36 r.rd = probeBuggyDNSMasq(r.Upstream)
37 }()
38 r.cache, _ = lru.New[string, cacheEntry](10000)
39 if r.Upstream != "" {
40 return
41 }
42 var servers []string
43 for _, ip := range host.DNS() {
44 // Only consider sending local IP PTR to private DNS.
45 if isPrivateIP(ip) {
46 servers = append(servers, ip)
47 }
48 }
49 if len(servers) == 0 {
50 return
51 }
52 r.Upstream = servers[0]
53}
54
55func (r *DNS) Name() string {
56 return "dns"

Callers

nothing calls this directly

Calls 3

DNSFunction · 0.92
probeBuggyDNSMasqFunction · 0.85
isPrivateIPFunction · 0.85

Tested by

no test coverage detected