fix warnings
Some checks failed
Build and Test / friends (push) Successful in 3m13s
Build and Test / splatoon (push) Failing after 4m27s

This commit is contained in:
Maple 2026-04-26 13:15:56 +02:00
commit a88f1898a5
24 changed files with 148 additions and 213 deletions

View file

@ -1,13 +1,6 @@
use cfg_if::cfg_if;
use rnex_core::common::setup;
use rnex_core::executables::common::new_simple_backend;
use rnex_core::executables::friends_backend::start_friends_backend;
use rnex_core::nex::matchmake::MatchmakeManager;
use rnex_core::nex::remote_console::RemoteConsole;
use rnex_core::nex::user::User;
use rnex_core::rmc::protocols::{RemoteDisconnectable, RmcPureRemoteObject};
use std::sync::Arc;
use std::sync::atomic::AtomicU32;
#[tokio::main]
async fn main() {

View file

@ -8,15 +8,11 @@ use log::error;
use tokio::net::TcpListener;
use crate::{
executables::common::{OWN_IP_PRIVATE, SERVER_PORT, new_simple_backend},
nex::friends_handler::{
FriendsGuest, FriendsManager, FriendsUser, RemoteFriendRemote, RemoteFriendsUser,
},
executables::common::{OWN_IP_PRIVATE, SERVER_PORT},
nex::friends_handler::{FriendsGuest, FriendsManager, FriendsUser, RemoteFriendRemote},
reggie::UnitPacketRead,
rmc::{
protocols::{
RmcCallable, RmcPureRemoteObject, friends::RemoteFriends, new_rmc_gateway_connection,
},
protocols::{RmcPureRemoteObject, new_rmc_gateway_connection},
structures::RmcSerialize,
},
rnex_proxy_common::ConnectionInitData,
@ -65,8 +61,8 @@ pub async fn start_friends_backend() {
})
});
} else {
new_rmc_gateway_connection(stream.into(), move |r| {
Arc::new_cyclic(move |this| FriendsGuest {
new_rmc_gateway_connection(stream.into(), move |_| {
Arc::new_cyclic(move |_| FriendsGuest {
fm,
addr: c.prudpsock_addr,
})

View file

@ -1,3 +1,10 @@
use cfg_if::cfg_if;
pub mod common;
pub mod friends_backend;
pub mod regular_backend;
cfg_if! {
if #[cfg(feature = "friends")]{
pub mod friends_backend;
} else {
pub mod regular_backend;
}
}

View file

@ -18,13 +18,13 @@ use rnex_core::PID;
cfg_if! {
if #[cfg(feature = "friends")]{
pub type SESSION_KEY_LENGTH_TY = U16;
pub type SessionLengthTy = U16;
} else {
use rc4::consts::U32;
pub type SESSION_KEY_LENGTH_TY = U32;
pub type SessionLengthTy = U32;
}
}
pub const SESSION_KEY_LENGTH: usize = SESSION_KEY_LENGTH_TY::USIZE;
pub const SESSION_KEY_LENGTH: usize = SessionLengthTy::USIZE;
type Md5Hmac = Hmac<md5::Md5>;

View file

@ -337,82 +337,3 @@ impl Auth for AuthHandler {
Err(ErrorCode::Core_Exception)
}
}
mod test {
use std::io::Cursor;
use rc4::{KeyInit, Rc4, StreamCipher};
use rnex_core::PID;
use rnex_core::kerberos::KerberosDateTime;
use rnex_core::rmc::structures::connection_data::ConnectionData;
use rnex_core::rmc::{
response::ErrorCode,
structures::{RmcSerialize, qresult::QResult},
};
use crate::kerberos::{self, derive_key};
use crate::rmc;
use crate::rmc::message::RMCMessage;
use crate::rmc::response::{RMCResponse, RMCResponseResult};
#[test]
fn test() {
return;
let packet = [
26, 1, 0, 0, 10, 1, 30, 0, 0, 0, 1, 128, 0, 0, 1, 0, 1, 0, 86, 4, 0, 0, 116, 0, 0, 0,
144, 209, 130, 175, 45, 215, 95, 55, 226, 192, 51, 54, 201, 84, 118, 150, 159, 164, 32,
103, 134, 252, 199, 168, 178, 5, 6, 208, 206, 241, 94, 23, 136, 37, 109, 247, 156, 252,
189, 233, 142, 115, 206, 72, 180, 57, 106, 223, 37, 59, 144, 208, 250, 197, 51, 202,
185, 156, 51, 159, 219, 117, 250, 103, 184, 1, 103, 108, 15, 14, 174, 160, 192, 146,
135, 10, 55, 125, 68, 181, 88, 127, 183, 34, 4, 213, 19, 146, 81, 56, 248, 213, 241,
168, 205, 253, 29, 10, 123, 198, 177, 157, 247, 209, 113, 167, 231, 42, 214, 15, 12,
200, 192, 230, 125, 227, 74, 0, 112, 114, 117, 100, 112, 115, 58, 47, 80, 73, 68, 61,
50, 59, 115, 105, 100, 61, 49, 59, 115, 116, 114, 101, 97, 109, 61, 49, 48, 59, 116,
121, 112, 101, 61, 50, 59, 97, 100, 100, 114, 101, 115, 115, 61, 57, 49, 46, 57, 56,
46, 49, 50, 56, 46, 56, 54, 59, 112, 111, 114, 116, 61, 54, 48, 48, 49, 59, 67, 73, 68,
61, 49, 0, 0, 0, 0, 0, 1, 0, 0, 162, 243, 240, 168, 31, 0, 0, 0, 51, 0, 98, 114, 97,
110, 99, 104, 58, 111, 114, 105, 103, 105, 110, 47, 112, 114, 111, 106, 101, 99, 116,
47, 119, 117, 112, 45, 97, 103, 109, 106, 32, 98, 117, 105, 108, 100, 58, 51, 95, 56,
95, 49, 53, 95, 50, 48, 48, 52, 95, 48, 0,
];
let rmc_packet = RMCResponse::new(&mut Cursor::new(&packet)).unwrap();
println!("{:?}", rmc_packet);
let RMCResponseResult::Success {
call_id,
method_id,
data,
} = rmc_packet.response_result
else {
panic!();
};
println!("{}", hex::encode(&data));
let mut data =
<(QResult, PID, Vec<u8>, ConnectionData, String) as RmcSerialize>::deserialize(
&mut Cursor::new(&data[..]),
)
.unwrap();
println!("{:?}", data);
let key = derive_key(1110, "AAAAAAAAAAAAAAAA".as_bytes());
let mut rc4 = Rc4::new((&key).into());
rc4.apply_keystream(&mut data.2);
println!("raw tick: {:?}", data.2);
let tick: &kerberos::Ticket =
bytemuck::from_bytes(&data.2[..size_of::<kerberos::Ticket>()]);
let remainder = &data.2[size_of::<kerberos::Ticket>()..];
println!("tick: {:?}", tick);
let data = <Vec<u8> as RmcSerialize>::deserialize(&mut Cursor::new(remainder)).unwrap();
println!("inner ticket raw: {:?}", data);
println!("{:?}", data);
}
}

View file

@ -312,7 +312,7 @@ impl Friends for FriendsUser {
async fn delete_persistent_notification(
&self,
notifs: Vec<PersistentNotification>,
_notifs: Vec<PersistentNotification>,
) -> Result<(), ErrorCode> {
Ok(())
}

View file

@ -1,7 +1,15 @@
use cfg_if::cfg_if;
pub mod account;
pub mod auth_handler;
pub mod common;
pub mod friends_handler;
pub mod matchmake;
pub mod remote_console;
pub mod user;
cfg_if! {
if #[cfg(feature = "friends")]{
pub mod friends_handler;
} else {
pub mod matchmake;
pub mod remote_console;
pub mod user;
}
}

View file

@ -6,7 +6,7 @@ use typenum::U16;
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
use crate::{
kerberos::{SESSION_KEY_LENGTH, SESSION_KEY_LENGTH_TY, TicketInternalData, derive_key},
kerberos::{SESSION_KEY_LENGTH, SessionLengthTy, TicketInternalData, derive_key},
nex::account::Account,
rmc::structures::RmcSerialize,
};
@ -53,7 +53,7 @@ pub fn read_secure_connection_data(
let request_data_length = request_data.len();
let request_data = &mut request_data[0..request_data_length - 0x10];
let mut rc4: StreamCipherCoreWrapper<Rc4Core<SESSION_KEY_LENGTH_TY>> =
let mut rc4: StreamCipherCoreWrapper<Rc4Core<SessionLengthTy>> =
Rc4::new_from_slice(&session_key).expect("unable to init rc4 keystream");
rc4.apply_keystream(request_data);

View file

@ -1,8 +1,5 @@
use bytemuck::{Pod, Zeroable};
use std::{
fmt::{Debug, Formatter},
slice,
};
use std::fmt::{Debug, Formatter};
use v_byte_helpers::SwapEndian;
#[repr(transparent)]

View file

@ -8,11 +8,11 @@ use rnex_core::rmc::structures::qresult::QResult;
cfg_if! {
if #[cfg(feature = "nx")]{
type LOGIN_EX_RET = (QResult, PID, Vec<u8>, ConnectionData, String, String);
type REQUEST_TICKET_RET = (QResult, Vec<u8>, String);
type LoginExRet = (QResult, PID, Vec<u8>, ConnectionData, String, String);
type RequestTicketRet = (QResult, Vec<u8>, String);
} else {
type LOGIN_EX_RET = (QResult, PID, Vec<u8>, ConnectionData, String);
type REQUEST_TICKET_RET = (QResult, Vec<u8>);
type LoginExRet = (QResult, PID, Vec<u8>, ConnectionData, String);
type RequestTicketRet = (QResult, Vec<u8>);
}
}
@ -31,14 +31,14 @@ pub trait Auth {
/// representation of the `LoginEx` method(for details see the
/// [kinnay wiki entry](https://github.com/kinnay/NintendoClients/wiki/Authentication-Protocol))
#[method_id(2)]
async fn login_ex(&self, name: String, extra_data: Any) -> Result<LOGIN_EX_RET, ErrorCode>;
async fn login_ex(&self, name: String, extra_data: Any) -> Result<LoginExRet, ErrorCode>;
#[method_id(3)]
async fn request_ticket(
&self,
source_pid: PID,
destination_pid: PID,
) -> Result<REQUEST_TICKET_RET, ErrorCode>;
) -> Result<RequestTicketRet, ErrorCode>;
/// representation of the `RequestTicket` method(for details see the
/// [kinnay wiki entry](https://github.com/kinnay/NintendoClients/wiki/Authentication-Protocol))

View file

@ -2,7 +2,7 @@ use macros::{RmcSerialize, method_id, rmc_proto};
use rnex_core::{kerberos::KerberosDateTime, rmc::response::ErrorCode};
use rnex_core::rmc::structures::{data::Data, rmc_struct};
use rnex_core::rmc::structures::data::Data;
#[derive(RmcSerialize, Debug, Clone)]
#[rmc_struct(0)]

View file

@ -1,4 +1,4 @@
use macros::{RmcSerialize, method_id, rmc_proto, rmc_struct};
use macros::{RmcSerialize, method_id, rmc_proto};
use rnex_core::PID;

View file

@ -1,4 +1,4 @@
use macros::{rmc_struct, rmc_proto, RmcSerialize, method_id};
use macros::{RmcSerialize, method_id, rmc_proto};
use rnex_core::kerberos::KerberosDateTime;
use rnex_core::rmc::structures::qbuffer::QBuffer;
@ -8,9 +8,9 @@ use rnex_core::rmc::structures::ranking::UploadCompetitionData;
#[derive(RmcSerialize, Debug, Default, Clone)]
#[rmc_struct(0)]
pub struct ResultsRange{
pub struct ResultsRange {
pub offset: u32,
pub size: u32
pub size: u32,
}
#[derive(RmcSerialize, Debug, Default, Clone)]
@ -23,29 +23,35 @@ pub struct CompetitionRankingGetParam {
#[derive(RmcSerialize, Debug, Default, Clone)]
#[rmc_struct(0)]
pub struct CompetitionRankingScoreInfo{
pub struct CompetitionRankingScoreInfo {
pub fest_id: u32,
pub score_data: Vec<CompetitionRankingScoreData>,
pub unk: u32,
pub team_wins: Vec<u32>,
pub team_votes: Vec<u32>
pub team_votes: Vec<u32>,
}
#[derive(RmcSerialize, Debug, Clone)]
#[rmc_struct(0)]
pub struct CompetitionRankingScoreData{
pub struct CompetitionRankingScoreData {
pub unk: u32,
pub pid: u32,
pub score: u32,
pub modified: KerberosDateTime,
pub unk2: u8,
pub appdata: QBuffer
pub appdata: QBuffer,
}
#[rmc_proto(112)]
pub trait Ranking{
pub trait Ranking {
#[method_id(16)]
async fn competition_ranking_get_param(&self, param: CompetitionRankingGetParam) -> Result<Vec<CompetitionRankingScoreInfo>,ErrorCode>;
async fn competition_ranking_get_param(
&self,
param: CompetitionRankingGetParam,
) -> Result<Vec<CompetitionRankingScoreInfo>, ErrorCode>;
#[method_id(18)]
async fn upload_competition_ranking_score(&self, param: UploadCompetitionData) -> Result<bool, ErrorCode>;
async fn upload_competition_ranking_score(
&self,
param: UploadCompetitionData,
) -> Result<bool, ErrorCode>;
}