nym-sdk
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub use nym_client_core::config::Config as BaseConfig;
|
||||
use nym_client_core::config::DebugConfig;
|
||||
use nym_config::defaults::DEFAULT_SOCKS5_LISTENING_PORT;
|
||||
use nym_config::OptionalSet;
|
||||
use nym_service_providers_common::interface::ProviderInterfaceVersion;
|
||||
@@ -10,7 +9,6 @@ use nym_socks5_requests::Socks5ProtocolVersion;
|
||||
use nym_sphinx::addressing::clients::Recipient;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub mod old_config_v1_1_13;
|
||||
@@ -35,6 +33,10 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_base(base: BaseConfig, socks5: Socks5) -> Self {
|
||||
Config { base, socks5 }
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> bool {
|
||||
// no other sections have explicit requirements (yet)
|
||||
self.base.validate()
|
||||
|
||||
@@ -68,7 +68,8 @@ where
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn start_socks5_listener(
|
||||
config: Config,
|
||||
socks5_config: &config::Socks5,
|
||||
base_debug: DebugConfig,
|
||||
client_input: ClientInput,
|
||||
client_output: ClientOutput,
|
||||
client_status: ClientState,
|
||||
@@ -94,26 +95,24 @@ where
|
||||
..
|
||||
} = client_status;
|
||||
|
||||
let packet_size = config
|
||||
.base
|
||||
.debug
|
||||
let packet_size = base_debug
|
||||
.traffic
|
||||
.secondary_packet_size
|
||||
.unwrap_or(config.base.debug.traffic.primary_packet_size);
|
||||
.unwrap_or(base_debug.traffic.primary_packet_size);
|
||||
|
||||
let authenticator = Authenticator::new(auth_methods, allowed_users);
|
||||
let mut sphinx_socks = NymSocksServer::new(
|
||||
config.socks5.listening_port,
|
||||
socks5_config.listening_port,
|
||||
authenticator,
|
||||
config.socks5.get_provider_mix_address(),
|
||||
socks5_config.get_provider_mix_address(),
|
||||
self_address,
|
||||
shared_lane_queue_lengths,
|
||||
socks::client::Config::new(
|
||||
packet_size,
|
||||
config.socks5.provider_interface_version,
|
||||
config.socks5.socks5_protocol_version,
|
||||
config.socks5.send_anonymously,
|
||||
config.socks5.socks5_debug,
|
||||
socks5_config.provider_interface_version,
|
||||
socks5_config.socks5_protocol_version,
|
||||
socks5_config.send_anonymously,
|
||||
socks5_config.socks5_debug,
|
||||
),
|
||||
shutdown.clone(),
|
||||
packet_type,
|
||||
@@ -218,7 +217,8 @@ where
|
||||
info!("Running with {packet_type} packets",);
|
||||
|
||||
Self::start_socks5_listener(
|
||||
self.config,
|
||||
&self.config.socks5,
|
||||
self.config.base.debug,
|
||||
client_input,
|
||||
client_output,
|
||||
client_state,
|
||||
|
||||
@@ -7,6 +7,7 @@ use nym_client_core::client::key_manager::persistence::OnDiskKeys;
|
||||
use nym_client_core::client::replies::reply_storage::fs_backend;
|
||||
use nym_client_core::config;
|
||||
use nym_client_core::config::disk_persistence::key_pathfinder::ClientKeysPathfinder;
|
||||
use nym_client_core::config::disk_persistence::CommonClientPathfinder;
|
||||
use nym_credential_storage::persistent_storage::PersistentStorage as PersistentCredentialStorage;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -122,33 +123,29 @@ impl StoragePaths {
|
||||
|
||||
fn client_key_pathfinder(&self) -> ClientKeysPathfinder {
|
||||
ClientKeysPathfinder {
|
||||
identity_private_key: self.private_identity.clone(),
|
||||
identity_public_key: self.public_identity.clone(),
|
||||
encryption_private_key: self.private_encryption.clone(),
|
||||
encryption_public_key: self.public_encryption.clone(),
|
||||
gateway_shared_key: self.gateway_shared_key.clone(),
|
||||
ack_key: self.ack_key.clone(),
|
||||
private_identity_key_file: self.private_identity.clone(),
|
||||
public_identity_key_file: self.public_identity.clone(),
|
||||
private_encryption_key_file: self.private_encryption.clone(),
|
||||
public_encryption_key_file: self.public_encryption.clone(),
|
||||
gateway_shared_key_file: self.gateway_shared_key.clone(),
|
||||
ack_key_file: self.ack_key.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StoragePaths> for ClientKeysPathfinder {
|
||||
fn from(paths: StoragePaths) -> Self {
|
||||
paths.client_key_pathfinder()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<&nym_client_core::config::Config<T>> for StoragePaths {
|
||||
fn from(value: &nym_client_core::config::Config<T>) -> Self {
|
||||
Self {
|
||||
private_identity: value.get_private_identity_key_file(),
|
||||
public_identity: value.get_public_identity_key_file(),
|
||||
private_encryption: value.get_private_encryption_key_file(),
|
||||
public_encryption: value.get_public_encryption_key_file(),
|
||||
ack_key: value.get_ack_key_file(),
|
||||
gateway_shared_key: value.get_gateway_shared_key_file(),
|
||||
credential_database_path: value.get_database_path(),
|
||||
reply_surb_database_path: value.get_reply_surb_database_path(),
|
||||
impl From<StoragePaths> for CommonClientPathfinder {
|
||||
fn from(value: StoragePaths) -> Self {
|
||||
CommonClientPathfinder {
|
||||
keys_pathfinder: ClientKeysPathfinder {
|
||||
private_identity_key_file: value.private_identity,
|
||||
public_identity_key_file: value.public_identity,
|
||||
private_encryption_key_file: value.private_encryption,
|
||||
public_encryption_key_file: value.public_encryption,
|
||||
gateway_shared_key_file: value.gateway_shared_key,
|
||||
ack_key_file: value.ack_key,
|
||||
},
|
||||
credentials_database: value.credential_database_path,
|
||||
reply_surb_database_path: value.reply_surb_database_path,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +57,7 @@ impl Socks5MixnetClient {
|
||||
|
||||
/// Get the SOCKS5 proxy URL that a HTTP(S) client can connect to.
|
||||
pub fn socks5_url(&self) -> String {
|
||||
format!(
|
||||
"socks5h://127.0.0.1:{}",
|
||||
self.socks5_config.get_listening_port()
|
||||
)
|
||||
format!("socks5h://127.0.0.1:{}", self.socks5_config.listening_port)
|
||||
}
|
||||
|
||||
/// Get a shallow clone of [`LaneQueueLengths`]. This is useful to manually implement some form
|
||||
|
||||
Reference in New Issue
Block a user