Merge branch 'develop' of github.com:nymtech/nym into develop

This commit is contained in:
Dave Hrycyszyn
2020-01-20 14:46:15 +00:00
12 changed files with 113 additions and 15 deletions
Generated
+4 -4
View File
@@ -1339,7 +1339,7 @@ dependencies = [
[[package]]
name = "nym-client"
version = "0.3.1"
version = "0.3.2"
dependencies = [
"addressing",
"base64 0.11.0",
@@ -1372,7 +1372,7 @@ dependencies = [
[[package]]
name = "nym-mixnode"
version = "0.3.1"
version = "0.3.2"
dependencies = [
"addressing",
"base64 0.11.0",
@@ -1388,7 +1388,7 @@ dependencies = [
[[package]]
name = "nym-sfw-provider"
version = "0.3.1"
version = "0.3.2"
dependencies = [
"base64 0.11.0",
"built",
@@ -2381,7 +2381,7 @@ dependencies = [
[[package]]
name = "tokio-tungstenite"
version = "0.10.0"
source = "git+https://github.com/dbcfd/tokio-tungstenite?rev=6dc2018cbfe8fe7ddd75ff977343086503135b38#6dc2018cbfe8fe7ddd75ff977343086503135b38"
source = "git+https://github.com/snapview/tokio-tungstenite?rev=308d9680c0e59dd1e8651659a775c05df937934e#308d9680c0e59dd1e8651659a775c05df937934e"
dependencies = [
"futures 0.3.1",
"log",
@@ -1,6 +1,9 @@
use crate::requests::presence_topology_get::PresenceTopologyGetRequester;
use crate::{Client, Config, DirectoryClient};
use serde::{Deserialize, Serialize};
use std::convert::TryInto;
use std::io;
use std::net::ToSocketAddrs;
use topology::{CocoNode, MixNode, MixProviderNode, NymTopology};
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -44,15 +47,25 @@ pub struct MixNodePresence {
pub version: String,
}
impl Into<topology::MixNode> for MixNodePresence {
fn into(self) -> topology::MixNode {
topology::MixNode {
host: self.host.parse().unwrap(),
impl TryInto<topology::MixNode> for MixNodePresence {
type Error = io::Error;
fn try_into(self) -> Result<MixNode, Self::Error> {
let resolved_hostname = self.host.to_socket_addrs()?.next();
if resolved_hostname.is_none() {
return Err(io::Error::new(
io::ErrorKind::Other,
"no valid socket address",
));
}
Ok(topology::MixNode {
host: resolved_hostname.unwrap(),
pub_key: self.pub_key,
layer: self.layer,
last_seen: self.last_seen,
version: self.version,
}
})
}
}
@@ -175,7 +188,10 @@ impl NymTopology for Topology {
}
fn get_mix_nodes(&self) -> Vec<topology::MixNode> {
self.mix_nodes.iter().map(|x| x.clone().into()).collect()
self.mix_nodes
.iter()
.filter_map(|x| x.clone().try_into().ok())
.collect()
}
fn get_mix_provider_nodes(&self) -> Vec<topology::MixProviderNode> {
@@ -189,3 +205,40 @@ impl NymTopology for Topology {
self.coco_nodes.iter().map(|x| x.clone().into()).collect()
}
}
#[cfg(test)]
mod converting_mixnode_presence_into_topology_mixnode {
use super::*;
#[test]
fn it_returns_error_on_unresolvable_hostname() {
let unresolvable_hostname = "foomp.foomp.foomp:1234";
let mix_presence = MixNodePresence {
host: unresolvable_hostname.to_string(),
pub_key: "".to_string(),
layer: 0,
last_seen: 0,
version: "".to_string(),
};
let result: Result<topology::MixNode, io::Error> = mix_presence.try_into();
assert!(result.is_err())
}
#[test]
fn it_returns_resolved_ip_on_resolvable_hostname() {
let resolvable_hostname = "nymtech.net:1234";
let mix_presence = MixNodePresence {
host: resolvable_hostname.to_string(),
pub_key: "".to_string(),
layer: 0,
last_seen: 0,
version: "".to_string(),
};
let result: Result<topology::MixNode, io::Error> = mix_presence.try_into();
assert!(result.is_ok())
}
}
+5
View File
@@ -1,5 +1,10 @@
# nym-mixnode Changelog
## 0.3.2
* added separate announce address
* allows announcing dns hostname instead of an ip address
## 0.3.1
* Fixed crash when directory server goes down
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-mixnode"
version = "0.3.1"
version = "0.3.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"
+12
View File
@@ -32,6 +32,18 @@ fn main() {
.takes_value(true)
.required(true),
)
.arg(
Arg::with_name("announce_host")
.long("announce-host")
.help("The host that will be reported to the directory server")
.takes_value(true)
)
.arg(
Arg::with_name("announce_port")
.long("announce-port")
.help("The port that will be reported to the directory server")
.takes_value(true)
)
.arg(
Arg::with_name("directory")
.long("directory")
+1
View File
@@ -19,6 +19,7 @@ mod presence;
pub mod runner;
pub struct Config {
announce_address: String,
directory_server: String,
layer: usize,
public_key: MontgomeryPoint,
+1 -1
View File
@@ -17,7 +17,7 @@ impl Notifier {
};
let net_client = directory_client::Client::new(config);
let presence = MixNodePresence {
host: node_config.socket_address.to_string(), // note: the directory server determines the real incoming IP itself, but uses the socket. Host here is just a placeholder.
host: node_config.announce_address.clone(),
pub_key: node_config.public_key_string(),
layer: node_config.layer as u64,
last_seen: 0,
+19
View File
@@ -24,6 +24,10 @@ pub fn start(matches: &ArgMatches) {
"Listening for incoming packets on {}",
config.socket_address
);
println!(
"Announcing the following socket address: {}",
config.announce_address
);
let mix = MixNode::new(&config);
mix.start(config).unwrap();
@@ -51,6 +55,20 @@ fn new_config(matches: &ArgMatches) -> node::Config {
.next()
.expect("Failed to extract the socket address from the iterator");
let announce_host = matches.value_of("announce_host").unwrap_or(host);
let announce_port = matches
.value_of("announce_port")
.map(|port| port.parse::<u16>().unwrap())
.unwrap_or(port);
let _ = (announce_host, announce_port)
.to_socket_addrs()
.expect("Failed to combine announce host and port")
.next()
.expect("Failed to extract the announce socket address from the iterator");
let announce_address = format!("{}:{}", announce_host, announce_port);
let (secret_key, public_key) = sphinx::crypto::keygen();
let directory_server = matches
@@ -63,6 +81,7 @@ fn new_config(matches: &ArgMatches) -> node::Config {
layer,
public_key,
socket_address,
announce_address,
secret_key,
}
}
+4
View File
@@ -1,5 +1,9 @@
# nym-client Changelog
## 0.3.2
* allows receiving topology with dns hostname instead of an ip address
## 0.3.1
* Version increase for consistency with `nym-mixnode` and `nym-sfw-provider`
+2 -2
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-client"
version = "0.3.1"
version = "0.3.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"
@@ -39,7 +39,7 @@ topology = {path = "../common/topology" }
sphinx = { git = "https://github.com/nymtech/sphinx", rev="1d8cefcb6a0cb8e87d00d89eb1ccf2839e92aa1f" }
# putting this explicitly below everything and most likely, the next time we look into it, it will already have a proper release
tokio-tungstenite = { git = "https://github.com/dbcfd/tokio-tungstenite", rev="6dc2018cbfe8fe7ddd75ff977343086503135b38" }
tokio-tungstenite = { git = "https://github.com/snapview/tokio-tungstenite", rev="308d9680c0e59dd1e8651659a775c05df937934e" }
[build-dependencies]
built = "0.3.2"
+4
View File
@@ -1,5 +1,9 @@
# nym-sfw-provider Changelog
## 0.3.2
* Version increase for consistency with `nym-mixnode` and `nym-client`
## 0.3.1
* Fixed crash when directory server goes down
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
build = "build.rs"
name = "nym-sfw-provider"
version = "0.3.1"
version = "0.3.2"
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
edition = "2018"