Remove things not needed
This commit is contained in:
@@ -345,8 +345,8 @@ pub struct Client<T> {
|
||||
nym_root_directory: PathBuf,
|
||||
|
||||
#[serde(skip)]
|
||||
super_struct: PhantomData<*const T>,
|
||||
// super_struct: PhantomData<T>,
|
||||
//super_struct: PhantomData<*const T>,
|
||||
super_struct: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: NymConfig> Default for Client<T> {
|
||||
|
||||
@@ -36,7 +36,7 @@ use nymsphinx::receiver::ReconstructedMessage;
|
||||
use crate::client::config::{Config, SocketType};
|
||||
use crate::websocket;
|
||||
|
||||
pub mod config;
|
||||
pub(crate) mod config;
|
||||
|
||||
pub struct NymClient {
|
||||
/// Client configuration options, including, among other things, packet sending rates,
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
||||
app
|
||||
}
|
||||
|
||||
pub async fn register_with_gateway(
|
||||
async fn register_with_gateway(
|
||||
gateway: &gateway::Node,
|
||||
our_identity: Arc<identity::KeyPair>,
|
||||
) -> Arc<SharedKeys> {
|
||||
@@ -110,7 +110,7 @@ pub async fn register_with_gateway(
|
||||
.expect("failed to register with the gateway!")
|
||||
}
|
||||
|
||||
pub async fn gateway_details(
|
||||
async fn gateway_details(
|
||||
validator_servers: Vec<Url>,
|
||||
chosen_gateway_id: Option<&str>,
|
||||
) -> gateway::Node {
|
||||
@@ -144,7 +144,7 @@ pub async fn gateway_details(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show_address(config: &Config) {
|
||||
fn show_address(config: &Config) {
|
||||
fn load_identity_keys(pathfinder: &ClientKeyPathfinder) -> identity::KeyPair {
|
||||
let identity_keypair: identity::KeyPair =
|
||||
pemstore::load_keypair(&pemstore::KeyPairPath::new(
|
||||
|
||||
@@ -11,13 +11,13 @@ pub(crate) const ETH_ENDPOINT_ARG_NAME: &str = "eth_endpoint";
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub(crate) const ETH_PRIVATE_KEY_ARG_NAME: &str = "eth_private_key";
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub const DEFAULT_ETH_ENDPOINT: &str =
|
||||
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
||||
"https://rinkeby.infura.io/v3/00000000000000000000000000000000";
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub const DEFAULT_ETH_PRIVATE_KEY: &str =
|
||||
pub(crate) const DEFAULT_ETH_PRIVATE_KEY: &str =
|
||||
"0000000000000000000000000000000000000000000000000000000000000001";
|
||||
|
||||
pub mod init;
|
||||
pub(crate) mod init;
|
||||
pub(crate) mod run;
|
||||
pub(crate) mod upgrade;
|
||||
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod client;
|
||||
pub mod commands;
|
||||
pub mod websocket;
|
||||
|
||||
@@ -48,8 +48,12 @@ pub struct NymClient {
|
||||
|
||||
impl NymClient {
|
||||
pub fn new(config: Config) -> Self {
|
||||
info!("NymClient::new() 1");
|
||||
let pathfinder = ClientKeyPathfinder::new_from_config(config.get_base());
|
||||
info!("NymClient::new() 2");
|
||||
dbg!(&pathfinder);
|
||||
let key_manager = KeyManager::load_keys(&pathfinder).expect("failed to load stored keys");
|
||||
info!("NymClient::new() 3");
|
||||
|
||||
NymClient {
|
||||
config,
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
||||
app
|
||||
}
|
||||
|
||||
async fn register_with_gateway(
|
||||
pub async fn register_with_gateway(
|
||||
gateway: &gateway::Node,
|
||||
our_identity: Arc<identity::KeyPair>,
|
||||
) -> Arc<SharedKeys> {
|
||||
@@ -110,10 +110,12 @@ async fn register_with_gateway(
|
||||
.expect("failed to register with the gateway!")
|
||||
}
|
||||
|
||||
async fn gateway_details(
|
||||
pub async fn gateway_details(
|
||||
validator_servers: Vec<Url>,
|
||||
chosen_gateway_id: Option<&str>,
|
||||
) -> gateway::Node {
|
||||
dbg!(&validator_servers);
|
||||
dbg!(&chosen_gateway_id);
|
||||
let validator_api = validator_servers
|
||||
.choose(&mut thread_rng())
|
||||
.expect("The list of validator apis is empty");
|
||||
@@ -144,7 +146,7 @@ async fn gateway_details(
|
||||
}
|
||||
}
|
||||
|
||||
fn show_address(config: &Config) {
|
||||
pub fn show_address(config: &Config) {
|
||||
fn load_identity_keys(pathfinder: &ClientKeyPathfinder) -> identity::KeyPair {
|
||||
let identity_keypair: identity::KeyPair =
|
||||
pemstore::load_keypair(&pemstore::KeyPairPath::new(
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::client::config::Config;
|
||||
use clap::ArgMatches;
|
||||
use url::Url;
|
||||
|
||||
pub(crate) mod init;
|
||||
pub mod init;
|
||||
pub(crate) mod run;
|
||||
pub(crate) mod upgrade;
|
||||
|
||||
|
||||
@@ -106,5 +106,6 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
||||
return;
|
||||
}
|
||||
|
||||
dbg!(&config);
|
||||
NymClient::new(config).run_forever().await;
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
pub mod client;
|
||||
pub mod socks;
|
||||
pub mod commands;
|
||||
|
||||
Generated
+1
@@ -2553,6 +2553,7 @@ dependencies = [
|
||||
"nym-network-requester",
|
||||
"nym-socks5-client",
|
||||
"nymsphinx",
|
||||
"pretty_env_logger",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -59,6 +59,7 @@ network-defaults = { path = "../../common/network-defaults" }
|
||||
|
||||
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs", branch = "release"}
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4.0"
|
||||
|
||||
[dev-dependencies]
|
||||
ts-rs = "6.1.2"
|
||||
|
||||
@@ -4,15 +4,14 @@ use rand::rngs::OsRng;
|
||||
use client_core::client::key_manager::KeyManager;
|
||||
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
||||
use config::NymConfig;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
use nym_client::commands::{DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY};
|
||||
use nymsphinx::addressing::clients::Recipient;
|
||||
|
||||
pub static NATIVE_CLIENT_CONFIG_ID: &str = "hrycyszynvpn";
|
||||
pub static SOCKS5_CONFIG_ID: &str = "hrycyszynvpn";
|
||||
|
||||
// TODO
|
||||
pub static PROVIDER_ADDRESS: &str = "HL2ufyQ875JNkro17ubKQB4gJyy2ozG8SMrUvHbYXYca.E7iz8hixuWE763h6MdaSnXAXobDqEHuq3Bzvi9XLQhW@BNjYZPxzcJwczXHHgBxCAyVJKxN6LPteDRrKapxWmexv";
|
||||
|
||||
// TODO: move to config file
|
||||
static GATEWAY_ID: &str = "83x9YyNkQ5QEY84ZU6Wmq8XHqfwf9SUtR7g5PAYB1FRY"; // sandbox
|
||||
//static GATEWAY_ID: &str = "83x9YyNkQ5QEY84ZU6Wmq8XHqfwf9SUtR7g5PAYB1FRY"; // sandbox
|
||||
|
||||
pub struct Config {}
|
||||
|
||||
@@ -20,104 +19,45 @@ impl Config {
|
||||
pub async fn init() {
|
||||
info!("Initialising...");
|
||||
|
||||
let native_client_address = init_native_client(GATEWAY_ID).await;
|
||||
init_socks5(native_client_address, GATEWAY_ID).await;
|
||||
init_socks5(PROVIDER_ADDRESS, None).await;
|
||||
|
||||
info!("Configuration saved 🚀");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn init_native_client(chosen_gateway_id: &str) -> Recipient {
|
||||
let mut config = nym_client::client::config::Config::new(NATIVE_CLIENT_CONFIG_ID);
|
||||
|
||||
let mut rng = OsRng;
|
||||
|
||||
// create identity, encryption and ack keys.
|
||||
let mut key_manager = KeyManager::new(&mut rng);
|
||||
|
||||
let gateway_details = nym_client::commands::init::gateway_details(
|
||||
config.get_base().get_validator_api_endpoints(),
|
||||
Some(chosen_gateway_id),
|
||||
)
|
||||
.await;
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_gateway_id(gateway_details.identity_key.to_base58_string());
|
||||
|
||||
config.get_base_mut().with_testnet_mode(true);
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT);
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY);
|
||||
|
||||
let shared_keys = nym_client::commands::init::register_with_gateway(
|
||||
&gateway_details,
|
||||
key_manager.identity_keypair(),
|
||||
)
|
||||
.await;
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_gateway_listener(gateway_details.clients_address());
|
||||
key_manager.insert_gateway_shared_key(shared_keys);
|
||||
|
||||
let pathfinder = ClientKeyPathfinder::new_from_config(config.get_base());
|
||||
key_manager
|
||||
.store_keys(&pathfinder)
|
||||
.expect("Failed to generated keys");
|
||||
info!("Saved all generated keys");
|
||||
|
||||
let config_save_location = config.get_config_file_save_location();
|
||||
config
|
||||
.save_to_file(None)
|
||||
.expect("Failed to save the config file");
|
||||
info!("Saved configuration file to {:?}", config_save_location);
|
||||
info!("Using gateway: {}", config.get_base().get_gateway_id(),);
|
||||
info!("Client configuration completed.\n\n\n");
|
||||
|
||||
nym_client::commands::init::show_address(&config)
|
||||
}
|
||||
|
||||
pub async fn init_socks5(provider_address: Recipient, chosen_gateway_id: &str) {
|
||||
pub async fn init_socks5(provider_address: &str, chosen_gateway_id: Option<&str>) {
|
||||
let id = SOCKS5_CONFIG_ID;
|
||||
|
||||
let mut config = nym_socks5::client::config::Config::new(id, &format!("{}", provider_address));
|
||||
|
||||
let mut rng = OsRng;
|
||||
let mut config = nym_socks5::client::config::Config::new(id, provider_address);
|
||||
|
||||
// create identity, encryption and ack keys.
|
||||
let mut rng = OsRng;
|
||||
let mut key_manager = KeyManager::new(&mut rng);
|
||||
|
||||
config.get_base_mut().with_testnet_mode(true);
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT);
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY);
|
||||
|
||||
let gateway_details = nym_client::commands::init::gateway_details(
|
||||
info!("Getting gateway details");
|
||||
let gateway_details = nym_socks5::commands::init::gateway_details(
|
||||
config.get_base().get_validator_api_endpoints(),
|
||||
Some(chosen_gateway_id),
|
||||
chosen_gateway_id,
|
||||
)
|
||||
.await;
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_gateway_id(gateway_details.identity_key.to_base58_string());
|
||||
let shared_keys = nym_client::commands::init::register_with_gateway(
|
||||
|
||||
info!("Registering with gateway");
|
||||
let shared_keys = nym_socks5::commands::init::register_with_gateway(
|
||||
&gateway_details,
|
||||
key_manager.identity_keypair(),
|
||||
)
|
||||
.await;
|
||||
|
||||
config
|
||||
.get_base_mut()
|
||||
.with_gateway_listener(gateway_details.clients_address());
|
||||
info!("Setting gateway endpoint");
|
||||
config.get_base_mut().with_gateway_endpoint(
|
||||
gateway_details.identity_key.to_base58_string(),
|
||||
gateway_details.owner.clone(),
|
||||
gateway_details.clients_address(),
|
||||
);
|
||||
|
||||
info!("Insert gateway shared key");
|
||||
key_manager.insert_gateway_shared_key(shared_keys);
|
||||
|
||||
info!("Creating client key path finder");
|
||||
let pathfinder = ClientKeyPathfinder::new_from_config(config.get_base());
|
||||
key_manager
|
||||
.store_keys(&pathfinder)
|
||||
@@ -131,4 +71,6 @@ pub async fn init_socks5(provider_address: Recipient, chosen_gateway_id: &str) {
|
||||
info!("Saved configuration file to {:?}", config_save_location);
|
||||
info!("Using gateway: {}", config.get_base().get_gateway_id(),);
|
||||
info!("Client configuration completed.\n\n\n");
|
||||
|
||||
nym_socks5::commands::init::show_address(&config);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ mod state;
|
||||
mod window;
|
||||
|
||||
fn main() {
|
||||
setup_logging();
|
||||
println!("Starting up...");
|
||||
|
||||
// as per breaking change description here: https://github.com/tauri-apps/tauri/blob/feac1d193c6d618e49916ad0707201f43d5cdd36/tooling/bundler/CHANGELOG.md
|
||||
@@ -44,6 +45,20 @@ fn main() {
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
fn setup_logging() {
|
||||
let mut log_builder = pretty_env_logger::formatted_timed_builder();
|
||||
if let Ok(s) = ::std::env::var("RUST_LOG") {
|
||||
log_builder.parse_filters(&s);
|
||||
} else {
|
||||
// default to 'Info'
|
||||
log_builder.filter(None, log::LevelFilter::Info);
|
||||
}
|
||||
|
||||
log_builder
|
||||
.filter_module("handlebars", log::LevelFilter::Warn)
|
||||
.init();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
ts_rs::export! {
|
||||
|
||||
@@ -1,196 +1,80 @@
|
||||
//use crate::models::{
|
||||
// AppEventConnectionStatusChangedPayload, ConnectionStatusKind, APP_EVENT_CONNECTION_STATUS_CHANGED,
|
||||
//};
|
||||
//use tauri::Manager;
|
||||
//use tokio::time::{sleep, Duration};
|
||||
//
|
||||
//type StatusChangedHandler = fn(status: &ConnectionStatusKind) -> ();
|
||||
//
|
||||
//pub struct State {
|
||||
// status: ConnectionStatusKind,
|
||||
//}
|
||||
//
|
||||
//impl State {
|
||||
// pub fn new() -> Self {
|
||||
// State {
|
||||
// status: ConnectionStatusKind::Disconnected,
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// pub fn get_status(&self) -> ConnectionStatusKind {
|
||||
// self.status.clone()
|
||||
// }
|
||||
//
|
||||
// fn set_state(&mut self, status: ConnectionStatusKind, window: &tauri::Window<tauri::Wry>) {
|
||||
// self.status = status.clone();
|
||||
// window.emit_all(
|
||||
// APP_EVENT_CONNECTION_STATUS_CHANGED,
|
||||
// AppEventConnectionStatusChangedPayload { status },
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// pub async fn init_config() {
|
||||
// // crate::config::Config::init().await;
|
||||
// }
|
||||
//
|
||||
// pub async fn start_connecting(&mut self, window: &tauri::Window<tauri::Wry>) {
|
||||
// self.set_state(ConnectionStatusKind::Connecting, window);
|
||||
// sleep(Duration::from_secs(2)).await;
|
||||
// self.set_state(ConnectionStatusKind::Connected, window);
|
||||
// }
|
||||
//
|
||||
// pub async fn start_disconnecting(&mut self, window: &tauri::Window<tauri::Wry>) {
|
||||
// self.set_state(ConnectionStatusKind::Disconnecting, window);
|
||||
// sleep(Duration::from_secs(2)).await;
|
||||
// self.set_state(ConnectionStatusKind::Disconnected, window);
|
||||
// }
|
||||
//}
|
||||
|
||||
use log::{error, info};
|
||||
use log::info;
|
||||
|
||||
use config::NymConfig;
|
||||
use nym_client::client::NymClient as NativeNymClient;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
use nym_socks5::client::NymClient as Socks5NymClient;
|
||||
use nymsphinx::addressing::clients::Recipient;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::config::{NATIVE_CLIENT_CONFIG_ID, SOCKS5_CONFIG_ID};
|
||||
use crate::models::ConnectionStatusKind;
|
||||
use crate::config::SOCKS5_CONFIG_ID;
|
||||
use crate::models::{
|
||||
AppEventConnectionStatusChangedPayload, ConnectionStatusKind, APP_EVENT_CONNECTION_STATUS_CHANGED,
|
||||
};
|
||||
use tauri::Manager;
|
||||
|
||||
pub struct State {
|
||||
status: ConnectionStatusKind,
|
||||
nym_client: Arc<RwLock<Option<NativeNymClient>>>,
|
||||
socks5_client: Arc<RwLock<Option<Socks5NymClient>>>,
|
||||
nym_network_requester: Arc<RwLock<Option<nym_network_requester::core::ServiceProvider>>>,
|
||||
//socks5_client: Arc<RwLock<Option<Socks5NymClient>>>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn new() -> Self {
|
||||
State {
|
||||
status: ConnectionStatusKind::Disconnected,
|
||||
nym_client: Arc::new(RwLock::new(None)),
|
||||
socks5_client: Arc::new(RwLock::new(None)),
|
||||
nym_network_requester: Arc::new(RwLock::new(None)),
|
||||
//socks5_client: Arc::new(RwLock::new(None)),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn get_status(&self) -> ConnectionStatusKind {
|
||||
self.status.clone()
|
||||
}
|
||||
|
||||
fn set_state(&mut self, status: ConnectionStatusKind, window: &tauri::Window<tauri::Wry>) {
|
||||
self.status = status.clone();
|
||||
window
|
||||
.emit_all(
|
||||
APP_EVENT_CONNECTION_STATUS_CHANGED,
|
||||
AppEventConnectionStatusChangedPayload { status },
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub async fn init_config() {
|
||||
crate::config::Config::init().await;
|
||||
}
|
||||
|
||||
pub async fn start_connecting(&mut self) {
|
||||
pub async fn start_connecting(&mut self, window: &tauri::Window<tauri::Wry>) {
|
||||
info!("Connecting");
|
||||
self.set_state(ConnectionStatusKind::Connecting, window);
|
||||
self.status = ConnectionStatusKind::Connecting;
|
||||
|
||||
let mut nym_client_guard = self.nym_client.write().await;
|
||||
let mut socks5_client_guard = self.socks5_client.write().await;
|
||||
let mut nym_network_requester_guard = self.nym_network_requester.write().await;
|
||||
Self::init_config().await;
|
||||
tokio::spawn(async move { start_nym_socks5_client().await });
|
||||
|
||||
*nym_client_guard = start_nym_native_client().await;
|
||||
if nym_client_guard.is_none() {
|
||||
self.status = ConnectionStatusKind::Disconnected;
|
||||
return;
|
||||
}
|
||||
|
||||
let address = nym_client_guard.unwrap().as_mix_recipient();
|
||||
info!("Nym client address is {}", address);
|
||||
|
||||
*socks5_client_guard = self.start_nym_socks5_client(&address).await;
|
||||
if socks5_client_guard.is_none() {
|
||||
self.status = ConnectionStatusKind::Disconnected;
|
||||
return;
|
||||
}
|
||||
|
||||
*nym_network_requester_guard = self.start_network_requester().await;
|
||||
self.status = ConnectionStatusKind::Connected;
|
||||
self.set_state(ConnectionStatusKind::Connected, window);
|
||||
}
|
||||
|
||||
pub async fn start_disconnecting(&mut self) {
|
||||
pub async fn start_disconnecting(&mut self, window: &tauri::Window<tauri::Wry>) {
|
||||
info!("Disconnecting");
|
||||
self.set_state(ConnectionStatusKind::Disconnecting, window);
|
||||
self.status = ConnectionStatusKind::Disconnecting;
|
||||
|
||||
let nym_client_guard = self.nym_client.write().await;
|
||||
let socks5_client_guard = self.socks5_client.write().await;
|
||||
let nym_network_requester_guard = self.nym_network_requester.write().await;
|
||||
|
||||
if nym_network_requester_guard.is_some() {
|
||||
// TODO: implement
|
||||
// nym_network_requester_guard.unwrap().stop().await;
|
||||
*nym_network_requester_guard = None;
|
||||
}
|
||||
|
||||
if socks5_client_guard.is_some() {
|
||||
// TODO: implement
|
||||
// socks5_client_guard.unwrap().stop().await;
|
||||
*socks5_client_guard = None;
|
||||
}
|
||||
|
||||
if nym_client_guard.is_some() {
|
||||
// TODO: implement
|
||||
// nym_client_guard.unwrap().stop().await;
|
||||
*nym_client_guard = None;
|
||||
}
|
||||
// TODO: implement
|
||||
// socks5_client_guard.unwrap().stop().await;
|
||||
// *socks5_client_guard = None;
|
||||
|
||||
self.status = ConnectionStatusKind::Disconnected;
|
||||
self.set_state(ConnectionStatusKind::Disconnected, window);
|
||||
}
|
||||
}
|
||||
|
||||
async fn start_nym_native_client() -> Option<NativeNymClient> {
|
||||
let id = NATIVE_CLIENT_CONFIG_ID;
|
||||
|
||||
let config = match nym_client::client::config::Config::load_from_file(Some(id)) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Failed to load config for {}. Are you sure you have run `init` before? (Error was: {})",
|
||||
id, err
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
// let base_config = config.get_base_mut();
|
||||
// base_config.with_gateway_id("83x9YyNkQ5QEY84ZU6Wmq8XHqfwf9SUtR7g5PAYB1FRY");
|
||||
|
||||
let mut nym_client = NativeNymClient::new(config);
|
||||
nym_client.start().await;
|
||||
Some(nym_client)
|
||||
}
|
||||
|
||||
async fn start_nym_socks5_client(recipient: &Recipient) -> Option<Socks5NymClient> {
|
||||
async fn start_nym_socks5_client() {
|
||||
let id = SOCKS5_CONFIG_ID;
|
||||
|
||||
let mut config = match nym_socks5::client::config::Config::load_from_file(Some(id)) {
|
||||
Ok(cfg) => cfg,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Failed to load config for {}. Are you sure you have run `init` before? (Error was: {})",
|
||||
id, err
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
// let base_config = config.get_base_mut();
|
||||
// base_config.with_gateway_id("83x9YyNkQ5QEY84ZU6Wmq8XHqfwf9SUtR7g5PAYB1FRY");
|
||||
|
||||
config = config.with_provider_mix_address(recipient.to_string());
|
||||
info!("Loading config from file");
|
||||
let config = nym_socks5::client::config::Config::load_from_file(Some(id)).unwrap();
|
||||
|
||||
let mut socks5_client = Socks5NymClient::new(config);
|
||||
info!("Starting socks5 client");
|
||||
socks5_client.start().await;
|
||||
Some(socks5_client)
|
||||
}
|
||||
|
||||
// TODO: use remote network requester
|
||||
async fn start_network_requester() -> nym_network_requester::core::ServiceProvider {
|
||||
let open_proxy = true;
|
||||
let uri = "ws://localhost:1977";
|
||||
info!("Starting socks5 service provider:");
|
||||
let mut server = nym_network_requester::core::ServiceProvider::new(uri.into(), open_proxy);
|
||||
server.run().await;
|
||||
server
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ version = "1.0.0-rc.2"
|
||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "nym_network_requester"
|
||||
path = "src/lib.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mod allowed_hosts;
|
||||
mod connection;
|
||||
pub mod core;
|
||||
mod websocket;
|
||||
@@ -5,7 +5,7 @@ use clap::{App, Arg, ArgMatches};
|
||||
|
||||
mod allowed_hosts;
|
||||
mod connection;
|
||||
pub mod core;
|
||||
mod core;
|
||||
mod websocket;
|
||||
|
||||
const OPEN_PROXY_ARG: &str = "open-proxy";
|
||||
|
||||
Reference in New Issue
Block a user