Rename to nym-ip-packet-router
This commit is contained in:
Generated
+2
-2
@@ -6540,7 +6540,7 @@ dependencies = [
|
||||
"nym-credentials",
|
||||
"nym-crypto",
|
||||
"nym-gateway-requests",
|
||||
"nym-ip-forwarder",
|
||||
"nym-ip-packet-router",
|
||||
"nym-mixnet-client",
|
||||
"nym-mixnode-common",
|
||||
"nym-network-defaults",
|
||||
@@ -6645,7 +6645,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nym-ip-forwarder"
|
||||
name = "nym-ip-packet-router"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ nym-task = { path = "../common/task" }
|
||||
nym-types = { path = "../common/types" }
|
||||
nym-validator-client = { path = "../common/client-libs/validator-client" }
|
||||
nym-wireguard = { path = "../common/wireguard", optional = true }
|
||||
nym-ip-forwarder = { path = "../service-providers/ip-forwarder" }
|
||||
nym-ip-packet-router = { path = "../service-providers/ip-forwarder" }
|
||||
|
||||
[dev-dependencies]
|
||||
tower = "0.4.13"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::commands::upgrade_helpers;
|
||||
use crate::config::default_config_filepath;
|
||||
use crate::config::persistence::paths::{
|
||||
default_ip_forwarder_data_dir, default_network_requester_data_dir,
|
||||
default_ip_packet_router_data_dir, default_network_requester_data_dir,
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::error::GatewayError;
|
||||
@@ -41,7 +41,7 @@ pub(crate) struct OverrideConfig {
|
||||
pub(crate) nyxd_urls: Option<Vec<url::Url>>,
|
||||
pub(crate) only_coconut_credentials: Option<bool>,
|
||||
pub(crate) with_network_requester: Option<bool>,
|
||||
pub(crate) with_ip_forwarder: Option<bool>,
|
||||
pub(crate) with_ip_packet_router: Option<bool>,
|
||||
}
|
||||
|
||||
impl OverrideConfig {
|
||||
@@ -80,15 +80,15 @@ impl OverrideConfig {
|
||||
Config::with_enabled_network_requester,
|
||||
self.with_network_requester,
|
||||
)
|
||||
.with_optional(Config::with_enabled_ip_forwarder, self.with_ip_forwarder);
|
||||
.with_optional(Config::with_enabled_ip_packet_router, self.with_ip_packet_router);
|
||||
|
||||
if config.network_requester.enabled
|
||||
&& config.storage_paths.network_requester_config.is_none()
|
||||
{
|
||||
Ok(config.with_default_network_requester_config_path())
|
||||
} else if config.ip_forwarder.enabled && config.storage_paths.ip_forwarder_config.is_none()
|
||||
} else if config.ip_packet_router.enabled && config.storage_paths.ip_packet_router_config.is_none()
|
||||
{
|
||||
Ok(config.with_default_ip_forwarder_config_path())
|
||||
Ok(config.with_default_ip_packet_router_config_path())
|
||||
} else {
|
||||
Ok(config)
|
||||
}
|
||||
@@ -236,10 +236,10 @@ pub(crate) fn override_network_requester_config(
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn override_ip_forwarder_config(
|
||||
cfg: nym_ip_forwarder::Config,
|
||||
pub(crate) fn override_ip_packet_router_config(
|
||||
cfg: nym_ip_packet_router::Config,
|
||||
_opts: Option<OverrideIpForwarderConfig>,
|
||||
) -> nym_ip_forwarder::Config {
|
||||
) -> nym_ip_packet_router::Config {
|
||||
cfg
|
||||
}
|
||||
|
||||
@@ -315,21 +315,21 @@ pub(crate) async fn initialise_local_network_requester(
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn initialise_local_ip_forwarder(
|
||||
pub(crate) async fn initialise_local_ip_packet_router(
|
||||
gateway_config: &Config,
|
||||
opts: OverrideIpForwarderConfig,
|
||||
identity: identity::PublicKey,
|
||||
) -> Result<GatewayIpForwarderDetails, GatewayError> {
|
||||
info!("initialising ip forwarder...");
|
||||
let Some(ip_cfg_path) = gateway_config.storage_paths.ip_forwarder_config() else {
|
||||
let Some(ip_cfg_path) = gateway_config.storage_paths.ip_packet_router_config() else {
|
||||
return Err(GatewayError::UnspecifiedIpForwarderConfig);
|
||||
};
|
||||
|
||||
let id = &gateway_config.gateway.id;
|
||||
let ip_id = make_ip_id(id);
|
||||
let ip_data_dir = default_ip_forwarder_data_dir(id);
|
||||
let mut ip_cfg = nym_ip_forwarder::Config::new(&ip_id).with_data_directory(ip_data_dir);
|
||||
ip_cfg = override_ip_forwarder_config(ip_cfg, Some(opts));
|
||||
let ip_data_dir = default_ip_packet_router_data_dir(id);
|
||||
let mut ip_cfg = nym_ip_packet_router::Config::new(&ip_id).with_data_directory(ip_data_dir);
|
||||
ip_cfg = override_ip_packet_router_config(ip_cfg, Some(opts));
|
||||
|
||||
let key_store = OnDiskKeys::new(ip_cfg.storage_paths.common_paths.keys.clone());
|
||||
let details_store =
|
||||
@@ -367,7 +367,7 @@ pub(crate) async fn initialise_local_ip_forwarder(
|
||||
}
|
||||
|
||||
Ok(GatewayIpForwarderDetails {
|
||||
enabled: gateway_config.ip_forwarder.enabled,
|
||||
enabled: gateway_config.ip_packet_router.enabled,
|
||||
identity_key: address.identity().to_string(),
|
||||
encryption_key: address.encryption_key().to_string(),
|
||||
address: address.to_string(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::commands::helpers::{
|
||||
initialise_local_ip_forwarder, initialise_local_network_requester,
|
||||
initialise_local_ip_packet_router, initialise_local_network_requester,
|
||||
OverrideNetworkRequesterConfig,
|
||||
};
|
||||
use crate::config::{default_config_directory, default_config_filepath, default_data_directory};
|
||||
@@ -82,12 +82,12 @@ pub struct Init {
|
||||
statistics_service_url: Option<url::Url>,
|
||||
|
||||
/// Allows this gateway to run an embedded network requester for minimal network overhead
|
||||
#[clap(long, conflicts_with = "with_ip_forwarder")]
|
||||
#[clap(long, conflicts_with = "with_ip_packet_router")]
|
||||
with_network_requester: bool,
|
||||
|
||||
/// Allows this gateway to run an embedded network requester for minimal network overhead
|
||||
#[clap(long, hide = true, conflicts_with = "with_network_requester")]
|
||||
with_ip_forwarder: bool,
|
||||
with_ip_packet_router: bool,
|
||||
|
||||
// ##### NETWORK REQUESTER FLAGS #####
|
||||
/// Specifies whether this network requester should run in 'open-proxy' mode
|
||||
@@ -161,7 +161,7 @@ impl From<Init> for OverrideConfig {
|
||||
nyxd_urls: init_config.nyxd_urls,
|
||||
only_coconut_credentials: init_config.only_coconut_credentials,
|
||||
with_network_requester: Some(init_config.with_network_requester),
|
||||
with_ip_forwarder: Some(init_config.with_ip_forwarder),
|
||||
with_ip_packet_router: Some(init_config.with_ip_packet_router),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,8 +243,8 @@ pub async fn execute(args: Init) -> anyhow::Result<()> {
|
||||
if config.network_requester.enabled {
|
||||
initialise_local_network_requester(&config, nr_opts, *identity_keys.public_key())
|
||||
.await?;
|
||||
} else if config.ip_forwarder.enabled {
|
||||
initialise_local_ip_forwarder(&config, ip_opts, *identity_keys.public_key()).await?;
|
||||
} else if config.ip_packet_router.enabled {
|
||||
initialise_local_ip_packet_router(&config, ip_opts, *identity_keys.public_key()).await?;
|
||||
}
|
||||
|
||||
eprintln!("Saved identity and mixnet sphinx keypairs");
|
||||
@@ -293,7 +293,7 @@ mod tests {
|
||||
only_coconut_credentials: None,
|
||||
output: Default::default(),
|
||||
with_network_requester: false,
|
||||
with_ip_forwarder: false,
|
||||
with_ip_packet_router: false,
|
||||
open_proxy: None,
|
||||
enable_statistics: None,
|
||||
statistics_recipient: None,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub(crate) mod helpers;
|
||||
pub(crate) mod init;
|
||||
pub(crate) mod node_details;
|
||||
pub(crate) mod run;
|
||||
pub(crate) mod setup_ip_forwarder;
|
||||
pub(crate) mod setup_ip_packet_router;
|
||||
pub(crate) mod setup_network_requester;
|
||||
pub(crate) mod sign;
|
||||
mod upgrade_helpers;
|
||||
@@ -35,7 +35,7 @@ pub(crate) enum Commands {
|
||||
/// Add ip forwarder support to this gateway
|
||||
// essentially an option to include ip forwarder without having to setup fresh gateway
|
||||
#[command(hide = true)]
|
||||
SetupIpForwarder(setup_ip_forwarder::CmdArgs),
|
||||
SetupIpForwarder(setup_ip_packet_router::CmdArgs),
|
||||
|
||||
/// Sign text to prove ownership of this mixnode
|
||||
Sign(sign::Sign),
|
||||
@@ -58,7 +58,7 @@ pub(crate) async fn execute(args: Cli) -> Result<(), Box<dyn Error + Send + Sync
|
||||
Commands::NodeDetails(m) => node_details::execute(m).await?,
|
||||
Commands::Run(m) => run::execute(m).await?,
|
||||
Commands::SetupNetworkRequester(m) => setup_network_requester::execute(m).await?,
|
||||
Commands::SetupIpForwarder(m) => setup_ip_forwarder::execute(m).await?,
|
||||
Commands::SetupIpForwarder(m) => setup_ip_packet_router::execute(m).await?,
|
||||
Commands::Sign(m) => sign::execute(m)?,
|
||||
Commands::BuildInfo(m) => build_info::execute(m),
|
||||
Commands::Completions(s) => s.generate(&mut crate::Cli::command(), bin_name),
|
||||
|
||||
@@ -87,12 +87,12 @@ pub struct Run {
|
||||
statistics_service_url: Option<url::Url>,
|
||||
|
||||
/// Allows this gateway to run an embedded network requester for minimal network overhead
|
||||
#[arg(long, conflicts_with = "with_ip_forwarder")]
|
||||
#[arg(long, conflicts_with = "with_ip_packet_router")]
|
||||
with_network_requester: Option<bool>,
|
||||
|
||||
/// Allows this gateway to run an embedded network requester for minimal network overhead
|
||||
#[arg(long, hide = true, conflicts_with = "with_network_requester")]
|
||||
with_ip_forwarder: Option<bool>,
|
||||
with_ip_packet_router: Option<bool>,
|
||||
|
||||
// ##### NETWORK REQUESTER FLAGS #####
|
||||
/// Specifies whether this network requester should run in 'open-proxy' mode
|
||||
@@ -163,7 +163,7 @@ impl From<Run> for OverrideConfig {
|
||||
nyxd_urls: run_config.nyxd_urls,
|
||||
only_coconut_credentials: run_config.only_coconut_credentials,
|
||||
with_network_requester: run_config.with_network_requester,
|
||||
with_ip_forwarder: run_config.with_ip_forwarder,
|
||||
with_ip_packet_router: run_config.with_ip_packet_router,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::commands::helpers::{
|
||||
initialise_local_ip_forwarder, try_load_current_config, OverrideIpForwarderConfig,
|
||||
initialise_local_ip_packet_router, try_load_current_config, OverrideIpForwarderConfig,
|
||||
};
|
||||
use crate::node::helpers::load_public_key;
|
||||
use clap::Args;
|
||||
@@ -43,22 +43,22 @@ pub async fn execute(args: CmdArgs) -> anyhow::Result<()> {
|
||||
// but it might be nice to be able to move files around.
|
||||
if let Some(custom_config_path) = args.custom_config_path {
|
||||
// if you specified anything as the argument, overwrite whatever was already in the config file
|
||||
config.storage_paths.ip_forwarder_config = Some(custom_config_path);
|
||||
config.storage_paths.ip_packet_router_config = Some(custom_config_path);
|
||||
}
|
||||
|
||||
if let Some(override_enabled) = args.enabled {
|
||||
config.ip_forwarder.enabled = override_enabled;
|
||||
config.ip_packet_router.enabled = override_enabled;
|
||||
}
|
||||
|
||||
if config.storage_paths.ip_forwarder_config.is_none() {
|
||||
config = config.with_default_ip_forwarder_config_path()
|
||||
if config.storage_paths.ip_packet_router_config.is_none() {
|
||||
config = config.with_default_ip_packet_router_config_path()
|
||||
}
|
||||
|
||||
let identity_public_key = load_public_key(
|
||||
&config.storage_paths.keys.public_identity_key_file,
|
||||
"gateway identity",
|
||||
)?;
|
||||
let details = initialise_local_ip_forwarder(&config, opts, identity_public_key).await?;
|
||||
let details = initialise_local_ip_packet_router(&config, opts, identity_public_key).await?;
|
||||
config.try_save()?;
|
||||
|
||||
args.output.to_stdout(&details);
|
||||
@@ -102,7 +102,7 @@ pub struct Config {
|
||||
pub network_requester: NetworkRequester,
|
||||
|
||||
#[serde(default)]
|
||||
pub ip_forwarder: IpForwarder,
|
||||
pub ip_packet_router: IpPacketRouter,
|
||||
|
||||
#[serde(default)]
|
||||
pub logging: LoggingSettings,
|
||||
@@ -132,7 +132,7 @@ impl Config {
|
||||
wireguard: Default::default(),
|
||||
storage_paths: GatewayPaths::new_default(id.as_ref()),
|
||||
network_requester: Default::default(),
|
||||
ip_forwarder: Default::default(),
|
||||
ip_packet_router: Default::default(),
|
||||
logging: Default::default(),
|
||||
debug: Default::default(),
|
||||
}
|
||||
@@ -200,15 +200,15 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_enabled_ip_forwarder(mut self, enabled_ip_forwarder: bool) -> Self {
|
||||
self.ip_forwarder.enabled = enabled_ip_forwarder;
|
||||
pub fn with_enabled_ip_packet_router(mut self, enabled_ip_packet_router: bool) -> Self {
|
||||
self.ip_packet_router.enabled = enabled_ip_packet_router;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_default_ip_forwarder_config_path(mut self) -> Self {
|
||||
pub fn with_default_ip_packet_router_config_path(mut self) -> Self {
|
||||
self.storage_paths = self
|
||||
.storage_paths
|
||||
.with_default_ip_forwarder_config(&self.gateway.id);
|
||||
.with_default_ip_packet_router_config(&self.gateway.id);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -379,13 +379,13 @@ impl Default for NetworkRequester {
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct IpForwarder {
|
||||
pub struct IpPacketRouter {
|
||||
/// Specifies whether ip forwarder service is enabled in this process.
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for IpForwarder {
|
||||
impl Default for IpPacketRouter {
|
||||
fn default() -> Self {
|
||||
Self { enabled: false }
|
||||
}
|
||||
|
||||
@@ -142,14 +142,14 @@ impl From<ConfigV1_1_31> for Config {
|
||||
clients_storage: value.storage_paths.clients_storage,
|
||||
network_requester_config: value.storage_paths.network_requester_config,
|
||||
// \/ ADDED
|
||||
ip_forwarder_config: Default::default(),
|
||||
ip_packet_router_config: Default::default(),
|
||||
// /\ ADDED
|
||||
},
|
||||
network_requester: NetworkRequester {
|
||||
enabled: value.network_requester.enabled,
|
||||
},
|
||||
// \/ ADDED
|
||||
ip_forwarder: Default::default(),
|
||||
ip_packet_router: Default::default(),
|
||||
// /\ ADDED
|
||||
logging: LoggingSettings {
|
||||
// no fields (yet)
|
||||
|
||||
@@ -15,8 +15,8 @@ pub const DEFAULT_CLIENTS_STORAGE_FILENAME: &str = "db.sqlite";
|
||||
pub const DEFAULT_NETWORK_REQUESTER_CONFIG_FILENAME: &str = "network_requester_config.toml";
|
||||
pub const DEFAULT_NETWORK_REQUESTER_DATA_DIR: &str = "network-requester-data";
|
||||
|
||||
pub const DEFAULT_IP_FORWARDER_CONFIG_FILENAME: &str = "ip_forwarder_config.toml";
|
||||
pub const DEFAULT_IP_FORWARDER_DATA_DIR: &str = "ip-forwarder-data";
|
||||
pub const DEFAULT_IP_PACKET_ROUTER_CONFIG_FILENAME: &str = "ip_packet_router_config.toml";
|
||||
pub const DEFAULT_IP_PACKET_ROUTER_DATA_DIR: &str = "ip-packet-router-data";
|
||||
|
||||
// pub const DEFAULT_DESCRIPTION_FILENAME: &str = "description.toml";
|
||||
|
||||
@@ -24,8 +24,8 @@ pub fn default_network_requester_data_dir<P: AsRef<Path>>(id: P) -> PathBuf {
|
||||
default_data_directory(id).join(DEFAULT_NETWORK_REQUESTER_DATA_DIR)
|
||||
}
|
||||
|
||||
pub fn default_ip_forwarder_data_dir<P: AsRef<Path>>(id: P) -> PathBuf {
|
||||
default_data_directory(id).join(DEFAULT_IP_FORWARDER_DATA_DIR)
|
||||
pub fn default_ip_packet_router_data_dir<P: AsRef<Path>>(id: P) -> PathBuf {
|
||||
default_data_directory(id).join(DEFAULT_IP_PACKET_ROUTER_DATA_DIR)
|
||||
}
|
||||
|
||||
/// makes sure that an empty path is converted into a `None` as opposed to `Some("")`
|
||||
@@ -59,7 +59,7 @@ pub struct GatewayPaths {
|
||||
// pub cosmos_bip39_mnemonic: PathBuf,
|
||||
/// Path to the configuration of the embedded ip forwarder.
|
||||
#[serde(deserialize_with = "de_maybe_path")]
|
||||
pub ip_forwarder_config: Option<PathBuf>,
|
||||
pub ip_packet_router_config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl GatewayPaths {
|
||||
@@ -69,7 +69,7 @@ impl GatewayPaths {
|
||||
clients_storage: default_data_directory(id).join(DEFAULT_CLIENTS_STORAGE_FILENAME),
|
||||
// node_description: default_config_filepath(id).join(DEFAULT_DESCRIPTION_FILENAME),
|
||||
network_requester_config: None,
|
||||
ip_forwarder_config: None,
|
||||
ip_packet_router_config: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,15 +87,15 @@ impl GatewayPaths {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_ip_forwarder_config<P: AsRef<Path>>(mut self, path: P) -> Self {
|
||||
self.ip_forwarder_config = Some(path.as_ref().into());
|
||||
pub fn with_ip_packet_router_config<P: AsRef<Path>>(mut self, path: P) -> Self {
|
||||
self.ip_packet_router_config = Some(path.as_ref().into());
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_default_ip_forwarder_config<P: AsRef<Path>>(self, id: P) -> Self {
|
||||
self.with_ip_forwarder_config(
|
||||
default_config_directory(id).join(DEFAULT_IP_FORWARDER_CONFIG_FILENAME),
|
||||
pub fn with_default_ip_packet_router_config<P: AsRef<Path>>(self, id: P) -> Self {
|
||||
self.with_ip_packet_router_config(
|
||||
default_config_directory(id).join(DEFAULT_IP_PACKET_ROUTER_CONFIG_FILENAME),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ impl GatewayPaths {
|
||||
&self.network_requester_config
|
||||
}
|
||||
|
||||
pub fn ip_forwarder_config(&self) -> &Option<PathBuf> {
|
||||
&self.ip_forwarder_config
|
||||
pub fn ip_packet_router_config(&self) -> &Option<PathBuf> {
|
||||
&self.ip_packet_router_config
|
||||
}
|
||||
|
||||
pub fn private_identity_key(&self) -> &Path {
|
||||
|
||||
@@ -82,9 +82,9 @@ landing_page_assets_path = '{{ http.landing_page_assets_path }}'
|
||||
# Specifies whether network requester service is enabled in this process.
|
||||
enabled = {{ network_requester.enabled }}
|
||||
|
||||
[ip_forwarder]
|
||||
# Specifies whether ip forwarder service is enabled in this process.
|
||||
enabled = {{ ip_forwarder.enabled }}
|
||||
[ip_packet_router]
|
||||
# Specifies whether ip packet router service is enabled in this process.
|
||||
enabled = {{ ip_packet_router.enabled }}
|
||||
|
||||
[storage_paths]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::node::storage::error::StorageError;
|
||||
use nym_ip_forwarder::error::IpForwarderError;
|
||||
use nym_ip_packet_router::error::IpForwarderError;
|
||||
use nym_network_requester::error::{ClientCoreError, NetworkRequesterError};
|
||||
use nym_validator_client::nyxd::error::NyxdError;
|
||||
use nym_validator_client::nyxd::AccountId;
|
||||
|
||||
@@ -30,7 +30,7 @@ impl LocalNetworkRequesterHandle {
|
||||
|
||||
// TODO: generalize this whole thing to be general. And change the name(s).
|
||||
pub(crate) fn new_ip(
|
||||
start_data: nym_ip_forwarder::OnStartData,
|
||||
start_data: nym_ip_packet_router::OnStartData,
|
||||
mix_message_sender: MixMessageSender,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -96,12 +96,12 @@ pub(crate) fn load_network_requester_config<P: AsRef<Path>>(
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn load_ip_forwarder_config<P: AsRef<Path>>(
|
||||
pub(crate) fn load_ip_packet_router_config<P: AsRef<Path>>(
|
||||
id: &str,
|
||||
path: P,
|
||||
) -> Result<nym_ip_forwarder::Config, GatewayError> {
|
||||
) -> Result<nym_ip_packet_router::Config, GatewayError> {
|
||||
let path = path.as_ref();
|
||||
nym_ip_forwarder::Config::read_from_toml_file(path).map_err(|err| {
|
||||
nym_ip_packet_router::Config::read_from_toml_file(path).map_err(|err| {
|
||||
GatewayError::IpForwarderConfigLoadFailure {
|
||||
id: id.to_string(),
|
||||
path: path.to_path_buf(),
|
||||
|
||||
+17
-17
@@ -1,10 +1,10 @@
|
||||
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use self::helpers::load_ip_forwarder_config;
|
||||
use self::helpers::load_ip_packet_router_config;
|
||||
use self::storage::PersistentStorage;
|
||||
use crate::commands::helpers::{
|
||||
override_ip_forwarder_config, override_network_requester_config, OverrideIpForwarderConfig,
|
||||
override_ip_packet_router_config, override_network_requester_config, OverrideIpForwarderConfig,
|
||||
OverrideNetworkRequesterConfig,
|
||||
};
|
||||
use crate::config::Config;
|
||||
@@ -75,10 +75,10 @@ pub(crate) async fn create_gateway(
|
||||
};
|
||||
|
||||
// don't attempt to read config if NR is disabled
|
||||
let ip_forwarder_config = if config.ip_forwarder.enabled {
|
||||
if let Some(path) = &config.storage_paths.ip_forwarder_config {
|
||||
let cfg = load_ip_forwarder_config(&config.gateway.id, path)?;
|
||||
Some(override_ip_forwarder_config(cfg, ip_config_override))
|
||||
let ip_packet_router_config = if config.ip_packet_router.enabled {
|
||||
if let Some(path) = &config.storage_paths.ip_packet_router_config {
|
||||
let cfg = load_ip_packet_router_config(&config.gateway.id, path)?;
|
||||
Some(override_ip_packet_router_config(cfg, ip_config_override))
|
||||
} else {
|
||||
// if NR is enabled, the config path must be specified
|
||||
return Err(GatewayError::UnspecifiedIpForwarderConfig);
|
||||
@@ -94,7 +94,7 @@ pub(crate) async fn create_gateway(
|
||||
custom_mixnet_path: custom_mixnet.clone(),
|
||||
});
|
||||
|
||||
let ip_opts = ip_forwarder_config.map(|config| LocalIpForwarderOpts {
|
||||
let ip_opts = ip_packet_router_config.map(|config| LocalIpForwarderOpts {
|
||||
config,
|
||||
custom_mixnet_path: custom_mixnet,
|
||||
});
|
||||
@@ -111,7 +111,7 @@ pub struct LocalNetworkRequesterOpts {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LocalIpForwarderOpts {
|
||||
config: nym_ip_forwarder::Config,
|
||||
config: nym_ip_packet_router::Config,
|
||||
|
||||
custom_mixnet_path: Option<PathBuf>,
|
||||
}
|
||||
@@ -121,7 +121,7 @@ pub(crate) struct Gateway<St = PersistentStorage> {
|
||||
|
||||
network_requester_opts: Option<LocalNetworkRequesterOpts>,
|
||||
|
||||
ip_forwarder_opts: Option<LocalIpForwarderOpts>,
|
||||
ip_packet_router_opts: Option<LocalIpForwarderOpts>,
|
||||
|
||||
/// ed25519 keypair used to assert one's identity.
|
||||
identity_keypair: Arc<identity::KeyPair>,
|
||||
@@ -138,7 +138,7 @@ impl<St> Gateway<St> {
|
||||
pub fn new(
|
||||
config: Config,
|
||||
network_requester_opts: Option<LocalNetworkRequesterOpts>,
|
||||
ip_forwarder_opts: Option<LocalIpForwarderOpts>,
|
||||
ip_packet_router_opts: Option<LocalIpForwarderOpts>,
|
||||
storage: St,
|
||||
) -> Result<Self, GatewayError> {
|
||||
Ok(Gateway {
|
||||
@@ -147,7 +147,7 @@ impl<St> Gateway<St> {
|
||||
sphinx_keypair: Arc::new(helpers::load_sphinx_keys(&config)?),
|
||||
config,
|
||||
network_requester_opts,
|
||||
ip_forwarder_opts,
|
||||
ip_packet_router_opts,
|
||||
client_registry: Arc::new(DashMap::new()),
|
||||
})
|
||||
}
|
||||
@@ -156,7 +156,7 @@ impl<St> Gateway<St> {
|
||||
pub async fn new_from_keys_and_storage(
|
||||
config: Config,
|
||||
network_requester_opts: Option<LocalNetworkRequesterOpts>,
|
||||
ip_forwarder_opts: Option<LocalIpForwarderOpts>,
|
||||
ip_packet_router_opts: Option<LocalIpForwarderOpts>,
|
||||
identity_keypair: identity::KeyPair,
|
||||
sphinx_keypair: encryption::KeyPair,
|
||||
storage: St,
|
||||
@@ -164,7 +164,7 @@ impl<St> Gateway<St> {
|
||||
Gateway {
|
||||
config,
|
||||
network_requester_opts,
|
||||
ip_forwarder_opts,
|
||||
ip_packet_router_opts,
|
||||
identity_keypair: Arc::new(identity_keypair),
|
||||
sphinx_keypair: Arc::new(sphinx_keypair),
|
||||
storage,
|
||||
@@ -327,7 +327,7 @@ impl<St> Gateway<St> {
|
||||
info!("Starting IP service provider...");
|
||||
|
||||
// if network requester is enabled, configuration file must be provided!
|
||||
let Some(ip_opts) = &self.ip_forwarder_opts else {
|
||||
let Some(ip_opts) = &self.ip_packet_router_opts else {
|
||||
log::error!("IP service provider is enabled but no configuration file was provided!");
|
||||
return Err(GatewayError::UnspecifiedIpForwarderConfig);
|
||||
};
|
||||
@@ -346,8 +346,8 @@ impl<St> Gateway<St> {
|
||||
|
||||
// TODO: well, wire it up internally to gateway traffic, shutdowns, etc.
|
||||
let (on_start_tx, on_start_rx) = oneshot::channel();
|
||||
// let mut nr_builder = nym_ip_forwarder::IpForwarderBuilder::new(nr_opts.config.clone())
|
||||
let mut ip_builder = nym_ip_forwarder::IpForwarderBuilder::new(ip_opts.config.clone())
|
||||
// let mut nr_builder = nym_ip_packet_router::IpForwarderBuilder::new(nr_opts.config.clone())
|
||||
let mut ip_builder = nym_ip_packet_router::IpForwarderBuilder::new(ip_opts.config.clone())
|
||||
.with_shutdown(shutdown)
|
||||
.with_custom_gateway_transceiver(Box::new(transceiver))
|
||||
.with_wait_for_gateway(true)
|
||||
@@ -493,7 +493,7 @@ impl<St> Gateway<St> {
|
||||
|
||||
// NOTE: this is mutually exclusive with the network requester (for now). This is reflected
|
||||
// in the command line arguments as well.
|
||||
if self.config.ip_forwarder.enabled {
|
||||
if self.config.ip_packet_router.enabled {
|
||||
let embedded_ip_sp = self
|
||||
.start_ip_service_provider(
|
||||
mix_forwarding_channel.clone(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "nym-ip-forwarder"
|
||||
name = "nym-ip-packet-router"
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
Reference in New Issue
Block a user