blockworks-foundation / lite-rpc

This is a solana lite rpc which optimizes sending transactions and confirming transactions strategies.
GNU Affero General Public License v3.0
161 stars 43 forks source link

(validator) Allow RPC endpoint to bind IPv6 address #396

Open grooviegermanikus opened 3 weeks ago

grooviegermanikus commented 3 weeks ago

--rpc-bind-address rejects IPv6 addresses: ::1, [::1], [::]

Custom { kind: Uncategorized, error: "failed to lookup address information: nodename nor servname provided, or not known" }

EmptyHost

github-actions[bot] commented 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

grooviegermanikus commented 3 weeks ago

Problem: solana_net_utils::parse_host validates host by:

  1. parse it using Url crate
  2. run OS resolver
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])
    }
}
grooviegermanikus commented 3 weeks ago

proposed solution I:

proposed solution II: