add some debug messages
This commit is contained in:
parent
b1cc5ddd32
commit
0a32061960
@ -30,8 +30,10 @@ pub async fn read_tun_iface(
|
|||||||
) {
|
) {
|
||||||
let mut buf: [u8; IP_BUFFER_SIZE] = [0u8; IP_BUFFER_SIZE];
|
let mut buf: [u8; IP_BUFFER_SIZE] = [0u8; IP_BUFFER_SIZE];
|
||||||
|
|
||||||
smol::block_on(async {
|
|
||||||
loop {
|
loop {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
eprintln!("Started listening for ip packets");
|
||||||
let data_lenght = tun_iface.recv(&mut buf).unwrap(); // build in auto termination, isn't it great
|
let data_lenght = tun_iface.recv(&mut buf).unwrap(); // build in auto termination, isn't it great
|
||||||
smol::spawn(handle_ip_packet(
|
smol::spawn(handle_ip_packet(
|
||||||
buf[..data_lenght - 1].to_vec().into(),
|
buf[..data_lenght - 1].to_vec().into(),
|
||||||
@ -40,7 +42,7 @@ pub async fn read_tun_iface(
|
|||||||
))
|
))
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_ip_packet(
|
pub async fn handle_ip_packet(
|
||||||
@ -48,6 +50,8 @@ pub async fn handle_ip_packet(
|
|||||||
network: Arc<RwLock<Network>>,
|
network: Arc<RwLock<Network>>,
|
||||||
socket: Arc<std::net::UdpSocket>,
|
socket: Arc<std::net::UdpSocket>,
|
||||||
) {
|
) {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
eprintln!("Processing IP packet");
|
||||||
let dst_ip = std::net::Ipv4Addr::from(
|
let dst_ip = std::net::Ipv4Addr::from(
|
||||||
match <[u8; 4]>::try_from(
|
match <[u8; 4]>::try_from(
|
||||||
&packet_data[DEST_IN_IPV4_OFFSET..DEST_IN_IPV4_OFFSET + IPV4_SIZE],
|
&packet_data[DEST_IN_IPV4_OFFSET..DEST_IN_IPV4_OFFSET + IPV4_SIZE],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user