rust-nex/prudpv0/src/lib.rs
Maple a88f1898a5
Some checks failed
Build and Test / friends (push) Successful in 3m13s
Build and Test / splatoon (push) Failing after 4m27s
fix warnings
2026-04-26 13:15:56 +02:00

50 lines
1.6 KiB
Rust

use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "prudpv0")] {
use log::info;
use proxy_common::ProxyStartupParam;
use std::env;
use std::net::SocketAddrV4;
use std::sync::{Arc, LazyLock};
use crate::crypto::{Crypto, Insecure, Secure};
use crate::server::Server;
mod crypto;
mod packet;
mod server;
pub static EDGE_NODE_HOLDER: LazyLock<SocketAddrV4> = LazyLock::new(|| {
env::var("EDGE_NODE_HOLDER")
.ok()
.and_then(|s| s.parse().ok())
.expect("EDGE_NODE_HOLDER not set")
});
pub static FORWARD_DESTINATION: LazyLock<SocketAddrV4> = LazyLock::new(|| {
env::var("FORWARD_DESTINATION")
.ok()
.and_then(|s| s.parse().ok())
.expect("FORWARD_DESTINATION not set")
});
//same as with prudpv1 this is responsible for handeling the different cryptography
//implementations, e.g. secure and insecure(this also includes special cases like friends)
async fn start_proxy<T: Crypto>(param: ProxyStartupParam) {
info!("binding to socket");
let server: Arc<Server<T>> = Arc::new(Server::new(param).await);
info!("waiting on packets");
server.run_task().await;
}
pub async fn start_secure(param: ProxyStartupParam) {
start_proxy::<Secure>(param).await;
}
pub async fn start_insecure(param: ProxyStartupParam) {
start_proxy::<Insecure>(param).await;
}
}
}