feat(secure): a lot of things
This commit is contained in:
parent
92c81e7126
commit
2b9f55e4d2
24 changed files with 435 additions and 98 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use std::io;
|
||||
use std::io::{Read, Seek};
|
||||
use std::io::{Read, Seek, Write};
|
||||
use bytemuck::bytes_of;
|
||||
use log::error;
|
||||
use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions};
|
||||
use crate::rmc::response::{ErrorCode, RMCResponseResult};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RMCMessage{
|
||||
pub protocol_id: u16,
|
||||
pub call_id: u32,
|
||||
|
|
@ -52,6 +53,23 @@ impl RMCMessage{
|
|||
})
|
||||
}
|
||||
|
||||
pub fn to_data(&self) -> Vec<u8>{
|
||||
let size = (1 + 4 + 4 + self.rest_of_data.len()) as u32;
|
||||
|
||||
let mut output = Vec::new();
|
||||
|
||||
output.write_all(bytes_of(&size)).expect("unable to write size");
|
||||
|
||||
let proto_id = self.protocol_id as u8;
|
||||
|
||||
output.write_all(bytes_of(&proto_id)).expect("unable to write size");
|
||||
|
||||
output.write_all(bytes_of(&self.call_id)).expect("unable to write size");
|
||||
output.write_all(bytes_of(&self.method_id)).expect("unable to write size");
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn error_result_with_code(&self, error_code: ErrorCode) -> RMCResponseResult{
|
||||
RMCResponseResult::Error {
|
||||
call_id: self.call_id,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::io;
|
||||
use std::io::{Write};
|
||||
use std::mem::transmute;
|
||||
use std::time::Duration;
|
||||
use bytemuck::bytes_of;
|
||||
use crate::prudp::packet::{PRUDPPacket};
|
||||
use crate::prudp::packet::flags::{NEED_ACK, RELIABLE};
|
||||
|
|
@ -100,6 +101,8 @@ pub async fn send_response(original_packet: &PRUDPPacket, socket: &SocketData, c
|
|||
|
||||
packet.payload = rmcresponse.to_data();
|
||||
|
||||
//tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
|
||||
connection.finish_and_send_packet_to(socket, packet).await;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::rmc::structures::RmcSerialize;
|
|||
|
||||
impl<T: RmcSerialize> RmcSerialize for Vec<T>{
|
||||
fn serialize(&self, writer: &mut dyn Write) -> crate::rmc::structures::Result<()> {
|
||||
let u32_len = self.len();
|
||||
let u32_len = self.len() as u32;
|
||||
|
||||
writer.write_all(bytes_of(&u32_len))?;
|
||||
for e in self{
|
||||
|
|
|
|||
|
|
@ -4,51 +4,82 @@ use crate::rmc::structures::RmcSerialize;
|
|||
use crate::rmc::structures::variant::Variant;
|
||||
|
||||
// rmc structure
|
||||
#[derive(RmcSerialize)]
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
struct Gathering{
|
||||
self_gid: u32,
|
||||
owner_pid: u32,
|
||||
host_pid: u32,
|
||||
minimum_participants: u16,
|
||||
maximum_participants: u16,
|
||||
participant_policy: u32,
|
||||
policy_argument: u32,
|
||||
flags: u32,
|
||||
state: u32,
|
||||
description: String
|
||||
pub struct Gathering {
|
||||
pub self_gid: u32,
|
||||
pub owner_pid: u32,
|
||||
pub host_pid: u32,
|
||||
pub minimum_participants: u16,
|
||||
pub maximum_participants: u16,
|
||||
pub participant_policy: u32,
|
||||
pub policy_argument: u32,
|
||||
pub flags: u32,
|
||||
pub state: u32,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
// rmc structure
|
||||
#[derive(RmcSerialize)]
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
struct MatchmakeParam{
|
||||
params: Vec<(String, Variant)>
|
||||
pub struct MatchmakeParam {
|
||||
pub params: Vec<(String, Variant)>,
|
||||
}
|
||||
|
||||
|
||||
// rmc structure
|
||||
#[derive(RmcSerialize)]
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(3)]
|
||||
struct MatchmakeSession{
|
||||
pub struct MatchmakeSession {
|
||||
//inherits from
|
||||
#[extends]
|
||||
gathering: Gathering,
|
||||
pub gathering: Gathering,
|
||||
|
||||
gamemode: u32,
|
||||
attributes: Vec<u32>,
|
||||
open_participation: bool,
|
||||
matchmake_system_type: u32,
|
||||
application_buffer: Vec<u8>,
|
||||
participation_count: u32,
|
||||
progress_score: u8,
|
||||
session_key: Vec<u8>,
|
||||
option0: u32,
|
||||
matchmake_param: MatchmakeParam,
|
||||
datetime: KerberosDateTime,
|
||||
user_password: String,
|
||||
refer_gid: u32,
|
||||
user_password_enabled: bool,
|
||||
system_password_enabled: bool
|
||||
pub gamemode: u32,
|
||||
pub attributes: Vec<u32>,
|
||||
pub open_participation: bool,
|
||||
pub matchmake_system_type: u32,
|
||||
pub application_buffer: Vec<u8>,
|
||||
pub participation_count: u32,
|
||||
pub progress_score: u8,
|
||||
pub session_key: Vec<u8>,
|
||||
pub option0: u32,
|
||||
pub matchmake_param: MatchmakeParam,
|
||||
pub datetime: KerberosDateTime,
|
||||
pub user_password: String,
|
||||
pub refer_gid: u32,
|
||||
pub user_password_enabled: bool,
|
||||
pub system_password_enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(3)]
|
||||
pub struct MatchmakeSessionSearchCriteria {
|
||||
pub attribs: Vec<String>,
|
||||
pub game_mode: String,
|
||||
pub minimum_participants: String,
|
||||
pub maximum_participants: String,
|
||||
pub matchmake_system_type: String,
|
||||
pub vacant_only: bool,
|
||||
pub exclude_locked: bool,
|
||||
pub exclude_non_host_pid: bool,
|
||||
pub selection_method: u32,
|
||||
pub vacant_participants: u16,
|
||||
pub matchmake_param: MatchmakeParam,
|
||||
pub exclude_user_password_set: bool,
|
||||
pub exclude_system_password_set: bool,
|
||||
pub refer_gid: u32,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct AutoMatchmakeParam {
|
||||
pub matchmake_session: MatchmakeSession,
|
||||
pub additional_participants: Vec<u32>,
|
||||
pub gid_for_participation_check: u32,
|
||||
pub auto_matchmake_option: u32,
|
||||
pub join_message: String,
|
||||
pub participation_count: u16,
|
||||
pub search_criteria: Vec<MatchmakeSessionSearchCriteria>,
|
||||
pub target_gids: Vec<u32>,
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ impl RmcSerialize for &str{
|
|||
panic!("cannot serialize to &str")
|
||||
}
|
||||
fn serialize(&self, writer: &mut dyn Write) -> Result<()> {
|
||||
let u16_len: u16 = self.len() as u16;
|
||||
let u16_len: u16 = (self.len() + 1) as u16;
|
||||
writer.write(bytes_of(&u16_len))?;
|
||||
|
||||
writer.write(self.as_bytes())?;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use crate::kerberos::KerberosDateTime;
|
|||
use crate::rmc::structures;
|
||||
use crate::rmc::structures::RmcSerialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Variant{
|
||||
None,
|
||||
SInt64(i64),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue