From 45a3f7e637571258e6d07e02a3304dfce390ea71 Mon Sep 17 00:00:00 2001 From: Maple Nebel Date: Wed, 8 Jul 2026 01:51:27 +0200 Subject: [PATCH] more stuff --- rnex-core/src/kerberos/mod.rs | 37 +++++++++++++++++---- rnex-core/src/nex/friends_handler.rs | 16 +++++++-- rnex-core/src/rmc/protocols/friends_wiiu.rs | 12 +++---- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/rnex-core/src/kerberos/mod.rs b/rnex-core/src/kerberos/mod.rs index 87ef6fd..0d36c4c 100644 --- a/rnex-core/src/kerberos/mod.rs +++ b/rnex-core/src/kerberos/mod.rs @@ -9,6 +9,7 @@ use rc4::KeyInit; use rc4::cipher::StreamCipherCoreWrapper; use rc4::{Rc4, Rc4Core, StreamCipher}; use rnex_core::rmc::structures::RmcSerialize; +use std::fmt::Display; use std::io::{Read, Write}; use typenum::U16; use typenum::Unsigned; @@ -33,6 +34,21 @@ type Md5Hmac = Hmac; #[repr(transparent)] pub struct KerberosDateTime(pub u64); +impl Display for KerberosDateTime { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}.{}.{} {}:{}:{}", + self.get_year(), + self.get_month(), + self.get_days(), + self.get_hours(), + self.get_minutes(), + self.get_seconds() + ) + } +} + impl KerberosDateTime { // this is the time which smm returned as the expriy date, we use it as a // date so far into the future that it might as well just be never more generally @@ -86,13 +102,20 @@ impl KerberosDateTime { (self.0 >> 26) & 0xFFFFFFFF } pub fn to_regular_time(&self) -> chrono::DateTime { + let date = match NaiveDate::from_ymd_opt( + self.get_year() as i32, + self.get_month() as u32, + self.get_days() as u32, + ) { + Some(v) => v, + None => { + println!("invalid datetime...: {}", self); + Default::default() + } + }; + NaiveDateTime::new( - NaiveDate::from_ymd_opt( - self.get_year() as i32, - self.get_month() as u32, - self.get_days() as u32, - ) - .unwrap_or_default(), + date, NaiveTime::from_hms_opt( self.get_hours() as u32, self.get_minutes() as u32, @@ -106,7 +129,7 @@ impl KerberosDateTime { impl Default for KerberosDateTime { fn default() -> Self { - Self::now() + KerberosDateTime(0) } } diff --git a/rnex-core/src/nex/friends_handler.rs b/rnex-core/src/nex/friends_handler.rs index 06dd011..2b77319 100644 --- a/rnex-core/src/nex/friends_handler.rs +++ b/rnex-core/src/nex/friends_handler.rs @@ -627,7 +627,7 @@ impl FriendsWiiU for FriendsUser { .insert(self.pid, self.this.clone()); ::update_presence(self, presence).await?; - Ok(( + dbg!(Ok(( PrincipalPreference { data: Data {}, block_friend_request: query.principal_preference_block_friend_requests, @@ -649,7 +649,7 @@ impl FriendsWiiU for FriendsUser { // todo: persistent notifications vec![], false, - )) + ))) } async fn add_friend(&self, friend: PID) -> Result<(FriendRequest, FriendInfo), ErrorCode> { @@ -791,7 +791,17 @@ impl FriendsWiiU for FriendsUser { .await; } - Ok((fr, Default::default())) + Ok(( + fr, + FriendInfo { + presence: NintendoPresenceV2 { + game_key, + app_data: vec![0x00], + ..Default::default() + }, + ..Default::default() + }, + )) } async fn cancel_friend_request(&self, id: u64) -> Result<(), ErrorCode> { diff --git a/rnex-core/src/rmc/protocols/friends_wiiu.rs b/rnex-core/src/rmc/protocols/friends_wiiu.rs index 49ef1a0..1fc73cd 100644 --- a/rnex-core/src/rmc/protocols/friends_wiiu.rs +++ b/rnex-core/src/rmc/protocols/friends_wiiu.rs @@ -79,7 +79,7 @@ pub struct PrincipalPreference { pub block_friend_request: bool, } -#[derive(RmcSerialize, Default)] +#[derive(RmcSerialize, Default, Debug)] #[rmc_struct(0)] pub struct Comment { #[extends] @@ -89,7 +89,7 @@ pub struct Comment { pub last_changed: KerberosDateTime, } -#[derive(RmcSerialize, Default)] +#[derive(RmcSerialize, Default, Debug)] #[rmc_struct(0)] pub struct FriendInfo { #[extends] @@ -102,7 +102,7 @@ pub struct FriendInfo { pub unk: u64, } -#[derive(RmcSerialize)] +#[derive(RmcSerialize, Debug)] #[rmc_struct(0)] pub struct FriendRequestMessage { #[extends] @@ -118,7 +118,7 @@ pub struct FriendRequestMessage { pub expires_on: KerberosDateTime, } -#[derive(RmcSerialize)] +#[derive(RmcSerialize, Debug)] #[rmc_struct(0)] pub struct FriendRequest { #[extends] @@ -128,7 +128,7 @@ pub struct FriendRequest { pub sent_on: KerberosDateTime, } -#[derive(RmcSerialize)] +#[derive(RmcSerialize, Debug)] #[rmc_struct(0)] pub struct BlacklistedPrincipal { #[extends] @@ -137,7 +137,7 @@ pub struct BlacklistedPrincipal { pub game_key: GameKey, pub since: KerberosDateTime, } -#[derive(RmcSerialize)] +#[derive(RmcSerialize, Debug)] #[rmc_struct(0)] pub struct PersistentNotification { #[extends]