{"record":{"id":"2a000b667c5a0874","repo":"XTLS/Xray-core","slug":"failed-to-determine-if-address-is-local-2a000b","errorCode":null,"errorMessage":"failed to determine if address is local: ","messagePattern":"failed to determine if address is local: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/net/find_process_linux.go","lineNumber":20,"sourceCode":"\npackage net\n\nimport (\n\t\"bufio\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/xtls/xray-core/common/errors\"\n)\n\nfunc FindProcess(network, srcIP string, srcPort uint16, destIP string, destPort uint16) (PID int, Name string, AbsolutePath string, err error) {\n\tisLocal, err := IsLocal(net.ParseIP(srcIP))\n\tif err != nil {\n\t\treturn 0, \"\", \"\", errors.New(\"failed to determine if address is local: \", err)\n\t}\n\tif !isLocal {\n\t\treturn 0, \"\", \"\", ErrNotLocal\n\t}\n\tif network != \"tcp\" && network != \"udp\" {\n\t\tpanic(\"Unsupported network type for process lookup.\")\n\t}\n\n\tvar procFile string\n\n\tswitch network {\n\tcase \"tcp\":\n\t\tif net.ParseIP(srcIP).To4() != nil {\n\t\t\tprocFile = \"/proc/net/tcp\"\n\t\t} else {\n\t\t\tprocFile = \"/proc/net/tcp6\"\n\t\t}\n\tcase \"udp\":","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/net/find_process_linux.go#L2-L38","documentation":"The Linux FindProcess first checks whether srcIP belongs to a local interface via IsLocal; that check enumerates network interfaces and failed. The wrapped error after the colon is from net.Interfaces() (e.g. error reading /sys/class/net or netlink). Without knowing the address is local, the /proc-based lookup cannot proceed.","triggerScenarios":"Calling FindProcess on Linux when interface enumeration fails: /sys/class/net unreadable inside a broken container, netlink socket failure in a restricted namespace, or srcIP being nil because net.ParseIP(srcIP) was given a malformed string.","commonSituations":"Containers with read-only or masked /proc//sys, network namespaces created without interfaces, or callers passing unparsable srcIP so ParseIP returns nil and IsLocal errors on nil input.","solutions":["Validate srcIP parses (net.ParseIP(srcIP) != nil) before calling FindProcess","In containers, ensure /sys/class/net and /proc are properly mounted (not masked)","Check the wrapped error: if it mentions a specific interface, that interface is in a bad state (dangling link)","Fall back to non-process routing when the check fails"],"exampleFix":"// before\npid, name, path, err := net.FindProcess(network, srcIP, srcPort, dstIP, dstPort)\n\n// after\nif ip := net.ParseIP(srcIP); ip == nil {\n    return fmt.Errorf(\"invalid srcIP %q\", srcIP)\n}\npid, name, path, err := net.FindProcess(network, srcIP, srcPort, dstIP, dstPort)","handlingStrategy":"try-catch","validationCode":"if ip := net.ParseIP(srcIP); ip == nil {\n    return fmt.Errorf(\"invalid srcIP %q\", srcIP) // IsLocal receives nil otherwise\n}\nif _, err := net.Interfaces(); err != nil {\n    // interface enumeration broken; lookup will fail\n}","typeGuard":null,"tryCatchPattern":"if _, _, _, err := net.FindProcess(netw, srcIP, srcPort, dstIP, dstPort); err != nil {\n    if strings.Contains(err.Error(), \"failed to determine if address is local\") {\n        // environment problem (interfaces unreadable), not a routing miss\n    }\n}","preventionTips":["Validate the source IP before every lookup","In containers, ensure /proc and /sys/class/net are mounted normally","Cache the IsLocal failure — it will not self-heal within a process lifetime"],"tags":["linux","process-lookup","network-interfaces","containers"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}