summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-28 11:34:56 +0100
committertv <tv@krebsco.de>2026-10-28 11:34:56 +0100
commit381ea0c63d59916d99061ed0fb2ed61927c263fb (patch)
treee6de8c33738cc843603e1450d7d363bd7f9b340a
parentc224f64c16c63e9795a31bc7aa34859d4b27d12b (diff)
consistently show addresses in /peers
-rw-r--r--docs/openapi.yaml2
-rw-r--r--src/transport/identity.rs2
-rw-r--r--src/transport/mod.rs3
-rw-r--r--src/transport/paths.rs19
4 files changed, 15 insertions, 11 deletions
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index b4c9c19..25a4a44 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1136,7 +1136,7 @@ components:
properties:
address:
type: string
- description: '`<scheme>:<transport identity>`, e.g. `libp2p:<peer ID>`.'
+ description: 'Where messages to it go: the first of `paths` (where none is proven, an address it is said to be at), in the same form: for libp2p the remote address of its connection, ending in the peer ID.'
proven:
type: boolean
description: The peer proved itself there; else sends wait for its proof.
diff --git a/src/transport/identity.rs b/src/transport/identity.rs
index 94faded..502c6b3 100644
--- a/src/transport/identity.rs
+++ b/src/transport/identity.rs
@@ -536,7 +536,7 @@ impl Transport for IdentityTransport {
};
let connection = self.shared.paths.connection(&address);
Some(Destination {
- address,
+ address: self.shared.paths.location(&address),
proven: is_proven,
connection,
paths: self.shared.paths.info(&proven),
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 25ad56d..839476b 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -353,7 +353,8 @@ pub(crate) struct ListedPeer {
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Destination {
- /// As the identity layer keeps it: `<scheme>:<transport identity>`.
+ /// Where messages to the peer go: its best path, as paths show it (`Paths::location`;
+ /// `stats::PathInfo::address`).
pub(crate) address: String,
/// The peer proved itself there; else it is only said to be there, and sends wait
/// for its proof.
diff --git a/src/transport/paths.rs b/src/transport/paths.rs
index ba16794..e966839 100644
--- a/src/transport/paths.rs
+++ b/src/transport/paths.rs
@@ -449,20 +449,23 @@ impl Paths {
self.located(infos)
}
- /// `infos` with where each path goes, where the transport knows
- /// (`Transport::location`); asked outside the table's lock.
+ /// `infos` with where each path goes (`located`); asked outside the table's lock.
fn located(&self, mut infos: Vec<PathInfo>) -> Vec<PathInfo> {
for info in &mut infos {
- if let Some((link, location)) = self
- .split(&info.address)
- .and_then(|(link, target)| Some((link, link.inner.location(&target)?)))
- {
- info.address = link.address(&location);
- }
+ info.address = self.location(&info.address);
}
infos
}
+ /// `address` (as paths keep it) as where it goes now, where the transport knows
+ /// more (`Transport::location`: libp2p, its connection's remote address); else
+ /// `address` itself. For showing: paths go by `address`.
+ pub(crate) fn location(&self, address: &str) -> String {
+ self.split(address)
+ .and_then(|(link, target)| Some(link.address(&link.inner.location(&target)?)))
+ .unwrap_or_else(|| address.to_owned())
+ }
+
/// Whether `address` is one of ours.
pub(crate) fn is_own(&self, address: &str) -> bool {
self.links.iter().any(|link| link.own_address() == address)