Skip to content

Commit

Permalink
feat(iroh-net): PCP probe
Browse files Browse the repository at this point in the history
- Adds PCP support for the Announce Opcode and implemented probing for PCP
- Add metrics for PCP probes
- Add a port-map-probe command to pick what subset of protocols to probe

Ref #910
  • Loading branch information
divagant-martian authored Jul 17, 2023
1 parent c5e4c1b commit 659a54a
Show file tree
Hide file tree
Showing 11 changed files with 724 additions and 35 deletions.
47 changes: 35 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions iroh-metrics/src/portmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pub struct Metrics {
pub upnp_probes_failed: Counter,
pub upnp_available: Counter,
pub upnp_gateway_updated: Counter,

/*
* PCP metrics
*/
pub pcp_probes: Counter,
pub pcp_available: Counter,
}

impl Default for Metrics {
Expand All @@ -44,6 +50,12 @@ impl Default for Metrics {
upnp_gateway_updated: Counter::new(
"Number of UPnP probes that resulted in a gateway different to the previous one.",
),

/*
* PCP metrics
*/
pcp_probes: Counter::new("Number of PCP probes executed."),
pcp_available: Counter::new("Number of PCP probes that found it available."),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = tr

# metrics
iroh-metrics = { path = "../iroh-metrics", optional = true }
num_enum = "0.6.1"

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
netlink-packet-route = "0.17.0"
Expand All @@ -85,6 +86,7 @@ wmi = "0.13"
clap = { version = "4", features = ["derive"] }
ntest = "*"
pretty_assertions = "1.4"
rand_chacha = "0.3.1"
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/hp/magicsock/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl Conn {
}

async fn with_name(name: String, opts: Options) -> Result<Self> {
let port_mapper = portmapper::Client::new().await;
let port_mapper = portmapper::Client::default().await;

let Options {
port,
Expand Down
Loading

0 comments on commit 659a54a

Please sign in to comment.