rust-internet2
rust-internet2 copied to clipboard
InetAddr: Use onion addresses instead of public keys
I'm opening this PR to discuss the format of the Tor address variants. This change reflects how I would reason about them. I'm curious what the original reasoning behind the design of the type was. If there is another / better approach to this, I'm very open to implement that instead.
Define new Tor enum inner types for the InetAddr PartialSocketAddr, and InetSocketAddr types. Replace the usage of the TorPublicKeyV3 with OnionAddressV3. While the two types are interchangeable, OnionAddressV3 is the human-readable format. For encoding purposes, OnionAddressV3 is converted to TorPublicKeyV3 in order to save some space.
Additionally, adds port numbers to the PartialSocketAddr and InetSocketAddr tor variants. This allows users to specify a specific port on which an onion address is listening.
I have recently discovered that the whole design I have in iner2_addr does not allow to efficiently work with Tor or SOCKS5 proxies. That's why I have already started a redesign of the address system API in https://github.com/Internet2-WG/rust-cyphernet/tree/master/src/addr
Please have a look there and let me know what do you think.
Example usage can be found here: https://github.com/Internet2-WG/rust-netservices/blob/master/nsh/src/main.rs
Specifically, this piece uses the address system: https://github.com/Internet2-WG/rust-netservices/blob/6b40268ef7ae5780f958cdbd7a0a45fa4d309e2b/nsh/src/main.rs#L44-L56