-
Notifications
You must be signed in to change notification settings - Fork 265
Feature Noise XKpsk3 IP from bond #4451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8c60d85
change mix_host in Node to a vec
simonwicky 084b03b
change key retrieval to use bond info
simonwicky 3cf3151
update cargo lock
simonwicky cd4718d
comment change according to review
simonwicky 6d299b0
apply jstuczyn suggestion
simonwicky 2e14136
change to psk structure and port checking to allow same ip
simonwicky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,9 +46,9 @@ pub enum GatewayConversionError { | |
| pub struct Node { | ||
| pub owner: String, | ||
| pub host: NetworkAddress, | ||
| // we're keeping this as separate resolved field since we do not want to be resolving the potential | ||
| // hostname every time we want to construct a path via this node | ||
| pub mix_host: SocketAddr, | ||
| // we're keeping all resolved IPs as a separate field since we do not want to be resolving the potential | ||
| // hostname every time we want to construct a path via this node. When we need one, we default to the first one | ||
| pub mix_hosts: Vec<SocketAddr>, | ||
|
|
||
| // #[serde(alias = "clients_port")] | ||
| pub clients_ws_port: u16, | ||
|
|
@@ -66,7 +66,7 @@ impl std::fmt::Debug for Node { | |
| f.debug_struct("gateway::Node") | ||
| .field("host", &self.host) | ||
| .field("owner", &self.owner) | ||
| .field("mix_host", &self.mix_host) | ||
| .field("mix_hosts", &self.mix_hosts) | ||
| .field("clients_ws_port", &self.clients_ws_port) | ||
| .field("clients_wss_port", &self.clients_wss_port) | ||
| .field("identity_key", &self.identity_key.to_base58_string()) | ||
|
|
@@ -88,13 +88,12 @@ impl Node { | |
| pub fn extract_mix_host( | ||
| host: &NetworkAddress, | ||
| mix_port: u16, | ||
| ) -> Result<SocketAddr, GatewayConversionError> { | ||
| Ok(host.to_socket_addrs(mix_port).map_err(|err| { | ||
| GatewayConversionError::InvalidAddress { | ||
| ) -> Result<Vec<SocketAddr>, GatewayConversionError> { | ||
| host.to_socket_addrs(mix_port) | ||
| .map_err(|err| GatewayConversionError::InvalidAddress { | ||
| value: host.to_string(), | ||
| source: err, | ||
| } | ||
| })?[0]) | ||
| }) | ||
| } | ||
|
|
||
| pub fn identity(&self) -> &NodeIdentity { | ||
|
|
@@ -135,7 +134,7 @@ impl filter::Versioned for Node { | |
|
|
||
| impl<'a> From<&'a Node> for SphinxNode { | ||
| fn from(node: &'a Node) -> Self { | ||
| let node_address_bytes = NymNodeRoutingAddress::from(node.mix_host) | ||
| let node_address_bytes = NymNodeRoutingAddress::from(node.mix_hosts[0]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| .try_into() | ||
| .unwrap(); | ||
|
|
||
|
|
@@ -151,12 +150,12 @@ impl<'a> TryFrom<&'a GatewayBond> for Node { | |
|
|
||
| // try to completely resolve the host in the mix situation to avoid doing it every | ||
| // single time we want to construct a path | ||
| let mix_host = Self::extract_mix_host(&host, bond.gateway.mix_port)?; | ||
| let mix_hosts = Self::extract_mix_host(&host, bond.gateway.mix_port)?; | ||
|
|
||
| Ok(Node { | ||
| owner: bond.owner.as_str().to_owned(), | ||
| host, | ||
| mix_host, | ||
| mix_hosts, | ||
| clients_ws_port: bond.gateway.clients_port, | ||
| clients_wss_port: None, | ||
| identity_key: identity::PublicKey::from_base58_string(&bond.gateway.identity_key)?, | ||
|
|
@@ -196,12 +195,15 @@ impl<'a> TryFrom<&'a DescribedGateway> for Node { | |
|
|
||
| // get ip from the self-reported values so we wouldn't need to do any hostname resolution | ||
| // (which doesn't really work in wasm) | ||
| let mix_host = SocketAddr::new(ips[0], value.bond.gateway.mix_port); | ||
| let mix_hosts = ips | ||
| .iter() | ||
| .map(|ip| SocketAddr::new(*ip, value.bond.gateway.mix_port)) | ||
| .collect(); | ||
|
|
||
| Ok(Node { | ||
| owner: value.bond.owner.as_str().to_owned(), | ||
| host, | ||
| mix_host, | ||
| mix_hosts, | ||
| clients_ws_port: self_described.mixnet_websockets.unwrap().ws_port, //SW gateway have that field | ||
| clients_wss_port: self_described.mixnet_websockets.unwrap().wss_port, //SW gateway have that field | ||
| identity_key: identity::PublicKey::from_base58_string( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,9 +34,9 @@ pub struct Node { | |
| pub mix_id: MixId, | ||
| pub owner: String, | ||
| pub host: NetworkAddress, | ||
| // we're keeping this as separate resolved field since we do not want to be resolving the potential | ||
| // hostname every time we want to construct a path via this node | ||
| pub mix_host: SocketAddr, | ||
| // we're keeping all resolved IPs as a separate field since we do not want to be resolving the potential | ||
| // hostname every time we want to construct a path via this node. When we need one, we default to the first one | ||
| pub mix_hosts: Vec<SocketAddr>, | ||
| pub identity_key: identity::PublicKey, | ||
| pub sphinx_key: encryption::PublicKey, // TODO: or nymsphinx::PublicKey? both are x25519 | ||
| pub layer: Layer, | ||
|
|
@@ -49,7 +49,7 @@ impl std::fmt::Debug for Node { | |
| .field("mix_id", &self.mix_id) | ||
| .field("owner", &self.owner) | ||
| .field("host", &self.host) | ||
| .field("mix_host", &self.mix_host) | ||
| .field("mix_hosts", &self.mix_hosts) | ||
| .field("identity_key", &self.identity_key.to_base58_string()) | ||
| .field("sphinx_key", &self.sphinx_key.to_base58_string()) | ||
| .field("layer", &self.layer) | ||
|
|
@@ -70,13 +70,12 @@ impl Node { | |
| pub fn extract_mix_host( | ||
| host: &NetworkAddress, | ||
| mix_port: u16, | ||
| ) -> Result<SocketAddr, MixnodeConversionError> { | ||
| Ok(host.to_socket_addrs(mix_port).map_err(|err| { | ||
| MixnodeConversionError::InvalidAddress { | ||
| ) -> Result<Vec<SocketAddr>, MixnodeConversionError> { | ||
| host.to_socket_addrs(mix_port) | ||
| .map_err(|err| MixnodeConversionError::InvalidAddress { | ||
| value: host.to_string(), | ||
| source: err, | ||
| } | ||
| })?[0]) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -89,7 +88,7 @@ impl filter::Versioned for Node { | |
|
|
||
| impl<'a> From<&'a Node> for SphinxNode { | ||
| fn from(node: &'a Node) -> Self { | ||
| let node_address_bytes = NymNodeRoutingAddress::from(node.mix_host) | ||
| let node_address_bytes = NymNodeRoutingAddress::from(node.mix_hosts[0]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| .try_into() | ||
| .unwrap(); | ||
|
|
||
|
|
@@ -105,13 +104,13 @@ impl<'a> TryFrom<&'a MixNodeBond> for Node { | |
|
|
||
| // try to completely resolve the host in the mix situation to avoid doing it every | ||
| // single time we want to construct a path | ||
| let mix_host = Self::extract_mix_host(&host, bond.mix_node.mix_port)?; | ||
| let mix_hosts = Self::extract_mix_host(&host, bond.mix_node.mix_port)?; | ||
|
|
||
| Ok(Node { | ||
| mix_id: bond.mix_id, | ||
| owner: bond.owner.as_str().to_owned(), | ||
| host, | ||
| mix_host, | ||
| mix_hosts, | ||
| identity_key: identity::PublicKey::from_base58_string(&bond.mix_node.identity_key)?, | ||
| sphinx_key: encryption::PublicKey::from_base58_string(&bond.mix_node.sphinx_key)?, | ||
| layer: bond.layer, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.