{"record":{"id":"6ab9dcade34fd7ea","repo":"XTLS/Xray-core","slug":"invalid-destination-ip-address","errorCode":null,"errorMessage":"invalid destination IP address: ","messagePattern":"invalid destination IP address: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/net/find_process_darwin.go","lineNumber":75,"sourceCode":"\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\tsrcAddr, err := netip.ParseAddr(srcIP)\n\tif err != nil {\n\t\treturn 0, \"\", \"\", errors.New(\"invalid source IP address: \", srcIP)\n\t}\n\tsrcAddr = srcAddr.Unmap()\n\n\tvar dstAddr netip.Addr\n\thasDstAddr := false\n\tif destIP != \"\" && destPort != 0 {\n\t\tdstAddr, err = netip.ParseAddr(destIP)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", \"\", errors.New(\"invalid destination IP address: \", destIP)\n\t\t}\n\t\tdstAddr = dstAddr.Unmap()\n\t\thasDstAddr = true\n\t}\n\n\tprocesses, err := unix.SysctlKinfoProcSlice(\"kern.proc.all\")\n\tif err != nil {\n\t\treturn 0, \"\", \"\", errors.New(\"failed to list processes\").Base(err)\n\t}\n\n\tvar bestPID int32\n\tbestLevel := darwinSocketNoMatch\n\tambiguousBest := false\n\n\tfor _, process := range processes {\n\t\tpid := process.Proc.P_pid\n\t\tif pid <= 0 {\n\t\t\tcontinue","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/net/find_process_darwin.go#L57-L93","documentation":"On macOS, FindProcess optionally parses destIP (when both destIP is non-empty and destPort is non-zero) with netip.ParseAddr, and it failed. Like error 178, the destination must be a bare IP literal — hostnames, empty ports with non-empty IPs are handled, but malformed IP text aborts the lookup.","triggerScenarios":"destIP is a hostname (e.g. 'example.com'), contains brackets/zone, or is otherwise unparsable while destPort != 0.","commonSituations":"Callers resolving the destination to a domain name instead of an IP before invoking process lookup, or tests passing placeholder destination strings.","solutions":["Resolve hostnames to IPs before calling FindProcess, or omit both destIP and destPort (pass \"\" and 0) to skip exact-match narrowing.","Validate with net.ParseIP(destIP) != nil at the call site and degrade gracefully (fall back to lookup without destination filter).","Ensure IPv6 addresses are passed without surrounding brackets.","Log the offending destIP value to catch formatting bugs quickly."],"exampleFix":"// before\npid, name, path, err := net.FindProcess(\"tcp\", srcIP, srcPort, \"example.com\", 443)\n// after: resolve first, or omit destination narrowing\nvar dstIPStr string\nif ip := net.ParseIP(dstHost); ip != nil {\n    dstIPStr = ip.String()\n}\npid, name, path, err := net.FindProcess(\"tcp\", srcIP, srcPort, dstIPStr, dstPort)","handlingStrategy":"validation","validationCode":"if destIP != \"\" && destPort != 0 {\n    if _, err := netip.ParseAddr(destIP); err != nil {\n        return errors.New(\"destIP is not an IP literal; pass empty dest to skip narrowing\")\n    }\n}","typeGuard":"func isParseableDest(ip string, port uint16) bool {\n    if ip == \"\" || port == 0 { return true } // optional: absent is fine\n    _, err := netip.ParseAddr(ip)\n    return err == nil\n}","tryCatchPattern":"pid, name, path, err := net.FindProcess(network, srcIP, srcPort, destIP, destPort)\nif err != nil && strings.Contains(err.Error(), \"invalid destination IP address\") {\n    // retry once without destination narrowing (destIP=\"\", destPort=0)\n    pid, name, path, err = net.FindProcess(network, srcIP, srcPort, \"\", 0)\n}","preventionTips":["Resolve domains to IPs before calling FindProcess, or omit the destination pair entirely.","Strip brackets and zones from IPv6 literals.","Remember both destIP and destPort must be valid together; an IP with port 0 skips parsing."],"tags":["darwin","macos","validation","process-lookup","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}