Compare commits
2 commits
bb3fc6c891
...
c9b4da2d37
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9b4da2d37 | ||
|
|
a526c31e24 |
4 changed files with 1125 additions and 9 deletions
1084
Cargo.lock
generated
Normal file
1084
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
5
server_commit.txt
Normal file
5
server_commit.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
commit a526c31e24213095e79205ea74f2a303bb1608f6
|
||||
Author: Sarthak <root@srtk.in>
|
||||
Date: Mon Feb 9 17:06:59 2026 +0530
|
||||
|
||||
chore: update server
|
||||
18
src/udp.rs
18
src/udp.rs
|
|
@ -23,17 +23,17 @@ pub async fn run_udp_server(state: AppState) -> anyhow::Result<()> {
|
|||
let data = &buf[..len];
|
||||
info!("UDP RECV from {}: {} bytes", addr, len);
|
||||
|
||||
// Manually parse header (22 bytes) to match client's raw byte layout:
|
||||
// Manually parse header (24 bytes) to match client's raw byte layout:
|
||||
// Byte 0: version (u8)
|
||||
// Byte 1: media_type (u8)
|
||||
// Bytes 2-5: user_id (u32 LE)
|
||||
// Bytes 6-9: sequence (u32 LE)
|
||||
// Bytes 10-17: timestamp (u64 LE)
|
||||
// Byte 18: fragment_index (u8)
|
||||
// Byte 19: fragment_count (u8)
|
||||
// Bytes 20-21: flags (u16 LE)
|
||||
// Bytes 18-19: fragment_index (u16 LE)
|
||||
// Bytes 20-21: fragment_count (u16 LE)
|
||||
// Bytes 22-23: flags (u16 LE)
|
||||
|
||||
if data.len() < 22 {
|
||||
if data.len() < 24 {
|
||||
warn!("UDP packet too small: {} bytes from {}", data.len(), addr);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -43,9 +43,9 @@ pub async fn run_udp_server(state: AppState) -> anyhow::Result<()> {
|
|||
let user_id = u32::from_le_bytes([data[2], data[3], data[4], data[5]]);
|
||||
let _sequence = u32::from_le_bytes([data[6], data[7], data[8], data[9]]);
|
||||
let _timestamp = u64::from_le_bytes([data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17]]);
|
||||
let _fragment_index = data[18];
|
||||
let _fragment_count = data[19];
|
||||
let _flags = u16::from_le_bytes([data[20], data[21]]);
|
||||
let _fragment_index = u16::from_le_bytes([data[18], data[19]]);
|
||||
let _fragment_count = u16::from_le_bytes([data[20], data[21]]);
|
||||
let _flags = u16::from_le_bytes([data[22], data[23]]);
|
||||
|
||||
let media_type = match media_type_byte {
|
||||
0 => MediaType::Audio,
|
||||
|
|
@ -55,7 +55,7 @@ pub async fn run_udp_server(state: AppState) -> anyhow::Result<()> {
|
|||
_ => MediaType::Unknown,
|
||||
};
|
||||
|
||||
let payload = &data[22..];
|
||||
let payload = &data[24..];
|
||||
|
||||
|
||||
match media_type {
|
||||
|
|
|
|||
27
status.txt
Normal file
27
status.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
On branch master
|
||||
Your branch is up to date with 'origin/master'.
|
||||
|
||||
Changes not staged for commit:
|
||||
(use "git add <file>..." to update what will be committed)
|
||||
(use "git restore <file>..." to discard changes in working directory)
|
||||
modified: src/udp.rs
|
||||
|
||||
Untracked files:
|
||||
(use "git add <file>..." to include in what will be committed)
|
||||
Cargo.lock
|
||||
status.txt
|
||||
|
||||
no changes added to commit (use "git add" and/or "git commit -a")
|
||||
--- SERVER LS ---
|
||||
total 44
|
||||
drwxr-xr-x. 1 sarthak sarthak 136 Feb 9 17:04 .
|
||||
drwxr-xr-x. 1 sarthak sarthak 68 Feb 9 17:04 ..
|
||||
-rw-r--r--. 1 sarthak sarthak 27547 Feb 8 23:30 Cargo.lock
|
||||
-rw-r--r--. 1 sarthak sarthak 423 Feb 8 23:27 Cargo.toml
|
||||
drwxr-xr-x. 1 sarthak sarthak 122 Feb 9 17:04 .git
|
||||
-rw-r--r--. 1 sarthak sarthak 29 Feb 8 23:27 .gitignore
|
||||
-rw-r--r--. 1 sarthak sarthak 2204 Feb 8 23:27 README.md
|
||||
drwxr-xr-x. 1 sarthak sarthak 46 Feb 8 23:27 shared
|
||||
drwxr-xr-x. 1 sarthak sarthak 64 Feb 8 23:27 src
|
||||
-rw-r--r--. 1 sarthak sarthak 446 Feb 9 17:04 status.txt
|
||||
drwxr-xr-x. 1 sarthak sarthak 66 Feb 8 23:30 target
|
||||
Loading…
Add table
Add a link
Reference in a new issue