aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-30 15:24:41 +0100
committertv <tv@krebsco.de>2026-10-30 15:24:41 +0100
commitbff42bf27f58bacb8bce58458dea7da74cda2c05 (patch)
treef06e584a2237f84007533b964144d45fedd21924 /src/transport
parent4250d9843133d38c7ace1a1b510265a15ebaa0fd (diff)
allow dead Connection unless a transport needs it
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/mod.rs6
-rw-r--r--src/transport/tor.rs9
2 files changed, 14 insertions, 1 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 40fdfc0..b10c799 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -382,9 +382,13 @@ pub(crate) struct Punching {
/// How a transport with connections (libp2p) is connected to a peer.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
+// Only libp2p and Tor have connections; without both (the cargo features) nothing makes
+// one.
+#[cfg_attr(not(any(feature = "libp2p", feature = "tor")), allow(dead_code))]
pub(crate) enum Connection {
+ /// libp2p's to the peer itself; Tor's always (an onion circuit).
Direct,
- /// Only through a relay.
+ /// Only through a relay (libp2p).
Relayed,
}
diff --git a/src/transport/tor.rs b/src/transport/tor.rs
index 39e0f31..2cf3249 100644
--- a/src/transport/tor.rs
+++ b/src/transport/tor.rs
@@ -544,6 +544,15 @@ impl Transport for TorTransport {
parse_location(target)
}
+ /// Direct while a connection to its onion service is open: an onion circuit, with no
+ /// relay of ours in between.
+ fn connection(&self, target: &str) -> Option<crate::transport::Connection> {
+ let location = parse_location(target)?;
+ lock(&self.shared.connections)
+ .contains_key(&location)
+ .then_some(crate::transport::Connection::Direct)
+ }
+
/// An onion service is its own transport identity: nothing to find out.
async fn resolve_seed(&self, seed: &str) -> Result<String> {
let location = parse_location(seed)