5a07b73375
* removed mnemonic from gateway config struct scaffolding for common mixnet listener running verloc unconditionally in a nym-node remove filtering by mixnode extracted verloc to separate crate integrated nym-node-http-server more tightly with the binary most logic for handling forward packets running all mixnode-related tasks natively inside nymnode removed gateway storage trait in favour of the only concrete implementation most logic for handling final hop packets using nym-node owned socket listener for gateways utility for sending plain message through mixnet + gateway fix using common packet forwarding in both modes nifying nym-node metrics reproduce behaviour of the console logger cleaned up cli args redesigned gateway tasks startup procedure removing dead code scaffolding for old config v6 config migration implemented MixnetMetricsCleaner * clippy * require entry/exit for wireguard * removed dead code in migration code * updated config template * use custom user agent for verloc queries * fixed premature shutdown of gateway tasks * hidden nym-api flag to allow illegal node ips * experiment: final hop handing with wireguard * added additional startup logs * typo * fixed legacy stats endpoint data * additional logs * apply review comments * fixed local testnet manager
58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{PacketSize, CURRENT_PACKET_VERSION_NUMBER};
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum PacketVersion {
|
|
// this will allow updated mixnodes to still understand packets from before the update
|
|
Legacy,
|
|
Versioned(u8),
|
|
}
|
|
|
|
impl PacketVersion {
|
|
pub fn new() -> Self {
|
|
Self::new_versioned(CURRENT_PACKET_VERSION_NUMBER)
|
|
}
|
|
|
|
pub fn new_legacy() -> Self {
|
|
PacketVersion::Legacy
|
|
}
|
|
|
|
pub fn new_versioned(version: u8) -> Self {
|
|
PacketVersion::Versioned(version)
|
|
}
|
|
|
|
pub fn is_legacy(&self) -> bool {
|
|
matches!(self, PacketVersion::Legacy)
|
|
}
|
|
|
|
pub fn as_u8(&self) -> Option<u8> {
|
|
match self {
|
|
PacketVersion::Legacy => None,
|
|
PacketVersion::Versioned(version) => Some(*version),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<u8> for PacketVersion {
|
|
fn from(v: u8) -> Self {
|
|
match v {
|
|
n if n == PacketSize::RegularPacket as u8 => PacketVersion::Legacy,
|
|
n if n == PacketSize::AckPacket as u8 => PacketVersion::Legacy,
|
|
n if n == PacketSize::ExtendedPacket8 as u8 => PacketVersion::Legacy,
|
|
n if n == PacketSize::ExtendedPacket16 as u8 => PacketVersion::Legacy,
|
|
n if n == PacketSize::ExtendedPacket32 as u8 => PacketVersion::Legacy,
|
|
n => PacketVersion::Versioned(n),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for PacketVersion {
|
|
fn default() -> Self {
|
|
PacketVersion::Versioned(CURRENT_PACKET_VERSION_NUMBER)
|
|
}
|
|
}
|