aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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)