fix port binding

This commit is contained in:
Maple 2026-03-24 15:48:56 +01:00
commit 785341e883
43 changed files with 1543 additions and 431 deletions

View file

@ -0,0 +1,14 @@
use rnex_core::PID;
use crate::crypto::Crypto;
pub struct Insecure;
impl Crypto for Insecure {
fn new_connection(&self, data: &[u8]) -> Option<(PID, Vec<u8>)> {
Some((100, vec![]))
}
fn new() -> Self {
Self
}
}

View file

@ -0,0 +1,9 @@
use rnex_core::PID;
pub mod insecure;
pub mod secure;
pub trait Crypto: 'static + Send + Sync {
fn new_connection(&self, data: &[u8]) -> Option<(PID, Vec<u8>)>;
fn new() -> Self;
}

View file

@ -0,0 +1,27 @@
use rnex_core::{
PID, executables::common::SECURE_SERVER_ACCOUNT, nex::account::Account,
prudp::ticket::read_secure_connection_data, rmc::structures::RmcSerialize,
};
use crate::crypto::Crypto;
pub struct Secure(&'static Account);
impl Crypto for Secure {
fn new_connection(&self, data: &[u8]) -> Option<(PID, Vec<u8>)> {
let (_, pid, check_value) = read_secure_connection_data(data, &self.0)?;
let check_value_response = check_value + 1;
let data = bytemuck::bytes_of(&check_value_response);
let mut response = Vec::new();
data.serialize(&mut response).ok()?;
Some((pid, response))
}
fn new() -> Self {
Self(&SECURE_SERVER_ACCOUNT)
}
}