()
| 29 | } |
| 30 | |
| 31 | func (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 | |
| 55 | func (r *DNS) Name() string { |
| 56 | return "dns" |
nothing calls this directly
no test coverage detected