rusty-kaspa icon indicating copy to clipboard operation
rusty-kaspa copied to clipboard

--rpclisten-borsh/json should support ip only like --grpclisten

Open supertypo opened this issue 1 year ago • 2 comments

kaspad supports specifying --rpclisten=0.0.0.0 for listening on all interfaces on default network port.

However, it doesn't support the same for --rpclisten-borsh and --rpclisten-json, even though the --help text specifies it as optional and is identical for the three:

      --rpclisten[=<IP[:PORT]>]
          Interface:port to listen for gRPC connections (default port: 16110, testnet: 16210).
      --rpclisten-borsh[=<IP[:PORT]>]
          Interface:port to listen for wRPC Borsh connections (default port: 17110, testnet: 17210).
      --rpclisten-json[=<IP[:PORT]>]
          Interface:port to listen for wRPC JSON connections (default port: 18110, testnet: 18210).

supertypo avatar Jan 22 '24 07:01 supertypo

For rpclisten-borsh the input is parsed into a WrpcNetAddress which can be any of default, public or an <ip>:<port>. The goal here is to also support just <ip>.

The string parsing logic in rpc/wrpc/server/src/addresses.rs is:

impl FromStr for WrpcNetAddress {
    type Err = AddrParseError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "default" => Ok(WrpcNetAddress::Default),
            "public" => Ok(WrpcNetAddress::Public),
            _ => {
                let addr: ContextualNetAddress = s.parse()?;
                Ok(Self::Custom(addr))
            }
        }
    }
}

The work is focused on the _ arm of this match.

NOTE: Make sure that if only the IP is passed that you use the default port for the given network. Mainnet, testnet, simnet, devnet may have different default ports.

coderofstuff avatar Mar 21 '24 04:03 coderofstuff

I have drafted a PR for this issue, but forgot to include a reference in the commit https://github.com/kaspanet/rusty-kaspa/pull/439

gvbgduh avatar Mar 23 '24 15:03 gvbgduh

This has been implemented in one of the merged PRs. Closing.

aspect avatar Aug 17 '24 07:08 aspect