From 9275f3b09f4ed824ff3bc9b4531f815bb28140e9 Mon Sep 17 00:00:00 2001 From: Maple Date: Sun, 26 Apr 2026 23:20:42 +0200 Subject: [PATCH] restrict what gets checked and implement sending of fragmented packets --- check-all.sh | 11 +++-- editions.yaml | 4 ++ prudpv1/src/prudp/socket.rs | 47 +++++++++++-------- rnex-core/src/executables/common.rs | 7 +-- rnex-core/src/nex/user.rs | 4 +- rnex-core/src/rmc/protocols/datastore.rs | 60 +++++++++++++++++------- 6 files changed, 86 insertions(+), 47 deletions(-) diff --git a/check-all.sh b/check-all.sh index d6281ab..1494e10 100755 --- a/check-all.sh +++ b/check-all.sh @@ -2,9 +2,12 @@ set -euo pipefail -SETTINGS=$(yq ea "." editions.yaml | yq 'keys[]') +EDITIONS=$(yq ea "." editions.yaml | yq 'keys[]') IFS=$'\n' while IFS=$'\n' read -r EDITION; do - export EDITION - ./check-edition.sh $EDITION -done <<< "$SETTINGS" + if [[ $(yq ea ".$EDITION.include-in-checkall" editions.yaml) == "true" ]] + then + export EDITION + ./check-edition.sh $EDITION + fi +done <<< "$EDITIONS" diff --git a/editions.yaml b/editions.yaml index 632274f..3801571 100644 --- a/editions.yaml +++ b/editions.yaml @@ -1,4 +1,5 @@ wiiu-chat: + include-in-checkall: true features: - prudpv1 - v3-8-15 @@ -9,6 +10,7 @@ wiiu-chat: RNEX_DEFAULT_PORT: 10000 RNEX_ACCESS_KEY: "e7a47214" splatoon: + include-in-checkall: true features: - prudpv1 - v3-8-15 @@ -19,6 +21,7 @@ splatoon: RNEX_DEFAULT_PORT: 6000 RNEX_ACCESS_KEY: "6f599f81" friends: + include-in-checkall: false features: - friends settings: @@ -28,6 +31,7 @@ friends: RNEX_DEFAULT_PORT: 6000 RNEX_ACCESS_KEY: "ridfebb9" super-mario-maker: + include-in-checkall: false features: - prudpv1 - v3-8-15 diff --git a/prudpv1/src/prudp/socket.rs b/prudpv1/src/prudp/socket.rs index a3b0445..c04f106 100644 --- a/prudpv1/src/prudp/socket.rs +++ b/prudpv1/src/prudp/socket.rs @@ -177,31 +177,40 @@ pub(super) trait AnyInternalConnection: #[async_trait] impl AnyInternalConnection for InternalConnection { async fn send_data_packet(&mut self, data: Vec) { - let mut packet = PRUDPV1Packet { - header: PRUDPV1Header { - sequence_id: self.next_server_count(), - substream_id: 0, - session_id: self.session_id, - types_and_flags: TypesFlags::default().types(DATA).flags(RELIABLE | NEED_ACK), - destination_port: self.common.socket_addr.virtual_port, - source_port: self.server_port, + let pieces = data.chunks(600); + let max_piece = pieces.len() - 1; + let mut piece_num = 1; + for (i, piece) in pieces.enumerate() { + let mut packet = PRUDPV1Packet { + header: PRUDPV1Header { + sequence_id: self.next_server_count(), + substream_id: 0, + session_id: self.session_id, + types_and_flags: TypesFlags::default().types(DATA).flags(RELIABLE | NEED_ACK), + destination_port: self.common.socket_addr.virtual_port, + source_port: self.server_port, + ..Default::default() + }, + payload: piece.to_owned(), + options: vec![FragmentId(if i == max_piece { 0 } else { piece_num })], ..Default::default() - }, - payload: data, - options: vec![FragmentId(0)], - ..Default::default() - }; + }; - self.crypto_handler_instance - .encrypt_outgoing(0, &mut packet.payload[..]); + self.crypto_handler_instance + .encrypt_outgoing(0, &mut packet.payload[..]); - packet.set_sizes(); + packet.set_sizes(); - self.crypto_handler_instance.sign_packet(&mut packet); + self.crypto_handler_instance.sign_packet(&mut packet); - self.send_raw_packet(&packet).await; + self.send_raw_packet(&packet).await; - self.unacknowleged_packets.push((Instant::now(), packet)); + self.unacknowleged_packets.push((Instant::now(), packet)); + + sleep(Duration::from_secs(16)).await; + + piece_num += 1; + } } async fn close_connection(&mut self) { diff --git a/rnex-core/src/executables/common.rs b/rnex-core/src/executables/common.rs index 280ab7f..b2ea50d 100644 --- a/rnex-core/src/executables/common.rs +++ b/rnex-core/src/executables/common.rs @@ -8,18 +8,15 @@ use std::io::Cursor; use std::net::{Ipv4Addr, SocketAddrV4}; use std::sync::Arc; use tokio::net::TcpListener; -use std::sync::LazyLock; -use std::sync::OnceLock; cfg_if! { if #[cfg(feature = "datastore")] { use sqlx::postgres::PgPool; } } +use crate::reggie::UnitPacketRead; +use cfg_if::cfg_if; use log::error; use std::error::Error; -use std::string::ToString; -use cfg_if::cfg_if; -use crate::reggie::UnitPacketRead; const IP_REQ_SERVICE_URL: &str = "https://ipinfo.io/ip"; diff --git a/rnex-core/src/nex/user.rs b/rnex-core/src/nex/user.rs index ed8a76f..757bb72 100644 --- a/rnex-core/src/nex/user.rs +++ b/rnex-core/src/nex/user.rs @@ -23,7 +23,6 @@ use rnex_core::rmc::protocols::matchmake_extension::{ }; use rnex_core::rmc::protocols::ranking::{Ranking, RawRanking, RawRankingInfo, RemoteRanking}; use rnex_core::rmc::protocols::secure::{RawSecure, RawSecureInfo, RemoteSecure, Secure}; -use rnex_core::rmc::protocols::datastore::{DataStore, RawDataStore, RawDataStoreInfo, RemoteDataStore}; use rnex_core::rmc::response::ErrorCode; use rnex_core::rmc::structures::any::Any; use rnex_core::rmc::structures::matchmake::{ @@ -34,6 +33,7 @@ use std::env; use std::str::FromStr; use crate::rmc::protocols::notifications::{NotificationEvent, RemoteNotification}; +use cfg_if::cfg_if; use log::{error, info}; use macros::rmc_struct; use rnex_core::prudp::socket_addr::PRUDPSockAddr; @@ -45,11 +45,11 @@ use rnex_core::rmc::structures::qbuffer::QBuffer; use rnex_core::rmc::structures::qresult::QResult; use rnex_core::rmc::structures::ranking::UploadCompetitionData; use std::sync::{Arc, Weak}; -use cfg_if::cfg_if; use tokio::sync::{Mutex, RwLock}; cfg_if! { if #[cfg(feature = "datastore")] { + use rnex_core::rmc::protocols::datastore::{DataStore, RawDataStore, RawDataStoreInfo, RemoteDataStore}; define_rmc_proto!( proto UserProtocol{ Secure, diff --git a/rnex-core/src/rmc/protocols/datastore.rs b/rnex-core/src/rmc/protocols/datastore.rs index 0c68fc5..51d5365 100644 --- a/rnex-core/src/rmc/protocols/datastore.rs +++ b/rnex-core/src/rmc/protocols/datastore.rs @@ -1,9 +1,9 @@ -use macros::{method_id, rmc_proto, RmcSerialize, rmc_struct}; -use rnex_core::rmc::structures::qbuffer::QBuffer; -use rnex_core::rmc::response::ErrorCode; -use rnex_core::rmc::structures::qresult::QResult; -use rnex_core::kerberos::KerberosDateTime; +use macros::{RmcSerialize, method_id, rmc_proto}; use rnex_core::PID; +use rnex_core::kerberos::KerberosDateTime; +use rnex_core::rmc::response::ErrorCode; +use rnex_core::rmc::structures::qbuffer::QBuffer; +use rnex_core::rmc::structures::qresult::QResult; use rnex_core::rmc::structures::resultsrange::ResultsRange; #[derive(RmcSerialize, Clone, Debug, Default)] @@ -78,7 +78,7 @@ pub struct RatingInitParam { pub range_min: i32, pub range_max: i32, pub period_hour: i8, - pub period_duration: i16 + pub period_duration: i16, } #[derive(RmcSerialize, Clone)] @@ -214,27 +214,53 @@ pub struct DataStoreSearchParam { } #[rmc_proto(115)] -pub trait DataStore{ +pub trait DataStore { #[method_id(8)] async fn get_meta(&self, metaparam: GetMetaParam) -> Result; #[method_id(36)] - async fn get_metas_multiple_param(&self, params: Vec) -> Result<(Vec, Vec), ErrorCode>; + async fn get_metas_multiple_param( + &self, + params: Vec, + ) -> Result<(Vec, Vec), ErrorCode>; #[method_id(24)] - async fn prepare_post_object(&self, postparam: PreparePostParam) -> Result; + async fn prepare_post_object( + &self, + postparam: PreparePostParam, + ) -> Result; #[method_id(26)] - async fn complete_post_object(&self, completeparam: CompletePostParam) -> Result<(), ErrorCode>; + async fn complete_post_object(&self, completeparam: CompletePostParam) + -> Result<(), ErrorCode>; #[method_id(48)] - async fn rate_custom_ranking(&self, rankingparam: Vec) -> Result<(), ErrorCode>; + async fn rate_custom_ranking( + &self, + rankingparam: Vec, + ) -> Result<(), ErrorCode>; #[method_id(61)] async fn get_application_config(&self, appid: u32) -> Result, ErrorCode>; #[method_id(50)] - async fn get_custom_ranking_by_data_id(&self, custom_ranking_param: DataStoreGetCustomRankingByDataIDParam) -> Result<(Vec, Vec), ErrorCode>; + async fn get_custom_ranking_by_data_id( + &self, + custom_ranking_param: DataStoreGetCustomRankingByDataIDParam, + ) -> Result<(Vec, Vec), ErrorCode>; #[method_id(54)] - async fn get_buffer_queue(&self, bufferparam: BufferQueueParam) -> Result, ErrorCode>; + async fn get_buffer_queue( + &self, + bufferparam: BufferQueueParam, + ) -> Result, ErrorCode>; #[method_id(25)] - async fn prepare_get_object(&self, prepare_get_param: DataStorePrepareGetParam) -> Result; + async fn prepare_get_object( + &self, + prepare_get_param: DataStorePrepareGetParam, + ) -> Result; #[method_id(65)] - async fn followings_latest_course_search_object(&self, course_search_param: DataStoreSearchParam, extra_data: Vec) -> Result, ErrorCode>; + async fn followings_latest_course_search_object( + &self, + course_search_param: DataStoreSearchParam, + extra_data: Vec, + ) -> Result, ErrorCode>; #[method_id(74)] - async fn get_application_config_string(&self, application_id: u32) -> Result, ErrorCode>; -} \ No newline at end of file + async fn get_application_config_string( + &self, + application_id: u32, + ) -> Result, ErrorCode>; +}