V0 #1
5 changed files with 43 additions and 12 deletions
Merge branch 'friendsfix' into 'v0'
fix friends See merge request spfn/rust-nex!4
commit
d9fa70bbee
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -850,6 +850,7 @@ dependencies = [
|
|||
name = "proxy-common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"log",
|
||||
"rnex-core",
|
||||
"thiserror",
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ thiserror = "2.0.12"
|
|||
rnex-core = { path = "../rnex-core", version = "0.1.1" }
|
||||
tokio = { version = "1.47.0", features = ["full"] }
|
||||
log = "0.4.25"
|
||||
hex = "0.4.3"
|
||||
|
|
|
|||
|
|
@ -187,17 +187,14 @@ pub async fn new_backend_connection(
|
|||
}
|
||||
};
|
||||
|
||||
if let Err(e) = stream
|
||||
.send_buffer(
|
||||
&ConnectionInitData {
|
||||
prudpsock_addr: addr,
|
||||
pid: pid,
|
||||
}
|
||||
.to_data()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
let data = ConnectionInitData {
|
||||
prudpsock_addr: addr,
|
||||
pid: pid,
|
||||
}
|
||||
.to_data()
|
||||
.unwrap();
|
||||
|
||||
if let Err(e) = stream.send_buffer(&data).await {
|
||||
error!("unable to send establishment data to backend: {}", e);
|
||||
return None;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ pub fn new_connect_packet(
|
|||
.checksummed_data()
|
||||
.expect("packet malformed in creation"),
|
||||
);
|
||||
info!("header: {:?}", packet.header());
|
||||
|
||||
packet.0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,40 @@
|
|||
use crate::{PID, prudp::socket_addr::PRUDPSockAddr};
|
||||
use macros::RmcSerialize;
|
||||
|
||||
#[derive(Debug, RmcSerialize)]
|
||||
#[derive(Debug, RmcSerialize, PartialEq, Eq)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct ConnectionInitData {
|
||||
pub prudpsock_addr: PRUDPSockAddr,
|
||||
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