25053e5e8a
* Generic prom wrapper idea * Extend packet_statistics control with prom metrics * Replace counters with Counters * Add legacy mixnode api route * fmt * Sanitize metric names * Format metrics * Script to make prom targets * More metrics * Update script * Make sure we dont panic in the future * Remove fragile test * Add metrics endpoint auth * Remove per IP metrics * Update target script, node_exporter setup * Remove prom from client * Simplify node stat * Centralize metrice, break cpucycles temporarily * Remove prometheus from mixnode * Add cpu-cycles to Prom * Further centralize Registry * Cleanup old tracing * Remove spurious assignment * Move cpu-cycles to metrics * Add features * setup_logging before logging * Remove cpucycle measurement in favour of time * Cleanup, hygine
104 lines
3.3 KiB
Rust
104 lines
3.3 KiB
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
use nym_config::defaults::{DEFAULT_NYM_NODE_HTTP_PORT, WG_PORT};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_helpers::*;
|
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
|
use std::path::PathBuf;
|
|
|
|
pub mod persistence;
|
|
mod serde_helpers;
|
|
|
|
pub const DEFAULT_WIREGUARD_PORT: u16 = WG_PORT;
|
|
pub const DEFAULT_WIREGUARD_PREFIX: u8 = 16;
|
|
pub const DEFAULT_HTTP_PORT: u16 = DEFAULT_NYM_NODE_HTTP_PORT;
|
|
|
|
// TODO: this is very much a WIP. we need proper ssl certificate support here
|
|
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct Host {
|
|
/// Ip address(es) of this host, such as 1.1.1.1 that external clients will use for connections.
|
|
pub public_ips: Vec<IpAddr>,
|
|
|
|
/// Optional hostname of this node, for example nymtech.net.
|
|
// TODO: this is temporary. to be replaced by pulling the data directly from the certs.
|
|
#[serde(deserialize_with = "de_maybe_string")]
|
|
pub hostname: Option<String>,
|
|
}
|
|
|
|
impl Host {
|
|
pub fn validate(&self) -> bool {
|
|
if self.public_ips.is_empty() {
|
|
return false;
|
|
}
|
|
|
|
true
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(default)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct Http {
|
|
/// Socket address this node will use for binding its http API.
|
|
/// default: `0.0.0.0:8080`
|
|
/// note: for legacy reasons, it defaults to port `8000` for mixnodes.
|
|
pub bind_address: SocketAddr,
|
|
|
|
/// Path to assets directory of custom landing page of this node.
|
|
#[serde(deserialize_with = "de_maybe_path")]
|
|
pub landing_page_assets_path: Option<PathBuf>,
|
|
|
|
#[serde(default)]
|
|
pub metrics_key: Option<String>,
|
|
}
|
|
|
|
impl Default for Http {
|
|
fn default() -> Self {
|
|
Http {
|
|
bind_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), DEFAULT_HTTP_PORT),
|
|
landing_page_assets_path: None,
|
|
metrics_key: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
|
#[serde(default)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct Wireguard {
|
|
/// Specifies whether the wireguard service is enabled on this node.
|
|
pub enabled: bool,
|
|
|
|
/// Socket address this node will use for binding its wireguard interface.
|
|
/// default: `0.0.0.0:51822`
|
|
pub bind_address: SocketAddr,
|
|
|
|
/// 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.
|
|
/// The maximum value for IPv4 is 32 and for IPv6 is 128
|
|
pub private_network_prefix: u8,
|
|
|
|
/// Paths for wireguard keys, client registries, etc.
|
|
pub storage_paths: persistence::WireguardPaths,
|
|
}
|
|
|
|
impl Default for Wireguard {
|
|
fn default() -> Self {
|
|
Wireguard {
|
|
enabled: false,
|
|
bind_address: SocketAddr::new(
|
|
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
|
|
DEFAULT_WIREGUARD_PORT,
|
|
),
|
|
announced_port: DEFAULT_WIREGUARD_PORT,
|
|
private_network_prefix: DEFAULT_WIREGUARD_PREFIX,
|
|
storage_paths: persistence::WireguardPaths {},
|
|
}
|
|
}
|
|
}
|