Merge pull request #44 from nymtech/feature/explicit_directory
Removed local flag and replaced it with explicit directory server
This commit is contained in:
+4
-4
@@ -122,7 +122,7 @@ pub struct NymClient {
|
||||
// to be used by "send" function or socket, etc
|
||||
input_rx: mpsc::UnboundedReceiver<InputMessage>,
|
||||
socket_listening_address: SocketAddr,
|
||||
is_local: bool,
|
||||
directory: String,
|
||||
auth_token: Option<AuthToken>,
|
||||
socket_type: SocketType,
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl NymClient {
|
||||
pub fn new(
|
||||
address: DestinationAddressBytes,
|
||||
socket_listening_address: SocketAddr,
|
||||
is_local: bool,
|
||||
directory: String,
|
||||
auth_token: Option<AuthToken>,
|
||||
socket_type: SocketType,
|
||||
) -> Self {
|
||||
@@ -145,7 +145,7 @@ impl NymClient {
|
||||
input_tx,
|
||||
input_rx,
|
||||
socket_listening_address,
|
||||
is_local,
|
||||
directory,
|
||||
auth_token,
|
||||
socket_type,
|
||||
}
|
||||
@@ -222,7 +222,7 @@ impl NymClient {
|
||||
println!("Starting nym client");
|
||||
let mut rt = Runtime::new()?;
|
||||
|
||||
let topology = get_topology(self.is_local);
|
||||
let topology = get_topology(self.directory.clone());
|
||||
// this is temporary and assumes there exists only a single provider.
|
||||
let provider_address: SocketAddr = topology
|
||||
.mix_provider_nodes
|
||||
|
||||
@@ -9,13 +9,17 @@ use std::net::ToSocketAddrs;
|
||||
pub fn execute(matches: &ArgMatches) {
|
||||
println!("{}", banner());
|
||||
|
||||
let is_local = matches.is_present("local");
|
||||
let id = matches.value_of("id").unwrap().to_string();
|
||||
let port = match matches.value_of("port").unwrap_or("9001").parse::<u16>() {
|
||||
Ok(n) => n,
|
||||
Err(err) => panic!("Invalid port value provided - {:?}", err),
|
||||
};
|
||||
|
||||
let directory_server = matches
|
||||
.value_of("directory")
|
||||
.unwrap_or("https://directory.nymtech.net")
|
||||
.to_string();
|
||||
|
||||
println!("Starting TCP socket on port: {:?}", port);
|
||||
println!("Listening for messages...");
|
||||
|
||||
@@ -31,7 +35,7 @@ pub fn execute(matches: &ArgMatches) {
|
||||
let client = NymClient::new(
|
||||
keypair.public_bytes(),
|
||||
socket_address.clone(),
|
||||
is_local,
|
||||
directory_server,
|
||||
auth_token,
|
||||
SocketType::TCP,
|
||||
);
|
||||
|
||||
@@ -8,13 +8,17 @@ use std::net::ToSocketAddrs;
|
||||
pub fn execute(matches: &ArgMatches) {
|
||||
println!("{}", banner());
|
||||
|
||||
let is_local = matches.is_present("local");
|
||||
let id = matches.value_of("id").unwrap().to_string();
|
||||
let port = match matches.value_of("port").unwrap_or("9001").parse::<u16>() {
|
||||
Ok(n) => n,
|
||||
Err(err) => panic!("Invalid port value provided - {:?}", err),
|
||||
};
|
||||
|
||||
let directory_server = matches
|
||||
.value_of("directory")
|
||||
.unwrap_or("https://directory.nymtech.net")
|
||||
.to_string();
|
||||
|
||||
println!("Starting websocket on port: {:?}", port);
|
||||
println!("Listening for messages...");
|
||||
|
||||
@@ -30,7 +34,7 @@ pub fn execute(matches: &ArgMatches) {
|
||||
let client = NymClient::new(
|
||||
keypair.public_bytes(),
|
||||
socket_address,
|
||||
is_local,
|
||||
directory_server,
|
||||
auth_token,
|
||||
SocketType::WebSocket,
|
||||
);
|
||||
|
||||
+15
-12
@@ -37,10 +37,11 @@ fn main() {
|
||||
.takes_value(true)
|
||||
.required(true)
|
||||
)
|
||||
.arg(Arg::with_name("local")
|
||||
.long("local")
|
||||
.help("Flag to indicate whether the client is expected to run on the local deployment.")
|
||||
.takes_value(false)
|
||||
.arg(
|
||||
Arg::with_name("directory")
|
||||
.long("directory")
|
||||
.help("Address of the directory server the client is getting topology from")
|
||||
.takes_value(true),
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
@@ -54,10 +55,11 @@ fn main() {
|
||||
.takes_value(true)
|
||||
.required(true),
|
||||
)
|
||||
.arg(Arg::with_name("local")
|
||||
.long("local")
|
||||
.help("Flag to indicate whether the client is expected to run on the local deployment.")
|
||||
.takes_value(false)
|
||||
.arg(
|
||||
Arg::with_name("directory")
|
||||
.long("directory")
|
||||
.help("Address of the directory server the client is getting topology from")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(Arg::with_name("id")
|
||||
.long("id")
|
||||
@@ -76,10 +78,11 @@ fn main() {
|
||||
.help("Port for websocket to listen on")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(Arg::with_name("local")
|
||||
.long("local")
|
||||
.help("Flag to indicate whether the client is expected to run on the local deployment.")
|
||||
.takes_value(false)
|
||||
.arg(
|
||||
Arg::with_name("directory")
|
||||
.long("directory")
|
||||
.help("Address of the directory server the client is getting topology from")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(Arg::with_name("id")
|
||||
.long("id")
|
||||
|
||||
+5
-11
@@ -5,22 +5,16 @@ use crate::clients::directory::requests::presence_topology_get::PresenceTopology
|
||||
use crate::clients::directory::DirectoryClient;
|
||||
use crate::utils::{addressing, bytes};
|
||||
use curve25519_dalek::montgomery::MontgomeryPoint;
|
||||
use futures::AsyncReadExt;
|
||||
use rand::seq::SliceRandom;
|
||||
use sphinx::route::Node as SphinxNode;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::string::ToString;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub(crate) fn get_topology(is_local: bool) -> Topology {
|
||||
let url = if is_local {
|
||||
"http://localhost:8080".to_string()
|
||||
} else {
|
||||
"https://directory.nymtech.net".to_string()
|
||||
pub(crate) fn get_topology(directory_server: String) -> Topology {
|
||||
println!("Using directory server: {:?}", directory_server);
|
||||
let directory_config = directory::Config {
|
||||
base_url: directory_server,
|
||||
};
|
||||
println!("Using directory server: {:?}", url);
|
||||
let directory_config = directory::Config { base_url: url };
|
||||
let directory = directory::Client::new(directory_config);
|
||||
|
||||
let topology = directory
|
||||
|
||||
Reference in New Issue
Block a user