MCPcopy
hub / github.com/safing/portmaster / findConflictingProcess

Function findConflictingProcess

service/nameserver/conflict.go:22–46  ·  view source on GitHub ↗
(ip net.IP, port uint16)

Source from the content-addressed store, hash-verified

20}
21
22func 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
48func getListeningProcess(resolverIP net.IP, resolverPort uint16) (*processInfo.Process, error) {
49 pid, _, err := state.Lookup(&packet.Info{

Callers 1

handleListenErrorFunction · 0.85

Calls 3

WarningfFunction · 0.92
getListeningProcessFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected