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

quic: ability to listen on ipv4 and v6 #4165

Closed
mxinden opened this issue Jul 10, 2023 · 5 comments · Fixed by #4289 or #4325
Closed

quic: ability to listen on ipv4 and v6 #4165

mxinden opened this issue Jul 10, 2023 · 5 comments · Fixed by #4289 or #4325
Labels
bug difficulty:moderate getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted

Comments

@mxinden
Copy link
Member

mxinden commented Jul 10, 2023

Summary

With libp2p-quic v0.8.0-alpha one can not listen on both a v4 and v6 address.

Unconfirmed whether #3454 has the same issue.

Expected behaviour

Calling listen_on with a v4 and v6 address to work.

Actual behaviour

Apply the following diff:

modified   examples/dcutr/src/main.rs
@@ -172,7 +172,10 @@ fn main() -> Result<(), Box<dyn Error>> {
     .build();
 
     swarm
-        .listen_on("/ip4/0.0.0.0/udp/0/quic-v1".parse().unwrap())
+        .listen_on("/ip4/0.0.0.0/udp/4001/quic-v1".parse().unwrap())
+        .unwrap();
+    swarm
+        .listen_on("/ip6/::/udp/4001/quic-v1".parse().unwrap())
         .unwrap();
     swarm
         .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap())

and then run with:

cargo run -- --mode listen --secret-key-seed 0 --relay-address /ip4/127.0.0.1

resulting in:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Other(Custom { kind: Other, error: Transport(Right(Io(Os { code: 98, kind: AddrInUse, message: "Address already in use" }))) })', examples/dcutr/src/main.rs:179:10
Debug Output

<output>

Possible Solution

My suspicion is that the ipv6 UdpSocket binds to both v4 and v6 in order to accept IPv4-mapped IPv6 traffic e.g. ::ffff:192.0.2.128.

In such case we would need to call set_only_v6 on the socket.

See same code on the tcp side:

if socket_addr.is_ipv6() {
socket.set_only_v6(true)?;
}

Version

libp2p-quic v0.8.0-alpha

Would you like to work on fixing this bug?

No

@mxinden mxinden added bug difficulty:moderate help wanted getting-started Issues that can be tackled if you don't know the internals of libp2p very well labels Jul 10, 2023
mxinden added a commit to mxinden/rust-libp2p-server that referenced this issue Jul 10, 2023
- Read listen addresses from `config.addresses.swarm`.
- Read external addresses from `config.addresses.announce`.
- Ignore IPv6 QUIC addresses due to libp2p/rust-libp2p#4165.
mxinden added a commit to mxinden/rust-libp2p-server that referenced this issue Jul 10, 2023
- Read listen addresses from `config.addresses.swarm`.
- Read external addresses from `config.addresses.announce`.
- Ignore IPv6 QUIC addresses due to libp2p/rust-libp2p#4165.
@eserilev
Copy link
Contributor

hi, i'd like to work on this if its still relevant

@eserilev
Copy link
Contributor

so far im having a bit of trouble recreating this bug

applying the diff you mentioned i'm getting a:
thread 'main' panicked at 'OutgoingConnectionError { connection_id: ConnectionId(1), peer_id: None, error: Transport([("/ip4/127.0.0.1", Other(Custom { kind: Other, error: MultiaddrNotSupported("/ip4/127.0.0.1") }))]) }'

@mxinden
Copy link
Member Author

mxinden commented Jul 28, 2023

Help is much appreciated. Also since #3454 is merged now, I don't suspect any larger merge conflicts to come up.

so far im having a bit of trouble recreating this bug

applying the diff you mentioned i'm getting a: thread 'main' panicked at 'OutgoingConnectionError { connection_id: ConnectionId(1), peer_id: None, error: Transport([("/ip4/127.0.0.1", Other(Custom { kind: Other, error: MultiaddrNotSupported("/ip4/127.0.0.1") }))]) }'

I suspect this to be due to an error I made above. --relay-address /ip4/127.0.0.1 should instead be a full QUIC address, e.g. --relay-address /ip4/127.0.0.1/udp/<listen-port/quic-v1. Does that fix the issue you are seeing?

@eserilev
Copy link
Contributor

Thanks for the additional info

I took a step back and just tried to run this example as is, with the example command found in the readme, but I'm getting a Connection Refused error message

applying the diff you mentioned and running with the following command:

cargo run -- --mode listen --secret-key-seed 0 --relay-address /ip4/127.0.0.1/udp/4005/quic-v1

I'm getting a HandshakeTimedOut error. I'm probably missing something here, so if you have any additional tips/hints please let me know. In the meantime I'll keep playing around with this and see how far I can get

@jxs
Copy link
Member

jxs commented Aug 2, 2023

Have you tried this after #3454 @mxinden?

UPD:

was able to reproduce your error with the ping example.

@mergify mergify bot closed this as completed in #4289 Aug 8, 2023
mergify bot pushed a commit that referenced this issue Aug 8, 2023
mxinden added a commit that referenced this issue Aug 10, 2023
With #4165 fixed, there is no need for filtering ipv6 quic.
thomaseizinger pushed a commit that referenced this issue Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug difficulty:moderate getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted
Projects
None yet
3 participants