mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-26 00:37:44 +00:00
Fill out ClientVersionInfo IPC, add KeepAlive packet response
Now the server is somewhat functional, we don't get to the lobby screen yet but at least get a loading indicator in the client.
This commit is contained in:
parent
942a64cd7b
commit
f81f5ce09d
1 changed files with 42 additions and 4 deletions
|
@ -51,12 +51,33 @@ enum ConnectionType {
|
||||||
Lobby = 0x3,
|
Lobby = 0x3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[binrw]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum IPCOpCode {
|
||||||
|
// Client->Server Packets
|
||||||
|
#[brw(magic = 0x5u16)]
|
||||||
|
ClientVersionInfo {
|
||||||
|
#[brw(pad_before = 30)] // full of nonsense i don't understand yet
|
||||||
|
#[br(count = 64)]
|
||||||
|
#[br(map = read_string)]
|
||||||
|
#[bw(ignore)]
|
||||||
|
session_id: String,
|
||||||
|
|
||||||
|
#[brw(pad_before = 8)] // empty
|
||||||
|
#[br(count = 128)]
|
||||||
|
#[br(map = read_string)]
|
||||||
|
#[bw(ignore)]
|
||||||
|
version_info: String,
|
||||||
|
// unknown stuff at the end, it's not completely empty'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct IPCSegment {
|
struct IPCSegment {
|
||||||
unk1: u8,
|
unk1: u8,
|
||||||
unk2: u8,
|
unk2: u8,
|
||||||
op_code: u8,
|
op_code: IPCOpCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
@ -81,6 +102,8 @@ enum SegmentType {
|
||||||
#[bw(ignore)]
|
#[bw(ignore)]
|
||||||
data: IPCSegment,
|
data: IPCSegment,
|
||||||
},
|
},
|
||||||
|
#[brw(magic = 0x7u32)]
|
||||||
|
KeepAlive { id: u32, timestamp: u32 },
|
||||||
|
|
||||||
// Server->Client Packets
|
// Server->Client Packets
|
||||||
#[brw(magic = 0x0Au32)]
|
#[brw(magic = 0x0Au32)]
|
||||||
|
@ -88,6 +111,8 @@ enum SegmentType {
|
||||||
#[br(count = 0x280)]
|
#[br(count = 0x280)]
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
},
|
},
|
||||||
|
#[brw(magic = 0x08u32)]
|
||||||
|
KeepAliveResponse { id: u32, timestamp: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
@ -127,6 +152,8 @@ impl PacketSegment {
|
||||||
SegmentType::InitializeEncryption { .. } => 616,
|
SegmentType::InitializeEncryption { .. } => 616,
|
||||||
SegmentType::InitializationEncryptionResponse { .. } => 640,
|
SegmentType::InitializationEncryptionResponse { .. } => 640,
|
||||||
SegmentType::IPC { .. } => todo!(),
|
SegmentType::IPC { .. } => todo!(),
|
||||||
|
SegmentType::KeepAlive { .. } => todo!(),
|
||||||
|
SegmentType::KeepAliveResponse { .. } => 0x8,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,12 +265,23 @@ pub async fn parse_packet(socket: &mut WriteHalf<TcpStream>, data: &[u8], state:
|
||||||
};
|
};
|
||||||
send_packet(socket, &[response_packet]).await;
|
send_packet(socket, &[response_packet]).await;
|
||||||
}
|
}
|
||||||
SegmentType::InitializationEncryptionResponse { .. } => {
|
|
||||||
panic!("The server is recieving a response packet!")
|
|
||||||
}
|
|
||||||
SegmentType::IPC { .. } => {
|
SegmentType::IPC { .. } => {
|
||||||
// decrypt
|
// decrypt
|
||||||
}
|
}
|
||||||
|
SegmentType::KeepAlive { id, timestamp } => {
|
||||||
|
let response_packet = PacketSegment {
|
||||||
|
source_actor: 0,
|
||||||
|
target_actor: 0,
|
||||||
|
segment_type: SegmentType::KeepAliveResponse {
|
||||||
|
id: *id,
|
||||||
|
timestamp: *timestamp,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
send_packet(socket, &[response_packet]).await;
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
panic!("The server is recieving a response packet!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue