aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index fb13ad9..40fdfc0 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -361,11 +361,24 @@ pub(crate) struct Destination {
pub(crate) proven: bool,
/// The transport's connection to it, if the transport has connections.
pub(crate) connection: Option<Connection>,
+ /// While it is connected only through a relay: how hole punching went.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub(crate) punching: Option<Punching>,
/// Every address it proved itself at, best first, as the paths layer measures them
/// (`transport::paths`).
pub(crate) paths: Vec<stats::PathInfo>,
}
+/// Hole punching to a peer connected only through a relay (libp2p), once a punch failed.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct Punching {
+ /// Punches that failed in a row.
+ pub(crate) failed: usize,
+ /// When it is tried again, in seconds from now (0: due).
+ pub(crate) next_in_secs: u64,
+}
+
/// How a transport with connections (libp2p) is connected to a peer.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
@@ -712,6 +725,13 @@ pub(crate) trait Transport: Send + Sync {
None
}
+ /// How hole punching to `target` went, if a punch failed and it is still connected
+ /// only through a relay (libp2p). By default never.
+ fn punching(&self, target: &str) -> Option<Punching> {
+ let _ = target;
+ None
+ }
+
/// The smoothed round-trip time of the path messages to `peer` go over, if
/// measured (`transport::paths`). By default none.
fn rtt(&self, peer: &str) -> Option<std::time::Duration> {