{"record":{"id":"b37e57a76ba58bc4","repo":"rathole-org/rathole","slug":"proxy-url-should-have-port-field","errorCode":null,"errorMessage":"proxy url should have port field","messagePattern":"proxy url should have port field","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/helper.rs","lineNumber":119,"sourceCode":"        }\n    };\n    let s = UdpSocket::bind(bind_addr).await?;\n    s.connect(socket_addr).await?;\n    s.connect(socket_addr).await?;\n    Ok(s)\n}\n\n/// Create a TcpStream using a proxy\n/// e.g. socks5://user:pass@127.0.0.1:1080 http://127.0.0.1:8080\npub async fn tcp_connect_with_proxy(\n    addr: &AddrMaybeCached,\n    proxy: Option<&Url>,\n) -> Result<TcpStream> {\n    if let Some(url) = proxy {\n        let addr = &addr.addr;\n        let mut s = TcpStream::connect((\n            url.host_str().expect(\"proxy url should have host field\"),\n            url.port().expect(\"proxy url should have port field\"),\n        ))\n        .await?;\n\n        let auth = if !url.username().is_empty() || url.password().is_some() {\n            Some(async_socks5::Auth {\n                username: url.username().into(),\n                password: url.password().unwrap_or(\"\").into(),\n            })\n        } else {\n            None\n        };\n        match url.scheme() {\n            \"socks5\" => {\n                async_socks5::connect(&mut s, host_port_pair(addr)?, auth).await?;\n            }\n            \"http\" => {\n                let (host, port) = host_port_pair(addr)?;\n                match auth {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/rathole-org/rathole/blob/a292f7ed5402f840415fc6a53827da2f34337856/src/helper.rs#L101-L137","documentation":"A generic validation panic in tcp_connect_with_proxy: a proxy URL was supplied (socks5:// or http://) but the parsed Url has no port, so url.port() returns None and expect() aborts. The input at fault is the proxy option whose URL lacks an explicit port; the helper requires host and port to open the TCP connection to the proxy itself.","triggerScenarios":"Thrown at src/helper.rs:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Specify an explicit port in the proxy URL, e.g. http://127.0.0.1:8080 or socks5://user:pass@host:1080","Pre-validate the proxy URL in config parsing (reject proxies without a port before startup)","Use url.port_or_known_default() to fall back to scheme defaults instead of expect","Document the port requirement for the --proxy option"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a292f7ed5402f840415fc6a53827da2f34337856","analyzedAt":"2026-09-07T09:56:55.739Z","contentChangedAt":"2026-09-07T09:56:55.739Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}