-
Notifications
You must be signed in to change notification settings - Fork 263
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
Changes from 3 commits
8c60d85
084b03b
3cf3151
cd4718d
6d299b0
2e14136
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ pub struct Node { | |
| 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, | ||
| 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( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ pub struct Node { | |
| 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, | ||
| 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, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,13 +135,13 @@ impl TryFrom<SerializableMixNode> for mix::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 = mix::Node::extract_mix_host(&host, mix_port)?; | ||
| let mix_hosts = mix::Node::extract_mix_host(&host, mix_port)?; | ||
|
|
||
| Ok(mix::Node { | ||
| mix_id: value.mix_id, | ||
| owner: value.owner, | ||
| host, | ||
| mix_host, | ||
| mix_hosts, | ||
| identity_key: identity::PublicKey::from_base58_string(&value.identity_key) | ||
| .map_err(MixnodeConversionError::from)?, | ||
| sphinx_key: encryption::PublicKey::from_base58_string(&value.sphinx_key) | ||
|
|
@@ -159,7 +159,7 @@ impl<'a> From<&'a mix::Node> for SerializableMixNode { | |
| mix_id: value.mix_id, | ||
| owner: value.owner.clone(), | ||
| host: value.host.to_string(), | ||
| mix_port: Some(value.mix_host.port()), | ||
| mix_port: Some(value.mix_hosts[0].port()), | ||
|
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. as @octol says, |
||
| identity_key: value.identity_key.to_base58_string(), | ||
| sphinx_key: value.sphinx_key.to_base58_string(), | ||
| layer: value.layer.into(), | ||
|
|
@@ -182,7 +182,7 @@ pub struct SerializableGateway { | |
| // (thank you wasm) | ||
| #[cfg_attr(feature = "wasm-serde-types", tsify(optional))] | ||
| #[serde(alias = "explicit_ip")] | ||
| pub explicit_ip: Option<IpAddr>, | ||
| pub explicit_ips: Option<Vec<IpAddr>>, | ||
|
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. this might break
Contributor
Author
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. In the current state, |
||
|
|
||
| #[cfg_attr(feature = "wasm-serde-types", tsify(optional))] | ||
| #[serde(alias = "mix_port")] | ||
|
|
@@ -221,16 +221,19 @@ impl TryFrom<SerializableGateway> for gateway::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 = if let Some(explicit_ip) = value.explicit_ip { | ||
| SocketAddr::new(explicit_ip, mix_port) | ||
| let mix_hosts = if let Some(explicit_ips) = value.explicit_ips { | ||
| explicit_ips | ||
| .iter() | ||
| .map(|explicit_ip| SocketAddr::new(*explicit_ip, mix_port)) | ||
| .collect() | ||
| } else { | ||
| gateway::Node::extract_mix_host(&host, mix_port)? | ||
| }; | ||
|
|
||
| Ok(gateway::Node { | ||
| owner: value.owner, | ||
| host, | ||
| mix_host, | ||
| mix_hosts, | ||
| clients_ws_port, | ||
| clients_wss_port: value.clients_wss_port, | ||
| identity_key: identity::PublicKey::from_base58_string(&value.identity_key) | ||
|
|
@@ -247,8 +250,8 @@ impl<'a> From<&'a gateway::Node> for SerializableGateway { | |
| SerializableGateway { | ||
| owner: value.owner.clone(), | ||
| host: value.host.to_string(), | ||
| explicit_ip: Some(value.mix_host.ip()), | ||
| mix_port: Some(value.mix_host.port()), | ||
| explicit_ips: Some(value.mix_hosts.iter().map(|addr| addr.ip()).collect()), | ||
| mix_port: Some(value.mix_hosts[0].port()), | ||
| clients_ws_port: Some(value.clients_ws_port), | ||
| clients_wss_port: value.clients_wss_port, | ||
| identity_key: value.identity_key.to_base58_string(), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.