(ip net.IP, port uint16)
| 20 | } |
| 21 | |
| 22 | func findConflictingProcess(ip net.IP, port uint16) (conflictingProcess *processInfo.Process) { |
| 23 | // Evaluate which IPs to check. |
| 24 | var ipsToCheck []net.IP |
| 25 | if ip.Equal(net.IPv4zero) || ip.Equal(net.IPv6zero) { |
| 26 | ipsToCheck = commonResolverIPs |
| 27 | } else { |
| 28 | ipsToCheck = []net.IP{ip} |
| 29 | } |
| 30 | |
| 31 | // Find the conflicting process. |
| 32 | var err error |
| 33 | for _, resolverIP := range ipsToCheck { |
| 34 | conflictingProcess, err = getListeningProcess(resolverIP, port) |
| 35 | switch { |
| 36 | case err != nil: |
| 37 | // Log the error and let the worker try again. |
| 38 | log.Warningf("nameserver: failed to find conflicting service: %s", err) |
| 39 | case conflictingProcess != nil: |
| 40 | // Conflicting service found. |
| 41 | return conflictingProcess |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return nil |
| 46 | } |
| 47 | |
| 48 | func getListeningProcess(resolverIP net.IP, resolverPort uint16) (*processInfo.Process, error) { |
| 49 | pid, _, err := state.Lookup(&packet.Info{ |
no test coverage detected