Open grooviegermanikus opened 3 weeks ago
This repository is no longer in use. Please re-open this issue in the agave repo: https://github.com/anza-xyz/agave
Problem:
solana_net_utils::parse_host
validates host by:
pub fn parse_host(host: &str) -> Result<IpAddr, String> {
// First, check if the host syntax is valid. This check is needed because addresses
// such as `("localhost:1234", 0)` will resolve to IPs on some networks.
let parsed_url = Url::parse(&format!("http://{host}")).map_err(|e| e.to_string())?;
if parsed_url.port().is_some() {
return Err(format!("Expected port in URL: {host}"));
}
// Next, check to see if it resolves to an IP address
let ips: Vec<_> = (host, 0)
.to_socket_addrs()
.map_err(|err| err.to_string())?
.map(|socket_address| socket_address.ip())
.collect();
if ips.is_empty() {
Err(format!("Unable to resolve host: {host}"))
} else {
Ok(ips[0])
}
}
proposed solution I:
parsed_url
check completely proposed solution II:
Url::parse
with both "http://{host}"
and "http://[{host}]"
--rpc-bind-address
rejects IPv6 addresses:::1
,[::1]
,[::]