From 7f27ad0a3c39a204785a5792808eab0383604420 Mon Sep 17 00:00:00 2001 From: Maple Date: Sun, 26 Apr 2026 13:48:26 +0200 Subject: [PATCH] fix more warnings and add script to check all editions --- build-edition.sh | 3 +- buildscripts/common.sh | 1 + check-all.sh | 7 ++++ check-edition.sh | 12 +++++++ editions.yaml | 10 ------ prudpv1/src/executables/common.rs | 17 --------- prudpv1/src/executables/mod.rs | 1 - prudpv1/src/executables/proxy_insecure.rs | 36 +++---------------- prudpv1/src/executables/proxy_secure.rs | 22 +++--------- prudpv1/src/lib.rs | 6 ++-- prudpv1/src/prudp/packet.rs | 2 +- prudpv1/src/prudp/secure.rs | 6 +--- prudpv1/src/prudp/unsecure.rs | 4 +-- .../src/executables/backend_server_secure.rs | 2 +- 14 files changed, 38 insertions(+), 91 deletions(-) create mode 100755 check-all.sh create mode 100755 check-edition.sh delete mode 100644 prudpv1/src/executables/common.rs diff --git a/build-edition.sh b/build-edition.sh index 5d65fc3..ce17110 100755 --- a/build-edition.sh +++ b/build-edition.sh @@ -5,9 +5,8 @@ fi # comma seperated list of features for the specified version source ./buildscripts/common.sh +echo building $EDITION echo FEATURES: echo $EDITION_FEATURES -echo ENV SETTINGS: -env OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C relocation-model=static -C linker=ld.lld" cargo build --release --features "$EDITION_FEATURES" --target x86_64-unknown-linux-musl diff --git a/buildscripts/common.sh b/buildscripts/common.sh index 8c5e67e..f224752 100755 --- a/buildscripts/common.sh +++ b/buildscripts/common.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e pipefail TMP_FEATURES_TRAILINGCOMMA=$(yq ea ".$EDITION.features" editions.yaml | sed 's/- //g' | tr '\n' ',') export EDITION_FEATURES=${TMP_FEATURES_TRAILINGCOMMA::-1} SETTINGS=$(yq ea ".$EDITION.settings" editions.yaml | yq 'keys[]') diff --git a/check-all.sh b/check-all.sh new file mode 100755 index 0000000..e44fa1b --- /dev/null +++ b/check-all.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +SETTINGS=$(yq ea "." editions.yaml | yq 'keys[]') +IFS=$'\n' +while IFS=$'\n' read -r EDITION; do + ./check-edition.sh $EDITION +done <<< "$SETTINGS" diff --git a/check-edition.sh b/check-edition.sh new file mode 100755 index 0000000..9caaa67 --- /dev/null +++ b/check-edition.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +if [ -z ${EDITION+x} ]; then + EDITION=$1 +fi + +# comma seperated list of features for the specified version +source ./buildscripts/common.sh +echo CHECKING $EDITION +echo FEATURES: +echo $EDITION_FEATURES + +cargo check --features "$EDITION_FEATURES" diff --git a/editions.yaml b/editions.yaml index 7a6869c..ab27550 100644 --- a/editions.yaml +++ b/editions.yaml @@ -8,16 +8,6 @@ splatoon: RNEX_VIRTUAL_PORT_SECURE: "1:10" RNEX_DEFAULT_PORT: 6000 RNEX_ACCESS_KEY: "6f599f81" -splatoon2: - features: - - v4-3-11 - - prudplite - - nx - settings: - AUTH_REPORT_VERSION: "branch:origin/project/wup-agmj build:3_8_15_2004_0" - RNEX_VIRTUAL_PORT_INSECURE: "1:10" - RNEX_VIRTUAL_PORT_SECURE: "1:10" - RNEX_DEFAULT_PORT: 6000 friends: features: - friends diff --git a/prudpv1/src/executables/common.rs b/prudpv1/src/executables/common.rs deleted file mode 100644 index 8d6f4c1..0000000 --- a/prudpv1/src/executables/common.rs +++ /dev/null @@ -1,17 +0,0 @@ -use once_cell::sync::Lazy; -use std::env; -use std::net::SocketAddrV4; - -pub static EDGE_NODE_HOLDER: Lazy = Lazy::new(|| { - env::var("EDGE_NODE_HOLDER") - .ok() - .and_then(|s| s.parse().ok()) - .expect("EDGE_NODE_HOLDER not set") -}); - -pub static FORWARD_DESTINATION: Lazy = Lazy::new(|| { - env::var("FORWARD_DESTINATION") - .ok() - .and_then(|s| s.parse().ok()) - .expect("FORWARD_DESTINATION not set") -}); diff --git a/prudpv1/src/executables/mod.rs b/prudpv1/src/executables/mod.rs index 2c0d6cf..dbcfdd7 100644 --- a/prudpv1/src/executables/mod.rs +++ b/prudpv1/src/executables/mod.rs @@ -1,3 +1,2 @@ -pub mod common; pub mod proxy_insecure; pub mod proxy_secure; diff --git a/prudpv1/src/executables/proxy_insecure.rs b/prudpv1/src/executables/proxy_insecure.rs index 06299d1..b9b974c 100644 --- a/prudpv1/src/executables/proxy_insecure.rs +++ b/prudpv1/src/executables/proxy_insecure.rs @@ -1,45 +1,19 @@ -use crate::executables::common::{EDGE_NODE_HOLDER, FORWARD_DESTINATION}; use crate::prudp::router::Router; use crate::prudp::unsecure::Unsecure; use log::error; -use rnex_core::common::setup; -use rnex_core::executables::common::{OWN_IP_PRIVATE, OWN_IP_PUBLIC, SERVER_PORT}; +use proxy_common::{ProxyStartupParam, RNEX_ACCESS_KEY}; use rnex_core::prudp::virtual_port::VirtualPort; -use rnex_core::reggie::EdgeNodeHolderConnectOption::Register; -use rnex_core::reggie::RemoteEdgeNodeHolder; use rnex_core::reggie::UnitPacketRead; use rnex_core::reggie::UnitPacketWrite; -use rnex_core::rmc::protocols::{OnlyRemote, new_rmc_gateway_connection}; use rnex_core::rmc::structures::RmcSerialize; use rnex_core::rnex_proxy_common::ConnectionInitData; -use rnex_core::util::SplittableBufferConnection; -use std::net::SocketAddrV4; -use std::sync::Arc; use std::time::Duration; use tokio::net::TcpStream; use tokio::task; use tokio::time::sleep; -use proxy_common::RNEX_ACCESS_KEY; -pub async fn start() { - /*let conn = tokio::net::TcpStream::connect(&*EDGE_NODE_HOLDER) - .await - .unwrap(); - - let conn: SplittableBufferConnection = conn.into(); - - conn.send( - Register(SocketAddrV4::new(*OWN_IP_PUBLIC, *SERVER_PORT)) - .to_data() - .unwrap(), - ) - .await; - - let conn = new_rmc_gateway_connection(conn, |r| { - Arc::new(OnlyRemote::::new(r)) - });*/ - - let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)) +pub async fn start(param: ProxyStartupParam) { + let (router_secure, _) = Router::new(param.self_private) .await .expect("unable to start router"); @@ -48,8 +22,6 @@ pub async fn start() { .await .expect("unable to add socket"); - // let conn = socket_secure.connect(auth_sockaddr).await.unwrap(); - loop { let Some(mut conn) = socket_secure.accept().await else { error!("server crashed"); @@ -57,7 +29,7 @@ pub async fn start() { }; task::spawn(async move { - let mut stream = match TcpStream::connect(*FORWARD_DESTINATION).await { + let mut stream = match TcpStream::connect(param.forward_destination).await { Ok(v) => v, Err(e) => { error!("unable to connect: {}", e); diff --git a/prudpv1/src/executables/proxy_secure.rs b/prudpv1/src/executables/proxy_secure.rs index 6bf3434..2e79317 100644 --- a/prudpv1/src/executables/proxy_secure.rs +++ b/prudpv1/src/executables/proxy_secure.rs @@ -1,30 +1,20 @@ -use crate::executables::common::{EDGE_NODE_HOLDER, FORWARD_DESTINATION}; use crate::prudp::router::Router; use crate::prudp::secure::Secure; use log::error; -use rnex_core::common::setup; -use rnex_core::executables::common::{ - OWN_IP_PRIVATE, OWN_IP_PUBLIC, SECURE_SERVER_ACCOUNT, SERVER_PORT, -}; +use proxy_common::{ProxyStartupParam, RNEX_ACCESS_KEY}; +use rnex_core::executables::common::SECURE_SERVER_ACCOUNT; use rnex_core::prudp::virtual_port::VirtualPort; -use rnex_core::reggie::EdgeNodeHolderConnectOption::Register; -use rnex_core::reggie::RemoteEdgeNodeHolder; use rnex_core::reggie::UnitPacketRead; use rnex_core::reggie::UnitPacketWrite; -use rnex_core::rmc::protocols::{OnlyRemote, new_rmc_gateway_connection}; use rnex_core::rmc::structures::RmcSerialize; use rnex_core::rnex_proxy_common::ConnectionInitData; -use rnex_core::util::SplittableBufferConnection; -use std::net::SocketAddrV4; -use std::sync::Arc; use std::time::Duration; use tokio::net::TcpStream; use tokio::task; use tokio::time::sleep; -use proxy_common::RNEX_ACCESS_KEY; -pub async fn start() { - let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)) +pub async fn start(param: ProxyStartupParam) { + let (router_secure, _) = Router::new(param.self_private) .await .expect("unable to start router"); @@ -36,8 +26,6 @@ pub async fn start() { .await .expect("unable to add socket"); - // let conn = socket_secure.connect(auth_sockaddr).await.unwrap(); - loop { let Some(mut conn) = socket_secure.accept().await else { error!("server crashed"); @@ -45,7 +33,7 @@ pub async fn start() { }; task::spawn(async move { - let mut stream = match TcpStream::connect(*FORWARD_DESTINATION).await { + let mut stream = match TcpStream::connect(param.forward_destination).await { Ok(v) => v, Err(e) => { error!("unable to connect: {}", e); diff --git a/prudpv1/src/lib.rs b/prudpv1/src/lib.rs index 0660a4b..a24f714 100644 --- a/prudpv1/src/lib.rs +++ b/prudpv1/src/lib.rs @@ -1,14 +1,14 @@ cfg_if::cfg_if! { if #[cfg(feature = "prudpv1")]{ - use proxy_common::{ProxyStartupParam, setup_edge_node_connection}; + use proxy_common::ProxyStartupParam; pub mod executables; pub mod prudp; pub async fn start_secure(param: ProxyStartupParam) { - executables::proxy_secure::start().await; + executables::proxy_secure::start(param).await; } pub async fn start_insecure(param: ProxyStartupParam) { - executables::proxy_insecure::start().await; + executables::proxy_insecure::start(param).await; } } } diff --git a/prudpv1/src/prudp/packet.rs b/prudpv1/src/prudp/packet.rs index 5a27d33..60e3feb 100644 --- a/prudpv1/src/prudp/packet.rs +++ b/prudpv1/src/prudp/packet.rs @@ -14,7 +14,7 @@ use rnex_core::prudp::socket_addr::PRUDPSockAddr; use rnex_core::prudp::types_flags::TypesFlags; use rnex_core::prudp::types_flags::flags::ACK; use rnex_core::prudp::virtual_port::VirtualPort; -use std::fmt::{Debug, Formatter}; +use std::fmt::Debug; use std::io; use std::io::{Cursor, Read, Seek, Write}; use std::net::SocketAddr; diff --git a/prudpv1/src/prudp/secure.rs b/prudpv1/src/prudp/secure.rs index 9bd441b..c7d312f 100644 --- a/prudpv1/src/prudp/secure.rs +++ b/prudpv1/src/prudp/secure.rs @@ -1,18 +1,13 @@ use crate::prudp::packet::PRUDPV1Packet; use crate::prudp::socket::{CryptoHandler, CryptoHandlerConnectionInstance}; use hmac::digest::consts::U32; -use log::error; use rc4::cipher::StreamCipherCoreWrapper; -use rc4::consts::U16; use rc4::{KeyInit, Rc4, Rc4Core, StreamCipher}; -use rnex_core::kerberos::{TicketInternalData, derive_key}; use rnex_core::nex::account::Account; use rnex_core::prudp::encryption::EncryptionPair; use rnex_core::prudp::ticket::read_secure_connection_data; use rnex_core::rmc::structures::RmcSerialize; -use std::io::Cursor; use typenum::U5; -use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions}; type Rc4U32 = StreamCipherCoreWrapper>; @@ -52,6 +47,7 @@ pub struct SecureInstance { session_key: [u8; 32], streams: Vec>>, self_signature: [u8; 16], + #[allow(dead_code)] remote_signature: [u8; 16], pid: u32, } diff --git a/prudpv1/src/prudp/unsecure.rs b/prudpv1/src/prudp/unsecure.rs index d47550f..79cc908 100644 --- a/prudpv1/src/prudp/unsecure.rs +++ b/prudpv1/src/prudp/unsecure.rs @@ -1,7 +1,6 @@ use crate::prudp::packet::PRUDPV1Packet; use crate::prudp::socket::{CryptoHandler, CryptoHandlerConnectionInstance}; -use once_cell::sync::Lazy; -use rc4::{Key, KeyInit, Rc4, StreamCipher}; +use rc4::{KeyInit, Rc4, StreamCipher}; use rnex_core::prudp::encryption::{DEFAULT_KEY, EncryptionPair}; use typenum::U5; @@ -11,6 +10,7 @@ pub struct UnsecureInstance { key: &'static str, streams: Vec>>, self_signature: [u8; 16], + #[allow(dead_code)] remote_signature: [u8; 16], } diff --git a/rnex-core/src/executables/backend_server_secure.rs b/rnex-core/src/executables/backend_server_secure.rs index 5ec36f1..9d5268d 100644 --- a/rnex-core/src/executables/backend_server_secure.rs +++ b/rnex-core/src/executables/backend_server_secure.rs @@ -1,6 +1,5 @@ use cfg_if::cfg_if; use rnex_core::common::setup; -use rnex_core::executables::friends_backend::start_friends_backend; #[tokio::main] async fn main() { @@ -8,6 +7,7 @@ async fn main() { cfg_if! { if #[cfg(feature = "friends")]{ + use rnex_core::executables::friends_backend::start_friends_backend; start_friends_backend().await; } else { use rnex_core::executables::regular_backend;