Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0be860268f |
Generated
+14
-1
@@ -4948,6 +4948,7 @@ dependencies = [
|
|||||||
"nym-nonexhaustive-delayqueue",
|
"nym-nonexhaustive-delayqueue",
|
||||||
"nym-pemstore",
|
"nym-pemstore",
|
||||||
"nym-sphinx",
|
"nym-sphinx",
|
||||||
|
"nym-sphinx-params",
|
||||||
"nym-statistics-common",
|
"nym-statistics-common",
|
||||||
"nym-task",
|
"nym-task",
|
||||||
"nym-topology",
|
"nym-topology",
|
||||||
@@ -4965,7 +4966,9 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
|
"toml 0.8.19",
|
||||||
"tungstenite 0.20.1",
|
"tungstenite 0.20.1",
|
||||||
|
"uneval",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
@@ -5991,7 +5994,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-node"
|
name = "nym-node"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -10468,6 +10471,16 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uneval"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "63cc5d2fd8648d7e2be86098f60c9ece7045cc710b3c1e226910e2f37d11dc73"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
|
|||||||
@@ -8,6 +8,13 @@ license.workspace = true
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
nym-client-core-config-types = { path = "./config-types", features = [
|
||||||
|
"disk-persistence",
|
||||||
|
] }
|
||||||
|
toml.workspace = true
|
||||||
|
uneval = "0.2.4"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
base64 = { workspace = true }
|
base64 = { workspace = true }
|
||||||
@@ -43,6 +50,7 @@ nym-gateway-requests = { path = "../gateway-requests" }
|
|||||||
nym-metrics = { path = "../nym-metrics" }
|
nym-metrics = { path = "../nym-metrics" }
|
||||||
nym-nonexhaustive-delayqueue = { path = "../nonexhaustive-delayqueue" }
|
nym-nonexhaustive-delayqueue = { path = "../nonexhaustive-delayqueue" }
|
||||||
nym-sphinx = { path = "../nymsphinx" }
|
nym-sphinx = { path = "../nymsphinx" }
|
||||||
|
nym-sphinx-params = { path = "../nymsphinx/params" }
|
||||||
nym-statistics-common = { path = "../statistics" }
|
nym-statistics-common = { path = "../statistics" }
|
||||||
nym-pemstore = { path = "../pemstore" }
|
nym-pemstore = { path = "../pemstore" }
|
||||||
nym-topology = { path = "../topology", features = ["persistence"] }
|
nym-topology = { path = "../topology", features = ["persistence"] }
|
||||||
@@ -117,12 +125,15 @@ features = ["wasm-bindgen"]
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
|
toml.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["enable-cfg"]
|
||||||
cli = ["clap", "comfy-table"]
|
cli = ["clap", "comfy-table"]
|
||||||
fs-credentials-storage = ["nym-credential-storage/persistent-storage"]
|
fs-credentials-storage = ["nym-credential-storage/persistent-storage"]
|
||||||
fs-surb-storage = ["nym-client-core-surb-storage/fs-surb-storage"]
|
fs-surb-storage = ["nym-client-core-surb-storage/fs-surb-storage"]
|
||||||
fs-gateways-storage = ["nym-client-core-gateways-storage/fs-gateways-storage"]
|
fs-gateways-storage = ["nym-client-core-gateways-storage/fs-gateways-storage"]
|
||||||
wasm = ["nym-gateway-client/wasm"]
|
wasm = ["nym-gateway-client/wasm"]
|
||||||
metrics-server = []
|
metrics-server = []
|
||||||
|
|
||||||
|
enable-cfg = []
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
use nym_client_core_config_types::Config;
|
||||||
|
|
||||||
|
use std::io::{BufWriter, Write};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
write_conditional_default();
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
const DEFAULT_CONFIG_FILE_NAME: &str = "nymvpn-config.toml";
|
||||||
|
|
||||||
|
const CONFIG_INIT_FN_PREAMBLE: &[u8] = br#"
|
||||||
|
pub fn new_bootstrapped<S1, S2>(id: S1, version: S2) -> Config
|
||||||
|
where
|
||||||
|
S1: Into<String>,
|
||||||
|
S2: Into<String>,
|
||||||
|
{
|
||||||
|
use nym_sphinx_params::{PacketSize, PacketType};
|
||||||
|
|
||||||
|
|
||||||
|
let mut cfg: Config = "#;
|
||||||
|
|
||||||
|
const CONFIG_INIT_FN_EPILOGUE: &[u8] = br#";
|
||||||
|
cfg.client.id = id.into();
|
||||||
|
cfg.client.version = version.into();
|
||||||
|
cfg
|
||||||
|
}"#;
|
||||||
|
|
||||||
|
// #[cfg(feature = "enable-cfg")]
|
||||||
|
// const CUSTOM_BREAK: &[u8] = br#"
|
||||||
|
// #[cfg(feature="enable-cfg")]
|
||||||
|
// "#;
|
||||||
|
|
||||||
|
// #[cfg(not(feature = "enable-cfg"))]
|
||||||
|
// const DEFAULT_BREAK: &[u8] = br#"
|
||||||
|
// #[cfg(not(feature="enable-cfg"))]
|
||||||
|
// "#;
|
||||||
|
|
||||||
|
// const CONFIG_INIT_FN_PREAMBLE: &[u8] = br#"
|
||||||
|
// impl Default for BaseClientConfig {
|
||||||
|
// fn default() -> Self {
|
||||||
|
// use config_types::Keys;
|
||||||
|
|
||||||
|
// Self("#;
|
||||||
|
|
||||||
|
// const DEFAULT_CONFIG_EPILOGUE: &[u8] = br#"
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }"#;
|
||||||
|
|
||||||
|
// #[cfg(feature = "enable-cfg")]
|
||||||
|
// const CUSTOM_BREAK: &[u8] = br#"
|
||||||
|
// #[cfg(feature="enable-cfg")]
|
||||||
|
// "#;
|
||||||
|
|
||||||
|
// #[cfg(not(feature = "enable-cfg"))]
|
||||||
|
// const DEFAULT_BREAK: &[u8] = br#"
|
||||||
|
// #[cfg(not(feature="enable-cfg"))]
|
||||||
|
// "#;
|
||||||
|
|
||||||
|
fn write_conditional_default() {
|
||||||
|
// creating a string with the values from our default Config object
|
||||||
|
let mut array_string = BufWriter::new(Vec::new());
|
||||||
|
array_string.write(CONFIG_INIT_FN_PREAMBLE).unwrap();
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-cfg")]
|
||||||
|
write_custom_config(&mut array_string);
|
||||||
|
|
||||||
|
#[cfg(not(feature = "enable-cfg"))]
|
||||||
|
{
|
||||||
|
let default_config = Config::new("", "");
|
||||||
|
uneval::write(default_config, &mut array_string).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
array_string.write(CONFIG_INIT_FN_EPILOGUE).unwrap();
|
||||||
|
|
||||||
|
// write the string to a file. OUT_DIR environment variable is defined by cargo
|
||||||
|
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||||
|
let dest_path = std::path::Path::new(&out_dir).join("default.rs");
|
||||||
|
|
||||||
|
let out_str = String::from_utf8(array_string.into_inner().unwrap()).unwrap();
|
||||||
|
std::fs::write(&dest_path, out_str).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "enable-cfg")]
|
||||||
|
pub(crate) fn write_custom_config(out: impl Write) {
|
||||||
|
// allow the name of the file we draw hardcoded values from to be set by an
|
||||||
|
// environment variable at compile time.
|
||||||
|
let cfg_file_name = option_env!("NYMVPN_CONFIG_PATH").unwrap_or(DEFAULT_CONFIG_FILE_NAME);
|
||||||
|
|
||||||
|
// set reasons to rebuild
|
||||||
|
println!("cargo:rerun-if-changed={cfg_file_name}");
|
||||||
|
println!("cargo:rerun-if-env-changed=NYMVPN_CONFIG_PATH");
|
||||||
|
|
||||||
|
let path = std::path::PathBuf::from(cfg_file_name);
|
||||||
|
let cfg_file_path = if path.is_absolute() {
|
||||||
|
path
|
||||||
|
} else {
|
||||||
|
let workspace_path = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
std::path::Path::new(&workspace_path).join(cfg_file_name)
|
||||||
|
};
|
||||||
|
|
||||||
|
let config_str: String = std::fs::read_to_string(cfg_file_path).unwrap();
|
||||||
|
let config: Config = toml::from_str(&config_str).unwrap();
|
||||||
|
|
||||||
|
uneval::write(config, out).unwrap();
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
[client]
|
||||||
|
version = ""
|
||||||
|
id = ""
|
||||||
|
disabled_credentials_mode = true
|
||||||
|
nyxd_urls = ["https://rpc.nymtech.net/"]
|
||||||
|
nym_api_urls = ["https://validator.nymtech.net/api/"]
|
||||||
|
|
||||||
|
[debug.traffic]
|
||||||
|
average_packet_delay = "50ms"
|
||||||
|
message_sending_average_delay = "20ms"
|
||||||
|
disable_main_poisson_packet_distribution = false
|
||||||
|
deterministic_route_selection = false
|
||||||
|
primary_packet_size = "regular"
|
||||||
|
packet_type = "mix"
|
||||||
|
|
||||||
|
[debug.cover_traffic]
|
||||||
|
loop_cover_traffic_average_delay = "200ms"
|
||||||
|
cover_traffic_primary_size_ratio = 0.7
|
||||||
|
disable_loop_cover_traffic_stream = false
|
||||||
|
|
||||||
|
[debug.gateway_connection]
|
||||||
|
gateway_response_timeout = "5m"
|
||||||
|
|
||||||
|
[debug.acknowledgements]
|
||||||
|
average_ack_delay = "50ms"
|
||||||
|
ack_wait_multiplier = 1.5
|
||||||
|
ack_wait_addition = "1s 500ms"
|
||||||
|
|
||||||
|
[debug.topology]
|
||||||
|
topology_refresh_rate = "5m"
|
||||||
|
topology_resolution_timeout = "5s"
|
||||||
|
disable_refreshing = false
|
||||||
|
max_startup_gateway_waiting_period = "1h 10m"
|
||||||
|
topology_structure = "NymApi"
|
||||||
|
minimum_mixnode_performance = 50
|
||||||
|
minimum_gateway_performance = 50
|
||||||
|
use_extended_topology = false
|
||||||
|
ignore_egress_epoch_role = false
|
||||||
|
|
||||||
|
[debug.reply_surbs]
|
||||||
|
minimum_reply_surb_storage_threshold = 10
|
||||||
|
maximum_reply_surb_storage_threshold = 200
|
||||||
|
minimum_reply_surb_request_size = 10
|
||||||
|
maximum_reply_surb_request_size = 100
|
||||||
|
maximum_allowed_reply_surb_request_size = 500
|
||||||
|
maximum_reply_surb_rerequest_waiting_period = "10s"
|
||||||
|
maximum_reply_surb_drop_waiting_period = "5m"
|
||||||
|
maximum_reply_surb_age = "12h"
|
||||||
|
maximum_reply_key_age = "1day"
|
||||||
|
|
||||||
|
[debug.stats_reporting]
|
||||||
|
enabled = true
|
||||||
|
reporting_interval = "5m"
|
||||||
@@ -7,3 +7,40 @@ pub use nym_client_core_config_types::old::{
|
|||||||
old_config_v1_1_33,
|
old_config_v1_1_33,
|
||||||
};
|
};
|
||||||
pub use nym_client_core_config_types::*;
|
pub use nym_client_core_config_types::*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/default.rs"));
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dump_default() {
|
||||||
|
let cfg = Config::new("","");
|
||||||
|
println!("{}", toml::to_string(&cfg).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bootstrapped_config() {
|
||||||
|
#[cfg(not(feature = "enable-cfg"))]
|
||||||
|
{
|
||||||
|
let config = new_bootstrapped("id1", "v0.0.0");
|
||||||
|
assert_eq!(config.client.id, "id1");
|
||||||
|
assert_eq!(config.client.version, "v0.0.0");
|
||||||
|
assert_eq!(config.client.disabled_credentials_mode, true);
|
||||||
|
|
||||||
|
assert_eq!(config.debug.topology.use_extended_topology, false);
|
||||||
|
assert_eq!(config.debug.stats_reporting.enabled, true);
|
||||||
|
}
|
||||||
|
#[cfg(feature = "enable-cfg")]
|
||||||
|
{
|
||||||
|
let config = new_bootstrapped("id2", "v0.0.0-beta");
|
||||||
|
assert_eq!(config.client.id, "id2");
|
||||||
|
assert_eq!(config.client.version, "v0.0.0-beta");
|
||||||
|
assert_eq!(config.client.disabled_credentials_mode, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,30 +59,30 @@ pub enum InvalidPacketSize {
|
|||||||
pub enum PacketSize {
|
pub enum PacketSize {
|
||||||
// for example instant messaging use case
|
// for example instant messaging use case
|
||||||
#[default]
|
#[default]
|
||||||
#[serde(rename = "regular")]
|
#[serde(alias = "regular")]
|
||||||
RegularPacket = 1,
|
RegularPacket = 1,
|
||||||
|
|
||||||
// for sending SURB-ACKs
|
// for sending SURB-ACKs
|
||||||
#[serde(rename = "ack")]
|
#[serde(alias = "ack")]
|
||||||
AckPacket = 2,
|
AckPacket = 2,
|
||||||
|
|
||||||
// for example for streaming fast and furious in uncompressed 10bit 4K HDR quality
|
// for example for streaming fast and furious in uncompressed 10bit 4K HDR quality
|
||||||
#[serde(rename = "extended32")]
|
#[serde(alias = "extended32")]
|
||||||
ExtendedPacket32 = 3,
|
ExtendedPacket32 = 3,
|
||||||
|
|
||||||
// for example for streaming fast and furious in heavily compressed lossy RealPlayer quality
|
// for example for streaming fast and furious in heavily compressed lossy RealPlayer quality
|
||||||
#[serde(rename = "extended8")]
|
#[serde(alias = "extended8")]
|
||||||
ExtendedPacket8 = 4,
|
ExtendedPacket8 = 4,
|
||||||
|
|
||||||
// for example for streaming fast and furious in compressed XviD quality
|
// for example for streaming fast and furious in compressed XviD quality
|
||||||
#[serde(rename = "extended16")]
|
#[serde(alias = "extended16")]
|
||||||
ExtendedPacket16 = 5,
|
ExtendedPacket16 = 5,
|
||||||
|
|
||||||
#[serde(rename = "outfox_regular")]
|
#[serde(alias = "outfox_regular")]
|
||||||
OutfoxRegularPacket = 6,
|
OutfoxRegularPacket = 6,
|
||||||
|
|
||||||
// for sending SURB-ACKs
|
// for sending SURB-ACKs
|
||||||
#[serde(rename = "outfox_ack")]
|
#[serde(alias = "outfox_ack")]
|
||||||
OutfoxAckPacket = 7,
|
OutfoxAckPacket = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,17 @@ pub enum PacketType {
|
|||||||
/// Represents 'normal' packet sent through the network that should be delayed by an appropriate
|
/// Represents 'normal' packet sent through the network that should be delayed by an appropriate
|
||||||
/// value at each hop.
|
/// value at each hop.
|
||||||
#[default]
|
#[default]
|
||||||
#[serde(rename = "mix")]
|
#[serde(alias = "mix")]
|
||||||
#[serde(alias = "sphinx")]
|
#[serde(alias = "sphinx")]
|
||||||
Mix = 0,
|
Mix = 0,
|
||||||
|
|
||||||
/// Represents a packet that should be sent through the network as fast as possible.
|
/// Represents a packet that should be sent through the network as fast as possible.
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
#[serde(rename = "unsupported-mix-vpn")]
|
#[serde(alias = "unsupported-mix-vpn")]
|
||||||
Vpn = 1,
|
Vpn = 1,
|
||||||
|
|
||||||
/// Abusing this to add Outfox support
|
/// Abusing this to add Outfox support
|
||||||
#[serde(rename = "outfox")]
|
#[serde(alias = "outfox")]
|
||||||
Outfox = 2,
|
Outfox = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user