friends stub
All checks were successful
Build and Test / minecraft-wiiu (push) Successful in 3m44s
Build and Test / puyopuyo (push) Successful in 3m44s
Build and Test / wii-sports-club (push) Successful in 3m45s
Build and Test / wii-u-chat (push) Successful in 3m45s
Build and Test / fast-racing-neo (push) Successful in 3m54s
Build and Test / mario-tennis (push) Successful in 3m55s
Build and Test / sonic-transformed (push) Successful in 3m59s
Build and Test / splatoon-testfire (push) Successful in 3m58s
Build and Test / splatoon (push) Successful in 3m59s
Build and Test / friends (push) Successful in 4m15s
Build and Test / super-mario-maker (push) Successful in 4m15s

This commit is contained in:
Maple Nebel 2026-06-08 11:33:30 +02:00
commit 7441342c5f
4 changed files with 175 additions and 35 deletions

View file

@ -5,23 +5,24 @@ use rnex_core::common::setup;
async fn main() {
setup();
#[cfg(feature = "database-support")]
{
use rnex_core::executables::common::DB_POOL;
use sqlx::PgPool;
let database_url = std::env::var("RNEX_DATASTORE_DATABASE_URL")
.expect("RNEX_DATASTORE_DATABASE_URL must be set");
let pool = PgPool::connect(&database_url)
.await
.expect("Failed to create pool");
DB_POOL.set(pool).expect("failed to set global DB_POOL");
}
cfg_if! {
if #[cfg(feature = "friends")]{
use rnex_core::executables::friends_backend::start_friends_backend;
start_friends_backend().await;
} else if #[cfg(feature = "datastore")] {
use rnex_core::executables::common::DB_POOL;
use sqlx::PgPool;
let database_url = std::env::var("RNEX_DATASTORE_DATABASE_URL")
.expect("RNEX_DATASTORE_DATABASE_URL must be set");
let pool = PgPool::connect(&database_url)
.await
.expect("Failed to create pool");
DB_POOL.set(pool).expect("failed to set global DB_POOL");
use rnex_core::executables::regular_backend;
regular_backend::start_regular_backend().await
} else {
use rnex_core::executables::regular_backend;
regular_backend::start_regular_backend().await

View file

@ -1,23 +1,18 @@
use crate::reggie::UnitPacketRead;
use cfg_if::cfg_if;
use log::error;
use once_cell::sync::Lazy;
use rnex_core::nex::account::Account;
use rnex_core::rmc::protocols::{RmcCallable, RmcConnection, new_rmc_gateway_connection};
use rnex_core::rmc::structures::RmcSerialize;
use rnex_core::rnex_proxy_common::ConnectionInitData;
use std::env;
use std::error::Error;
use std::fmt::Display;
use std::io::{Cursor, Read, Write};
use std::net::{Ipv4Addr, SocketAddrV4, TcpStream};
use std::sync::Arc;
use tokio::net::TcpListener;
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;
const IP_REQ_SERVICE_URLS: &[(&str, &str, &str)] = &[
("ipinfo.io:80", "ipinfo.io", "/ip"),
@ -30,11 +25,12 @@ const IP_REQ_SERVICE_URLS: &[(&str, &str, &str)] = &[
];
cfg_if! {
if #[cfg(feature = "datastore")] {
if #[cfg(feature = "database-support")] {
use std::sync::{LazyLock, OnceLock};
pub static RNEX_DATASTORE_DATABASE_URL: LazyLock<String> = LazyLock::new(|| {
std::env::var("RNEX_DATASTORE_DATABASE_URL")
.expect("RNEX_DATASTORE_DATABASE_URL must be set")
use sqlx::postgres::PgPool;
pub static RNEX_DATABASE_URL: LazyLock<String> = LazyLock::new(|| {
std::env::var("RNEX_DATABASE_URL")
.expect("RNEX_DATABASE_URL must be set")
});
pub static DB_POOL: OnceLock<PgPool> = OnceLock::new();
@ -42,6 +38,10 @@ cfg_if! {
pub fn get_db() -> &'static PgPool {
DB_POOL.get().expect("db_pool not initialized")
}
}
}
cfg_if! {
if #[cfg(feature = "datastore")]{
pub static RNEX_DATASTORE_S3_ENDPOINT: LazyLock<String> = LazyLock::new(|| {
std::env::var("RNEX_DATASTORE_S3_ENDPOINT")
.expect("RNEX_DATASTORE_S3_ENDPOINT must be set")

View file

@ -10,7 +10,9 @@ use macros::rmc_struct;
use rnex_core::rmc::protocols::account_management::{
AccountManagement, RawAccountManagement, RawAccountManagementInfo, RemoteAccountManagement,
};
use rnex_core::rmc::protocols::friends::{Friends, RawFriends, RawFriendsInfo, RemoteFriends};
use rnex_core::rmc::protocols::friends_wiiu::{
FriendsWiiU, RawFriendsWiiU, RawFriendsWiiUInfo, RemoteFriendsWiiU,
};
use rnex_core::rmc::protocols::nintendo_notification::{
NintendoNotification, RawNintendoNotification, RawNintendoNotificationInfo,
RemoteNintendoNotification,
@ -22,9 +24,9 @@ use rnex_core::{
nex::common::get_station_urls,
prudp::{socket_addr::PRUDPSockAddr, station_url::StationUrl},
rmc::{
protocols::friends::{
protocols::friends_wiiu::{
BlacklistedPrincipal, Comment, FriendInfo, FriendRequest, NNAInfo, NintendoPresenceV2,
PersistentNotification, PrincipalPreference,
PersistentNotification, PrincipalPreference, PrincipalRequestBlockSetting,
},
response::ErrorCode,
structures::{any::Any, qresult::QResult},
@ -34,7 +36,7 @@ use std::sync::atomic::Ordering::Relaxed;
use tokio::spawn;
use tokio::sync::RwLock;
use rnex_core::rmc::protocols::friends::{GameKey, MiiV2, PrincipalBasicInfo};
use rnex_core::rmc::protocols::friends_wiiu::{GameKey, MiiV2, PrincipalBasicInfo};
use rnex_core::PID;
@ -47,7 +49,7 @@ use rnex_core::rmc::structures::data::Data;
define_rmc_proto!(
proto FriendsUser{
Secure,
Friends
FriendsWiiU
}
);
define_rmc_proto!(
@ -112,7 +114,7 @@ pub fn friend_info_from_user(data: &UserData) -> FriendInfo {
}
}
impl Friends for FriendsUser {
impl FriendsWiiU for FriendsUser {
async fn update_and_get_all_information(
&self,
info: NNAInfo,
@ -320,8 +322,8 @@ impl Friends for FriendsUser {
async fn check_setting_status(&self) -> Result<u8, ErrorCode> {
Ok(0xFF)
}
async fn update_preference(&self, preference: PrincipalPreference) -> Result<(),ErrorCode> {
async fn update_preference(&self, preference: PrincipalPreference) -> Result<(), ErrorCode> {
info!("user updated preference: {:?}", preference);
let any_presence: Any = Any::new(&preference).expect("out of memory");
@ -337,9 +339,87 @@ impl Friends for FriendsUser {
.await;
}
drop(users);
Ok(())
}
async fn add_friend(&self, friend: PID) -> Result<(FriendRequest, FriendInfo), ErrorCode> {
todo!()
}
async fn add_friend_by_name(
&self,
name: String,
) -> Result<(FriendRequest, FriendInfo), ErrorCode> {
todo!()
}
async fn remove_friend(&self, friend: PID) -> Result<(), ErrorCode> {
todo!()
}
async fn add_friend_request(
&self,
friend: PID,
unk1: u8,
message: String,
unk2: u8,
unk3: String,
game_key: GameKey,
unk4: KerberosDateTime,
) -> Result<(FriendRequest, FriendInfo), ErrorCode> {
todo!()
}
async fn cancel_friend_request(&self, id: u64) -> Result<(), ErrorCode> {
todo!()
}
async fn accept_friend_request(&self, id: u64) -> Result<FriendInfo, ErrorCode> {
todo!()
}
async fn delete_friend_request(&self, id: u64) -> Result<(), ErrorCode> {
todo!()
}
async fn deny_friend_request(&self, id: u64) -> Result<BlacklistedPrincipal, ErrorCode> {
todo!()
}
async fn mark_friend_requests_as_received(&self, ids: Vec<u64>) -> Result<(), ErrorCode> {
todo!()
}
async fn add_blacklist(
&self,
principal: BlacklistedPrincipal,
) -> Result<BlacklistedPrincipal, ErrorCode> {
todo!()
}
async fn remove_blacklist(&self, id: PID) -> Result<(), ErrorCode> {
todo!()
}
async fn update_mii(&self, presence: MiiV2) -> Result<KerberosDateTime, ErrorCode> {
todo!()
}
async fn update_comment(&self, presence: Comment) -> Result<KerberosDateTime, ErrorCode> {
todo!()
}
async fn get_basic_info(&self, pids: Vec<PID>) -> Result<Vec<PrincipalBasicInfo>, ErrorCode> {
todo!()
}
async fn get_request_block_settings(
&self,
unk: Vec<u32>,
) -> Result<Vec<PrincipalRequestBlockSetting>, ErrorCode> {
todo!()
}
}
type HMacMd5 = hmac::Hmac<md5::Md5>;

View file

@ -4,6 +4,8 @@ use rnex_core::{kerberos::KerberosDateTime, rmc::response::ErrorCode};
use rnex_core::rmc::structures::data::Data;
use rnex_core::PID;
#[derive(RmcSerialize, Debug, Clone)]
#[rmc_struct(0)]
pub struct MiiV2 {
@ -147,6 +149,15 @@ pub struct PersistentNotification {
pub unk5: String,
}
#[derive(RmcSerialize)]
#[rmc_struct(0)]
pub struct PrincipalRequestBlockSetting {
#[extends]
pub data: Data,
pub pid: PID,
pub blocked: bool,
}
#[rmc_proto(102)]
pub trait FriendsWiiU {
#[method_id(1)]
@ -169,10 +180,53 @@ pub trait FriendsWiiU {
),
ErrorCode,
>;
#[method_id(2)]
async fn add_friend(&self, friend: PID) -> Result<(FriendRequest, FriendInfo), ErrorCode>;
#[method_id(3)]
async fn add_friend_by_name(
&self,
name: String,
) -> Result<(FriendRequest, FriendInfo), ErrorCode>;
#[method_id(4)]
async fn remove_friend(&self, friend: PID) -> Result<(), ErrorCode>;
#[method_id(5)]
async fn add_friend_request(
&self,
friend: PID,
unk1: u8,
message: String,
unk2: u8,
unk3: String,
game_key: GameKey,
unk4: KerberosDateTime,
) -> Result<(FriendRequest, FriendInfo), ErrorCode>;
#[method_id(6)]
async fn cancel_friend_request(&self, id: u64) -> Result<(), ErrorCode>;
#[method_id(7)]
async fn accept_friend_request(&self, id: u64) -> Result<FriendInfo, ErrorCode>;
#[method_id(8)]
async fn delete_friend_request(&self, id: u64) -> Result<(), ErrorCode>;
#[method_id(9)]
async fn deny_friend_request(&self, id: u64) -> Result<BlacklistedPrincipal, ErrorCode>;
#[method_id(10)]
async fn mark_friend_requests_as_received(&self, ids: Vec<u64>) -> Result<(), ErrorCode>;
#[method_id(11)]
async fn add_blacklist(
&self,
principal: BlacklistedPrincipal,
) -> Result<BlacklistedPrincipal, ErrorCode>;
#[method_id(12)]
async fn remove_blacklist(&self, id: PID) -> Result<(), ErrorCode>;
#[method_id(13)]
async fn update_presence(&self, presence: NintendoPresenceV2) -> Result<(), ErrorCode>;
#[method_id(14)]
async fn update_mii(&self, presence: MiiV2) -> Result<KerberosDateTime, ErrorCode>;
#[method_id(15)]
async fn update_comment(&self, presence: Comment) -> Result<KerberosDateTime, ErrorCode>;
#[method_id(16)]
async fn update_preference(&self, preference: PrincipalPreference) -> Result<(), ErrorCode>;
#[method_id(17)]
async fn get_basic_info(&self, pids: Vec<PID>) -> Result<Vec<PrincipalBasicInfo>, ErrorCode>;
#[method_id(18)]
async fn delete_persistent_notification(
&self,
@ -180,4 +234,9 @@ pub trait FriendsWiiU {
) -> Result<(), ErrorCode>;
#[method_id(19)]
async fn check_setting_status(&self) -> Result<u8, ErrorCode>;
#[method_id(20)]
async fn get_request_block_settings(
&self,
unk: Vec<u32>,
) -> Result<Vec<PrincipalRequestBlockSetting>, ErrorCode>;
}