summaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/firewall.rs4
-rw-r--r--src/transport/mod.rs4
-rw-r--r--src/transport/mycelium/mod.rs4
-rw-r--r--src/transport/sim.rs5
-rw-r--r--src/transport/traffic.rs4
5 files changed, 21 insertions, 0 deletions
diff --git a/src/transport/firewall.rs b/src/transport/firewall.rs
index c8592bd..23d91fe 100644
--- a/src/transport/firewall.rs
+++ b/src/transport/firewall.rs
@@ -65,6 +65,10 @@ impl Transport for FirewallTransport {
self.inner.local_id()
}
+ fn is_peer_id(&self, id: &str) -> bool {
+ self.inner.is_peer_id(id)
+ }
+
async fn resolve_seed(&self, seed: &str) -> Result<String> {
self.inner.resolve_seed(seed).await
}
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 14c5ee4..b2ce63f 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -323,6 +323,10 @@ pub trait Transport: Send + Sync {
/// This node's identity on the transport (for Mycelium: its public key).
fn local_id(&self) -> &str;
+ /// Whether `id` can be a node's identity on this transport (for Mycelium: a public
+ /// key). Identities other peers name to us (in a HELLO_REPLY) are checked with it.
+ fn is_peer_id(&self, id: &str) -> bool;
+
/// Resolves a seed (anything that leads to a node, e.g. an address) to that node's
/// identity, as `local_id` gives it on that node.
async fn resolve_seed(&self, seed: &str) -> Result<String>;
diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs
index cbae567..0b74793 100644
--- a/src/transport/mycelium/mod.rs
+++ b/src/transport/mycelium/mod.rs
@@ -168,6 +168,10 @@ impl Transport for MyceliumTransport {
&self.local_id
}
+ fn is_peer_id(&self, id: &str) -> bool {
+ is_pubkey(id)
+ }
+
async fn resolve_seed(&self, hint: &str) -> Result<String> {
if is_pubkey(hint) {
return Ok(hint.to_owned());
diff --git a/src/transport/sim.rs b/src/transport/sim.rs
index 675f382..05160f8 100644
--- a/src/transport/sim.rs
+++ b/src/transport/sim.rs
@@ -255,6 +255,11 @@ impl Transport for SimTransport {
&self.id
}
+ /// Any name will do.
+ fn is_peer_id(&self, id: &str) -> bool {
+ !id.is_empty()
+ }
+
/// A seed is a node ID; one no node has doesn't resolve (yet).
async fn resolve_seed(&self, seed: &str) -> Result<String> {
if self.net.is_known(seed) {
diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs
index 3d17860..78c5fee 100644
--- a/src/transport/traffic.rs
+++ b/src/transport/traffic.rs
@@ -138,6 +138,10 @@ impl Transport for CountingTransport {
self.inner.local_id()
}
+ fn is_peer_id(&self, id: &str) -> bool {
+ self.inner.is_peer_id(id)
+ }
+
async fn resolve_seed(&self, seed: &str) -> Result<String> {
self.inner.resolve_seed(seed).await
}