Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portmapper does not use Iroh bound interfaces #2871

Open
CGamesPlay opened this issue Oct 31, 2024 · 0 comments
Open

Portmapper does not use Iroh bound interfaces #2871

CGamesPlay opened this issue Oct 31, 2024 · 0 comments
Labels
bug Something isn't working c-iroh-net

Comments

@CGamesPlay
Copy link

This is split from #2866 (comment). Applying the following patch and running the listen example in iroh-net demonstrates that the port mapper service uses interfaces on which it has not been configured. The patch disables relay and all discovery, and binds to loopback addresses, only.

git reset --hard fad3e24b3
cat patch.patch | git apply
RUST_LOG=trace cargo run --example listen

In the log, we notice the following selected lines, indicating that portmapper is using SSDP on the default interface, ignoring the configuration set by the Endpoint.

2024-10-31T01:52:20.276752Z DEBUG ep{me=rseo2uaniqtssr4r}:magicsock:portmapper.service: portmapper: portmap starting
2024-10-31T01:52:20.277091Z TRACE ep{me=rseo2uaniqtssr4r}:magicsock:portmapper.service: portmapper: tick: msg Some(UpdateLocalPort { local_port: Some(5000) })
2024-10-31T01:52:20.277943Z DEBUG ep{me=rseo2uaniqtssr4r}:magicsock:portmapper.service: portmapper: getting a port mapping for 192.168.20.59:5000 -> None
2024-10-31T01:52:20.278075Z DEBUG ep{me=rseo2uaniqtssr4r}:magicsock:portmapper.service:upnp: igd_next::aio::tokio: sending broadcast request to: 239.255.255.250:1900 on interface: Ok(0.0.0.0:52449)    
diff --git i/iroh-net/examples/listen.rs w/iroh-net/examples/listen.rs
index 1a3828c6e..731a2aca7 100644
--- i/iroh-net/examples/listen.rs
+++ w/iroh-net/examples/listen.rs
@@ -30,7 +30,10 @@ async fn main() -> anyhow::Result<()> {
         // Use `RelayMode::Custom` to pass in a `RelayMap` with custom relay urls.
         // Use `RelayMode::Disable` to disable holepunching and relaying over HTTPS
         // If you want to experiment with relaying using your own relay server, you must pass in the same custom relay url to both the `listen` code AND the `connect` code
-        .relay_mode(RelayMode::Default)
+        .relay_mode(RelayMode::Disabled)
+        .clear_discovery()
+        .bind_addr_v6("[::1]:5000".parse().unwrap())
+        .bind_addr_v4("127.0.0.1:5000".parse().unwrap())
         // you can choose a port to bind to, but passing in `0` will bind the socket to a random available port
         .bind()
         .await?;
@@ -39,29 +42,20 @@ async fn main() -> anyhow::Result<()> {
     println!("node id: {me}");
     println!("node listening addresses:");
 
-    let local_addrs = endpoint
+    for endpoint in endpoint
         .direct_addresses()
         .next()
         .await
         .context("no endpoints")?
         .into_iter()
-        .map(|endpoint| {
-            let addr = endpoint.addr.to_string();
-            println!("\t{addr}");
-            addr
-        })
-        .collect::<Vec<_>>()
-        .join(" ");
+    {
+        let addr = endpoint.addr.to_string();
+        println!("\t{addr}");
+    }
 
-    let relay_url = endpoint
-        .home_relay()
-        .expect("should be connected to a relay server, try calling `endpoint.local_endpoints()` or `endpoint.connect()` first, to ensure the endpoint has actually attempted a connection before checking for the connected relay server");
-    println!("node relay server url: {relay_url}");
-    println!("\nin a separate terminal run:");
+    let relay_url = endpoint.home_relay();
+    println!("node relay server url: {relay_url:?}");
 
-    println!(
-        "\tcargo run --example connect -- --node-id {me} --addrs \"{local_addrs}\" --relay-url {relay_url}\n"
-    );
     // accept incoming connections, returns a normal QUIC connection
     while let Some(incoming) = endpoint.accept().await {
         let mut connecting = match incoming.accept() {
@flub flub added bug Something isn't working c-iroh-net labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c-iroh-net
Projects
Status: No status
Development

No branches or pull requests

2 participants