change log levels

This commit is contained in:
soruh 2023-03-18 22:17:24 +01:00
parent 8a1c99229c
commit 12856c687d
2 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,7 @@ use tokio::{
sync::Mutex, sync::Mutex,
time::{sleep, timeout, Instant}, time::{sleep, timeout, Instant},
}; };
use tracing::{debug, error, info, warn, Level}; use tracing::{error, info, trace, warn, Level};
use crate::packets::{dyn_ip_update, PacketKind, REJECT_OOP, REJECT_TIMEOUT}; use crate::packets::{dyn_ip_update, PacketKind, REJECT_OOP, REJECT_TIMEOUT};
use crate::ports::{AllowedPorts, PortHandler, PortStatus}; use crate::ports::{AllowedPorts, PortHandler, PortStatus};
@ -447,13 +447,13 @@ async fn connection_handler(
let mut last_ping_received_at = Instant::now(); let mut last_ping_received_at = Instant::now();
let result = loop { let result = loop {
debug!( trace!(
seconds = SEND_PING_INTERVAL seconds = SEND_PING_INTERVAL
.saturating_sub(last_ping_sent_at.elapsed()) .saturating_sub(last_ping_sent_at.elapsed())
.as_secs(), .as_secs(),
"next ping in" "next ping in"
); );
debug!( trace!(
seconds = PING_TIMEOUT seconds = PING_TIMEOUT
.saturating_sub(last_ping_received_at.elapsed()) .saturating_sub(last_ping_received_at.elapsed())
.as_secs(), .as_secs(),
@ -472,14 +472,14 @@ async fn connection_handler(
packet.recv_into(&mut reader).await?; packet.recv_into(&mut reader).await?;
if packet.kind() == PacketKind::Ping { if packet.kind() == PacketKind::Ping {
debug!("received ping"); trace!("received ping");
last_ping_received_at = Instant::now(); last_ping_received_at = Instant::now();
} else { } else {
break Result::Packet { packet } break Result::Packet { packet }
} }
}, },
_ = sleep(send_next_ping_in) => { _ = sleep(send_next_ping_in) => {
debug!("sending ping"); trace!("sending ping");
writer.write_all(bytemuck::bytes_of(& Header { kind: PacketKind::Ping.raw(), length: 0 })).await?; writer.write_all(bytemuck::bytes_of(& Header { kind: PacketKind::Ping.raw(), length: 0 })).await?;
last_ping_sent_at = Instant::now(); last_ping_sent_at = Instant::now();
} }

View File

@ -6,7 +6,7 @@ use tokio::{
io::{AsyncReadExt, AsyncWriteExt}, io::{AsyncReadExt, AsyncWriteExt},
net::tcp::{ReadHalf, WriteHalf}, net::tcp::{ReadHalf, WriteHalf},
}; };
use tracing::info; use tracing::debug;
pub const REJECT_OOP: &[u8; 6] = b"\x04\x04oop\x00"; pub const REJECT_OOP: &[u8; 6] = b"\x04\x04oop\x00";
pub const REJECT_TIMEOUT: &[u8; 10] = b"\x04\x08timeout\x00"; pub const REJECT_TIMEOUT: &[u8; 10] = b"\x04\x08timeout\x00";
@ -184,7 +184,7 @@ pub async fn dyn_ip_update(
pin: u16, pin: u16,
port: u16, port: u16,
) -> anyhow::Result<std::net::Ipv4Addr> { ) -> anyhow::Result<std::net::Ipv4Addr> {
info!(%number, %port, "starting dyn ip update"); debug!(%number, %port, "starting dyn ip update");
let mut packet = Packet::default(); let mut packet = Packet::default();
packet.header = Header { packet.header = Header {
@ -235,7 +235,7 @@ pub async fn dyn_ip_update(
_ => bail!("server returned unexpected packet"), _ => bail!("server returned unexpected packet"),
}; };
info!(?result, "finished dyn ip update"); debug!(?result, "finished dyn ip update");
result result
} }