Skip to content

Commit 4205675

Browse files
committed
Debug logging for address translation
1 parent d7beb55 commit 4205675

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

protocols/identify/src/behaviour.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,21 @@ impl Behaviour {
276276
{
277277
// Apply address translation to the candidate address.
278278
// For TCP without port-reuse, the observed address contains an ephemeral port which needs to be replaced by the port of a listen address.
279+
tracing::info!(">>> translating ephemeral address {observed:?}");
279280
let translated_addresses = {
280281
let mut addrs: Vec<_> = self
281282
.listen_addresses
282283
.iter()
283284
.filter_map(|server| {
285+
tracing::info!("> translating to listen address {server:?}");
284286
if (is_tcp_addr(server) && is_tcp_addr(observed))
285287
|| (is_quic_addr(server, true) && is_quic_addr(observed, true))
286288
|| (is_quic_addr(server, false) && is_quic_addr(observed, false))
287289
{
288-
_address_translation(server, observed)
290+
let translated = _address_translation(server, observed);
291+
tracing::info!("> translated to {translated:?}");
292+
293+
translated
289294
} else {
290295
None
291296
}
@@ -298,6 +303,8 @@ impl Behaviour {
298303
addrs
299304
};
300305

306+
tracing::info!("> translated addresses {translated_addresses:?}");
307+
301308
// If address translation yielded nothing, broadcast the original candidate address.
302309
if translated_addresses.is_empty() {
303310
self.events
@@ -313,6 +320,7 @@ impl Behaviour {
313320

314321
// outgoing connection dialed with port reuse
315322
// incomming connection
323+
tracing::info!(">>> skipping translation for port-reuse address {observed:?}");
316324
self.events
317325
.push_back(ToSwarm::NewExternalAddrCandidate(observed.clone()));
318326
}

0 commit comments

Comments
 (0)