1
0

better packet infomation logging

This commit is contained in:
EAimTY 2023-05-30 19:49:23 +09:00
parent ae052a805b
commit d6e4e7eeee
2 changed files with 16 additions and 14 deletions

View File

@ -39,11 +39,11 @@ impl Connection {
match self.udp_relay_mode {
UdpRelayMode::Native => {
log::info!("[relay] [packet] [{assoc_id:#06x}] [to-native] {addr_display}");
log::info!("[relay] [packet] [{assoc_id:#06x}] [to-native] to {addr_display}");
match self.model.packet_native(pkt, addr, assoc_id) {
Ok(()) => Ok(()),
Err(err) => {
log::warn!("[relay] [packet] [{assoc_id:#06x}] [to-native] failed relaying packet to {addr_display}: {err}");
log::warn!("[relay] [packet] [{assoc_id:#06x}] [to-native] to {addr_display}: {err}");
Err(Error::Model(err))
}
}
@ -53,7 +53,9 @@ impl Connection {
match self.model.packet_quic(pkt, addr, assoc_id).await {
Ok(()) => Ok(()),
Err(err) => {
log::warn!("[relay] [packet] [{assoc_id:#06x}] [to-quic] failed relaying packet to {addr_display}: {err}");
log::warn!(
"[relay] [packet] [{assoc_id:#06x}] [to-quic] to {addr_display}: {err}"
);
Err(Error::Model(err))
}
}
@ -66,7 +68,7 @@ impl Connection {
match self.model.dissociate(assoc_id).await {
Ok(()) => Ok(()),
Err(err) => {
log::warn!("[relay] [dissociate] [{assoc_id:#06x}] failed dissociating: {err}");
log::warn!("[relay] [dissociate] [{assoc_id:#06x}] {err}");
Err(Error::Model(err))
}
}
@ -86,7 +88,7 @@ impl Connection {
match self.model.heartbeat().await {
Ok(()) => log::debug!("[relay] [heartbeat]"),
Err(err) => log::warn!("[relay] [heartbeat] heartbeat sending error: {err}"),
Err(err) => log::warn!("[relay] [heartbeat] {err}"),
}
}
}
@ -105,7 +107,7 @@ impl Connection {
match pkt.accept().await {
Ok(Some((pkt, addr, _))) => {
log::info!("[relay] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] {addr}");
log::info!("[relay] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] from {addr}");
let addr = match addr {
Address::None => unreachable!(),

View File

@ -86,7 +86,7 @@ impl Connection {
let frag_total = pkt.frag_total();
log::info!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] {frag_id}/{frag_total}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] fragment {frag_id}/{frag_total}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
@ -99,7 +99,7 @@ impl Connection {
Ok(Some(res)) => res,
Err(err) => {
log::warn!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] {frag_id}/{frag_total}: {err}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] fragment {frag_id}/{frag_total}: {err}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
@ -110,7 +110,7 @@ impl Connection {
let process = async {
log::info!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] {src_addr}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] to {src_addr}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
@ -140,7 +140,7 @@ impl Connection {
if let Err(err) = process.await {
log::warn!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] {src_addr}: {err}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [from-{mode}] [{pkt_id:#06x}] to {src_addr}: {err}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
@ -175,12 +175,12 @@ impl Connection {
let addr_display = addr.to_string();
log::info!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [to-{mode}] {target_addr}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [to-{mode}] from {src_addr}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
mode = self.udp_relay_mode.load().unwrap(),
target_addr = addr_display,
src_addr = addr_display,
);
let res = match self.udp_relay_mode.load().unwrap() {
@ -190,12 +190,12 @@ impl Connection {
if let Err(err) = res {
log::warn!(
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [to-{mode}] {target_addr}: {err}",
"[{id:#010x}] [{addr}] [{user}] [packet] [{assoc_id:#06x}] [to-{mode}] from {src_addr}: {err}",
id = self.id(),
addr = self.inner.remote_address(),
user = self.auth,
mode = self.udp_relay_mode.load().unwrap(),
target_addr = addr_display,
src_addr = addr_display,
);
}
}