fix friends #4
5 changed files with 43 additions and 12 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -647,6 +647,7 @@ dependencies = [
|
||||||
name = "proxy-common"
|
name = "proxy-common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"hex",
|
||||||
"log",
|
"log",
|
||||||
"rnex-core",
|
"rnex-core",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ thiserror = "2.0.12"
|
||||||
rnex-core = { path = "../rnex-core", version = "0.1.1" }
|
rnex-core = { path = "../rnex-core", version = "0.1.1" }
|
||||||
tokio = { version = "1.47.0", features = ["full"] }
|
tokio = { version = "1.47.0", features = ["full"] }
|
||||||
log = "0.4.25"
|
log = "0.4.25"
|
||||||
|
hex = "0.4.3"
|
||||||
|
|
|
||||||
|
|
@ -187,17 +187,14 @@ pub async fn new_backend_connection(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = stream
|
let data = ConnectionInitData {
|
||||||
.send_buffer(
|
prudpsock_addr: addr,
|
||||||
&ConnectionInitData {
|
pid: pid,
|
||||||
prudpsock_addr: addr,
|
}
|
||||||
pid: pid,
|
.to_data()
|
||||||
}
|
.unwrap();
|
||||||
.to_data()
|
|
||||||
.unwrap(),
|
if let Err(e) = stream.send_buffer(&data).await {
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
error!("unable to send establishment data to backend: {}", e);
|
error!("unable to send establishment data to backend: {}", e);
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ pub fn new_connect_packet(
|
||||||
.checksummed_data()
|
.checksummed_data()
|
||||||
.expect("packet malformed in creation"),
|
.expect("packet malformed in creation"),
|
||||||
);
|
);
|
||||||
|
info!("header: {:?}", packet.header());
|
||||||
|
|
||||||
packet.0
|
packet.0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,40 @@
|
||||||
use crate::{PID, prudp::socket_addr::PRUDPSockAddr};
|
use crate::{PID, prudp::socket_addr::PRUDPSockAddr};
|
||||||
use macros::RmcSerialize;
|
use macros::RmcSerialize;
|
||||||
|
|
||||||
#[derive(Debug, RmcSerialize)]
|
#[derive(Debug, RmcSerialize, PartialEq, Eq)]
|
||||||
#[rmc_struct(0)]
|
#[rmc_struct(0)]
|
||||||
pub struct ConnectionInitData {
|
pub struct ConnectionInitData {
|
||||||
pub prudpsock_addr: PRUDPSockAddr,
|
pub prudpsock_addr: PRUDPSockAddr,
|
||||||
pub pid: PID,
|
pub pid: PID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use std::{
|
||||||
|
io::Cursor,
|
||||||
|
net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
prudp::{socket_addr::PRUDPSockAddr, virtual_port::VirtualPort},
|
||||||
|
rmc::structures::RmcSerialize,
|
||||||
|
rnex_proxy_common::ConnectionInitData,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
let data = ConnectionInitData {
|
||||||
|
prudpsock_addr: PRUDPSockAddr {
|
||||||
|
regular_socket_addr: SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::BROADCAST, 19293)),
|
||||||
|
virtual_port: VirtualPort::new(10, 2),
|
||||||
|
},
|
||||||
|
pid: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
let ser = data.to_data().unwrap();
|
||||||
|
|
||||||
|
let de = ConnectionInitData::deserialize(&mut Cursor::new(ser)).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(data, de);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue