From 066ed4c85d066e10824c771d42cbd97a2f2b2a6a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 12 Mar 2024 21:12:50 +1100 Subject: [PATCH] chore(snownet): log channel number and peer as part of failed channel binding (#4086) Should help in debugging which channel we tried to bind without having to sieve through the relay's logs for the transaction ID. --- rust/connlib/snownet/src/allocation.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rust/connlib/snownet/src/allocation.rs b/rust/connlib/snownet/src/allocation.rs index 590e443af..b5728c72d 100644 --- a/rust/connlib/snownet/src/allocation.rs +++ b/rust/connlib/snownet/src/allocation.rs @@ -238,8 +238,19 @@ impl Allocation { tracing::warn!("Request did not contain a `CHANNEL-NUMBER`"); return true; }; + let Some(peer) = original_request + .get_attribute::() + .map(|c| c.address()) + else { + tracing::warn!("Request did not contain a `XOR-PEER-ADDRESS`"); + return true; + }; self.channel_bindings.handle_failed_binding(channel); + + // Duplicate log here because we want to attach "channel number" and "peer". + tracing::warn!(error = %error.reason_phrase(), %channel, %peer); + return true; } REFRESH => { self.invalidate_allocation(); @@ -248,10 +259,7 @@ impl Allocation { _ => {} } - // TODO: Handle error codes such as: - // - Failed allocations - - tracing::warn!(error = %error.reason_phrase(), "STUN request failed"); + tracing::warn!(error = %error.reason_phrase()); return true; }