Closed cn-kali-team closed 1 month ago
An IP address is a domain.
But according to the document description, it should be expected to be IPv4.
https://docs.rs/url/latest/url/struct.Url.html#method.domain
When the scheme of a URL is not special, the host will be an opaque host https://url.spec.whatwg.org/#concept-opaque-host-parser
That applies for IP addresses as well - while for special schemes, the host needs to be valid, you can define your own scheme where the host looks like an IPv4 address, but isn't.
let _ = dbg!(url::Url::parse("lotsofdots://user:pass@1.2.3.4.5.6.7.8.9.0:1080")); // succeeds
let _ = dbg!(url::Url::parse("http://user:pass@1.2.3.4.5.6.7.8.9.0:1080")); // fails
So even though the host of a socks5 URL is supposed to be a valid IP address, the URL parser doesn't know anything about this scheme - so it's parsed as an opaque host - if you want to turn it into a domain you can process it yourself by parsing it with domain.parse::<Ipv4Addr>()
Describe the bug A clear and concise description of what the bug is. Include code snippets if possible.
url::Url::parse("socks5://user:pass@127.0.0.1:1080")
Url { scheme: "socks5", cannot_be_a_base: false, username: "user", password: Some("pass"), host: Some(Domain("127.0.0.1")), port: Some(1080), path: "/", query: None, fragment: None }