Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 8 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ members = [
"sdk/ffi/go",
"sdk/ffi/shared",
"sdk/rust/nym-sdk",
"service-providers/authenticator",
"service-providers/common",
"service-providers/ip-packet-router",
"service-providers/network-requester",
Expand Down Expand Up @@ -165,7 +164,6 @@ default-members = [
"nym-statistics-api",
"nym-validator-rewarder",
"nyx-chain-watcher",
"service-providers/authenticator",
"service-providers/ip-packet-router",
"service-providers/network-requester",
"tools/nymvisor",
Expand Down
26 changes: 16 additions & 10 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
]
description = "Implementation of the Nym Mixnet Gateway"
edition = "2021"
rust-version = "1.76"
rust-version = "1.77"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -20,13 +20,16 @@ path = "src/lib.rs"

[dependencies]
anyhow = { workspace = true }
bincode = { workspace = true }
async-trait = { workspace = true }
bip39 = { workspace = true }
bs58 = { workspace = true }
dashmap = { workspace = true }
fastrand = { workspace = true }
futures = { workspace = true }
ipnetwork = { workspace = true }
rand = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sha2 = { workspace = true }
thiserror = { workspace = true }
time = { workspace = true }
Expand All @@ -44,8 +47,8 @@ tracing = { workspace = true }
url = { workspace = true, features = ["serde"] }
zeroize = { workspace = true }


# internal
nym-authenticator = { path = "../service-providers/authenticator" }
nym-api-requests = { path = "../nym-api/nym-api-requests" }
nym-credentials = { path = "../common/credentials" }
nym-credentials-interface = { path = "../common/credentials-interface" }
Expand All @@ -71,13 +74,16 @@ nym-node-metrics = { path = "../nym-node/nym-node-metrics" }
nym-wireguard = { path = "../common/wireguard" }
nym-wireguard-types = { path = "../common/wireguard-types", default-features = false }

nym-authenticator-requests = { path = "../common/authenticator-requests" }
nym-client-core = { path = "../common/client-core", features = ["cli"] }
nym-id = { path = "../common/nym-id" }
nym-service-provider-requests-common = { path = "../common/service-provider-requests-common" }


defguard_wireguard_rs = { workspace = true }

[build-dependencies]
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
sqlx = { workspace = true, features = [
"runtime-tokio-rustls",
"sqlite",
"macros",
"migrate",
] }
[dev-dependencies]
nym-gateway-storage = { path = "../common/gateway-storage", features = ["mock"] }
nym-wireguard = { path = "../common/wireguard", features = ["mock"] }
mock_instant = "0.5.3"
time = { workspace = true }
2 changes: 1 addition & 1 deletion gateway/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only

use nym_authenticator::error::AuthenticatorError;
use crate::node::internal_service_providers::authenticator::error::AuthenticatorError;
use nym_gateway_stats_storage::error::StatsStorageError;
use nym_gateway_storage::error::GatewayStorageError;
use nym_ip_packet_router::error::IpPacketRouterError;
Expand Down
2 changes: 2 additions & 0 deletions gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ pub mod node;

pub use error::GatewayError;
pub use node::GatewayTasksBuilder;

pub use node::internal_service_providers::authenticator as nym_authenticator;
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2024 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: Apache-2.0

use nym_network_defaults::{
WG_PORT, WG_TUN_DEVICE_IP_ADDRESS_V4, WG_TUN_DEVICE_IP_ADDRESS_V6, WG_TUN_DEVICE_NETMASK_V4,
WG_TUN_DEVICE_NETMASK_V6,
};
use serde::{Deserialize, Serialize};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};

pub use nym_client_core::config::Config as BaseClientConfig;
pub use persistence::AuthenticatorPaths;

pub mod persistence;

#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
pub struct Config {
#[serde(flatten)]
pub base: BaseClientConfig,

#[serde(default)]
pub authenticator: Authenticator,

pub storage_paths: AuthenticatorPaths,
}

impl Config {
pub fn validate(&self) -> bool {
// no other sections have explicit requirements (yet)
self.base.validate()
}
}

#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct Authenticator {
/// Socket address this node will use for binding its wireguard interface.
/// default: `0.0.0.0:51822`
pub bind_address: SocketAddr,

/// Private IP address of the wireguard gateway.
/// default: `10.1.0.1`
pub private_ipv4: Ipv4Addr,

/// Private IP address of the wireguard gateway.
/// default: `fc01::1`
pub private_ipv6: Ipv6Addr,

/// Port announced to external clients wishing to connect to the wireguard interface.
/// Useful in the instances where the node is behind a proxy.
pub announced_port: u16,

/// The prefix denoting the maximum number of the clients that can be connected via Wireguard using IPv4.
/// The maximum value for IPv4 is 32
pub private_network_prefix_v4: u8,

/// The prefix denoting the maximum number of the clients that can be connected via Wireguard using IPv6.
/// The maximum value for IPv6 is 128
pub private_network_prefix_v6: u8,
}

impl Default for Authenticator {
fn default() -> Self {
Self {
bind_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), WG_PORT),
private_ipv4: WG_TUN_DEVICE_IP_ADDRESS_V4,
private_ipv6: WG_TUN_DEVICE_IP_ADDRESS_V6,
announced_port: WG_PORT,
private_network_prefix_v4: WG_TUN_DEVICE_NETMASK_V4,
private_network_prefix_v6: WG_TUN_DEVICE_NETMASK_V6,
}
}
}

impl From<Authenticator> for nym_wireguard_types::Config {
fn from(value: Authenticator) -> Self {
nym_wireguard_types::Config {
bind_address: value.bind_address,
private_ipv4: value.private_ipv4,
private_ipv6: value.private_ipv6,
announced_port: value.announced_port,
private_network_prefix_v4: value.private_network_prefix_v4,
private_network_prefix_v6: value.private_network_prefix_v6,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,3 @@ pub enum AuthenticatorError {
#[error("no credential received")]
NoCredentialReceived,
}

pub type Result<T> = std::result::Result<T, AuthenticatorError>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use nym_client_core::{config::disk_persistence::CommonClientPaths, TopologyProvi
use nym_sdk::{GatewayTransceiver, NymNetworkDetails};
use nym_task::TaskClient;

use crate::{config::BaseClientConfig, error::AuthenticatorError};
use crate::node::internal_service_providers::authenticator::{
config::BaseClientConfig, error::AuthenticatorError,
};

// Helper function to create the mixnet client.
// This is NOT in the SDK since we don't want to expose any of the client-core config types.
Expand Down
Loading
Loading