Files
nym/gateway/src/config.rs
T
Jędrzej Stuczyński f6bd511599 feat: Lewes Protocol with PSQv2 (#6491)
* merging georgio/lp-psqv2-integration

* use authenicator on the responder's side

* nym-lp crate compiling

* moved the e2e test to nym-lp

* move key generation to peer

* moved principal generation

* update KKTResponder

* encapsulation key parsing

* Adding concrete types within KKT exchange

* initiator side of the full handshake

* responder side of the handshake and full e2e test

* fixed unit-tests within nym-kkt

* LpSession cleanup

* helpers for Transport

* revamp of the transport traits and initial work on client-side transport

* compiling nym-crypto

* 'working' client-entry dvpn reg

* Fix key conversion

* Slightly reduce use of rand08

* reverted back to libcrux repo refs

* intial telescoping reg

* removing dead code

* wip

* moved data encryption into the state machine

* restoring nym-lp tests

* update lp api model

* Add receiver index derivation

* Add receiver index derivation

* use derived receiver index

* feat: add kem key generation to nodes

* generate fresh x25519, mlkem768 and mceliece keys on config migration

* add lp peer config

* nym-node startup cleanup

* removed dependency on pre-rand09 from nym-lp

* re-expose LP information on the http API

* fixed tests compilation

* add peer config happy path tests

* formatting

* add more tests and fix bug

* better docs

* clippy and formatting issues

* return error on mceliece within NestedSession

* wasm fixes

* removed legacy nym-vpn-lib-wasm

* fixing wasm for real this time

* additional fixes

* add payload to kkt

* make clippy happy

* moved LP to nym-node crate

* cargo fmt

* integrate lpconfig payload

* fix response size trait impl

* Migrate receiver index

* Change receiver index to u32 and regorganize crates

* clippy

* hopefully final wasm fixes

* simple conversion method from semver to ciphersuite

* updated nym-node config template

* chore: remove duplicated code

---------

Co-authored-by: Georgio Nicolas <me@georgio.xyz>
2026-02-27 13:49:08 +00:00

159 lines
5.0 KiB
Rust

// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
use std::net::SocketAddr;
use std::time::Duration;
use url::Url;
#[derive(Debug)]
pub struct Config {
pub gateway: Gateway,
pub network_requester: NetworkRequester,
pub ip_packet_router: IpPacketRouter,
pub upgrade_mode_watcher: UpgradeModeWatcher,
pub debug: Debug,
}
impl Config {
pub fn new(
gateway: impl Into<Gateway>,
network_requester: impl Into<NetworkRequester>,
ip_packet_router: impl Into<IpPacketRouter>,
upgrade_mode_watcher: impl Into<UpgradeModeWatcher>,
debug: impl Into<Debug>,
) -> Self {
Config {
gateway: gateway.into(),
network_requester: network_requester.into(),
ip_packet_router: ip_packet_router.into(),
upgrade_mode_watcher: upgrade_mode_watcher.into(),
debug: debug.into(),
}
}
pub fn get_nym_api_endpoints(&self) -> Vec<Url> {
self.gateway.nym_api_urls.clone()
}
pub fn get_nyxd_urls(&self) -> Vec<Url> {
self.gateway.nyxd_urls.clone()
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct Gateway {
/// Indicates whether this gateway is accepting only zk-nym credentials for accessing the mixnet
/// or if it also accepts non-paying clients
pub enforce_zk_nyms: bool,
/// Socket address this node will use for binding its client websocket API.
/// default: `0.0.0.0:9000`
pub websocket_bind_address: SocketAddr,
/// Addresses to APIs from which the node gets the view of the network.
pub nym_api_urls: Vec<Url>,
/// Addresses to validators which the node uses to check for double spending of ERC20 tokens.
pub nyxd_urls: Vec<Url>,
}
#[derive(Debug)]
pub struct UpgradeModeWatcher {
/// Specifies whether this gateway watches for upgrade mode changes
/// via the published attestation file.
pub enabled: bool,
/// Endpoint to query to retrieve current upgrade mode attestation.
/// If not provided, it implicitly disables the watcher and upgrade-mode features
pub attestation_url: Url,
pub debug: UpgradeModeWatcherDebug,
}
#[derive(Debug)]
pub struct UpgradeModeWatcherDebug {
/// Default polling interval
pub regular_polling_interval: Duration,
/// Expedited polling interval for once upgrade mode is detected
pub expedited_poll_interval: Duration,
}
#[derive(Debug, PartialEq)]
pub struct NetworkRequester {
/// Specifies whether network requester service is enabled in this process.
pub enabled: bool,
}
#[allow(clippy::derivable_impls)]
impl Default for NetworkRequester {
fn default() -> Self {
NetworkRequester { enabled: false }
}
}
#[derive(Debug, PartialEq)]
pub struct IpPacketRouter {
/// Specifies whether ip packet router service is enabled in this process.
pub enabled: bool,
}
#[allow(clippy::derivable_impls)]
impl Default for IpPacketRouter {
fn default() -> Self {
Self { enabled: false }
}
}
#[derive(Debug)]
pub struct Debug {
/// Defines maximum delay between client bandwidth information being flushed to the persistent storage.
pub client_bandwidth_max_flushing_rate: Duration,
/// Defines a maximum change in client bandwidth before it gets flushed to the persistent storage.
pub client_bandwidth_max_delta_flushing_amount: i64,
/// Specifies how often the clean-up task should check for stale data.
pub stale_messages_cleaner_run_interval: Duration,
/// Specifies maximum age of stored messages before they are removed from the storage
pub stale_messages_max_age: Duration,
/// The maximum number of client connections the gateway will keep open at once.
pub maximum_open_connections: usize,
pub zk_nym_tickets: ZkNymTicketHandlerDebug,
/// Defines the timestamp skew of a signed authentication request before it's deemed too excessive to process.
pub max_request_timestamp_skew: Duration,
/// The minimum duration since the last explicit check for the upgrade mode to allow creation of new requests.
pub upgrade_mode_min_staleness_recheck: Duration,
}
#[derive(Debug, Clone)]
pub struct ZkNymTicketHandlerDebug {
/// Specifies the multiplier for revoking a malformed/double-spent ticket
/// (if it has to go all the way to the nym-api for verification)
/// e.g. if one ticket grants 100Mb and `revocation_bandwidth_penalty` is set to 1.5,
/// the client will lose 150Mb
pub revocation_bandwidth_penalty: f32,
/// Specifies the interval for attempting to resolve any failed, pending operations,
/// such as ticket verification or redemption.
pub pending_poller: Duration,
pub minimum_api_quorum: f32,
/// Specifies the minimum number of tickets this gateway will attempt to redeem.
pub minimum_redemption_tickets: usize,
/// Specifies the maximum time between two subsequent tickets redemptions.
/// That's required as nym-apis will purge all ticket information for tickets older than maximum validity.
pub maximum_time_between_redemption: Duration,
}