Skip to content

Commit

Permalink
Prints sprinkled in nameserver
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasan6979 committed Feb 4, 2025
1 parent b0a6a96 commit f094cc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions crates/telio-dns/src/nameserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ impl LocalNameServer {
let semaphore = Arc::new(Semaphore::new(MAX_CONCURRENT_QUERIES));
loop {
let bytes_read = match socket.recv(&mut receiving_buffer).await {
Ok(bytes) => bytes,
Ok(bytes) => {
telio_log_debug!("Pkt recvd");
bytes
}
Err(e) => {
telio_log_error!("[DNS] Failed to read bytes: {:?}", e);
continue;
Expand All @@ -109,7 +112,7 @@ impl LocalNameServer {
_ => break,
};
}

telio_log_debug!("Timers updated");
let peer = peer.clone();
let socket = socket.clone();
let nameserver = nameserver.clone();
Expand All @@ -122,6 +125,7 @@ impl LocalNameServer {
receiving_buffer.get(..bytes_read).unwrap_or(&[]),
&mut sending_buffer,
);
telio_log_debug!("Pkt decapsulated");
match res {
// Handshake packets
TunnResult::WriteToNetwork(packet) => {
Expand All @@ -141,6 +145,7 @@ impl LocalNameServer {
return;
};
}
telio_log_debug!("Handshake pkt");
}
// DNS packets
TunnResult::WriteToTunnelV4(packet, _)
Expand All @@ -153,6 +158,7 @@ impl LocalNameServer {
return;
}
};
telio_log_debug!("Write2Tun");

let nameserver = nameserver.clone();
let length = match LocalNameServer::process_packet(
Expand All @@ -172,6 +178,7 @@ impl LocalNameServer {
return;
}
};
telio_log_debug!("Pkt processed");

let tunn_res = peer.lock().await.encapsulate(
receiving_buffer.get(..length).unwrap_or(&[]),
Expand Down Expand Up @@ -205,6 +212,7 @@ impl LocalNameServer {
nameserver: Arc<RwLock<LocalNameServer>>,
request_info: &mut RequestInfo,
) -> Result<Vec<u8>, String> {
telio_log_debug!("Resolving dns");
let resolver = Resolver::new();
let zones = nameserver.zones().await;

Expand Down
1 change: 0 additions & 1 deletion nat-lab/tests/test_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async def test_dns(
)


@pytest.mark.repeat(50)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"alpha_ip_stack",
Expand Down

0 comments on commit f094cc4

Please sign in to comment.