{"record":{"id":"fd94a5105de1632e","repo":"bettercap/bettercap","slug":"failed-to-parse-remote-addr-v","errorCode":null,"errorMessage":"failed to parse remote addr: %v","messagePattern":"failed to parse remote addr: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/ssh_proxy/ssh_origdst_darwin.go","lineNumber":28,"sourceCode":"\t\"strings\"\n)\n\n// getOriginalDst retrieves the original destination for a redirected connection\n// on macOS by querying the pf state table via `pfctl -s state`.\n//\n// When pf `rdr` redirects a connection, the state table contains entries like:\n//   ALL tcp 192.168.1.50:54321 -> 192.168.1.100:22 -> 192.168.1.1:2222\n//\n// We look for the entry matching our connection's local+remote and extract\n// the middle address (the original destination).\nfunc getOriginalDst(conn net.Conn) (string, error) {\n\tlocalAddr := conn.LocalAddr().String()\n\tremoteAddr := conn.RemoteAddr().String()\n\n\t// Parse what we know about this connection\n\tremoteHost, _, err := net.SplitHostPort(remoteAddr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse remote addr: %v\", err)\n\t}\n\t_, localPort, err := net.SplitHostPort(localAddr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse local addr: %v\", err)\n\t}\n\n\t// Query pf state table\n\tout, err := exec.Command(\"pfctl\", \"-s\", \"state\").CombinedOutput()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"pfctl -s state failed: %v (output: %s)\", err, string(out))\n\t}\n\n\t// Parse state table looking for our connection\n\t// Format: ALL tcp <src> -> <original_dst> -> <rdr_dst>  ESTABLISHED:ESTABLISHED\n\tscanner := bufio.NewScanner(strings.NewReader(string(out)))\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/ssh_proxy/ssh_origdst_darwin.go#L10-L46","documentation":"Raised in getOriginalDst (macOS) when net.SplitHostPort cannot split the connection's remote address into host and port. This is a defensive guard on an address the kernel handed us; it only fires on a malformed remote address string, so in practice it indicates a corrupted or non-network connection rather than a configuration problem.","triggerScenarios":"Thrown at modules/ssh_proxy/ssh_origdst_darwin.go:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the proxied connection's remote address for anomalies","Set ssh.address explicitly so original-destination detection is skipped"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}