quic: support quic/udp address parsing#430
Conversation
|
Please execute |
|
/quic refers to the old draft-29 protocol, while /quic-v1 refers to the standardized RFC 9000 QUIC v1, so they are not interchangeable, we should use |
| const WSS: u32 = 0x01de; | ||
| const MEMORY: u32 = 0x0309; | ||
| const ONION3: u32 = 0x01bd; | ||
| const QUIC: u32 = 0x1111; |
There was a problem hiding this comment.
encoding of QUIC and UDP are wrong, please check: https://github.com/multiformats/multiaddr/blob/master/protocols.csv?plain=1#L4
There was a problem hiding this comment.
There is a rust-multiaddr can help us: https://github.com/multiformats/rust-multiaddr/blob/33f1de2cb2c4a265b3d2dae3fe522d7bcf61ae11/src/protocol.rs#L38-L39
BTW, how about using decimal for u32 here.
There was a problem hiding this comment.
Fixed. Used numbers from https://github.com/multiformats/multiaddr/blob/master/protocols.csv?plain=1#L4
| "udp" => { | ||
| let s = iter.next().ok_or(Error::InvalidProtocolString)?; | ||
| Ok(Protocol::Udp( | ||
| u16::from_str_radix(s, 10).map_err(|_| Error::InvalidPort)?, |
There was a problem hiding this comment.
Could we use s.parse()? here?
There was a problem hiding this comment.
Replaced with s.parse()? now
|
We have Lines 429 to 459 in 87ef6d9 Perhaps we should move |
| "udp" => { | ||
| let s = iter.next().ok_or(Error::InvalidProtocolString)?; | ||
| Ok(Protocol::Udp( | ||
| u16::from_str_radix(s, 10).map_err(|_| Error::InvalidPort)?, |
There was a problem hiding this comment.
| u16::from_str_radix(s, 10).map_err(|_| Error::InvalidPort)?, | |
| s.parse()? |
If we use s.parse(), we can avoid introducing a new error type like Error::InvalidPort.
|
Summary
This PR is part 1 of 5 in the series to add native QUIC transport support to Tentacle, as outlined in #428.
QUIC Implementation Roadmap
UdpandQuicV1protocols/udp/<port>and/quic-v1protocol componentsbinding_sigServerCertVerifierandClientCertVerifierthat enforce Tentacle's identity model instead of CA-based validationQuicBiStream,QuicEndpoint,QuicSession, and the three integration points intoInnerService; generalizeSubstream<U>with a stream type parameterServiceBuilder::quic_config(), add a runnable example, and write user-facing documentationWhat this PR does
Adds
Udp(u16)andQuicV1variants to theProtocolenum intentacle-multiaddr, enabling addresses of the form/ip4/<addr>/udp/<port>/quic-v1.Changes in
multiaddr/src/protocol.rs:UDP = 0x0111,QUICV1 = 0x01cdUdp/QuicV1:from_str_peek,from_bytes,write_to_bytes,acquire,Display::fmt, and a newError::InvalidPortvariant for malformed UDP portsChanges in
multiaddr/src/error.rs:Error::InvalidPortvariant for UDP port parsing failuresNo changes to any existing tentacle, yamux, or secio code. The
quicfeature flag and transport-layer address validation (e.g., rejecting DNS-based QUIC addresses) will be introduced in later PRs.Test plan
Tests are organized into three files:
multiaddr/tests/udp.rs— UDP protocol tests:Displayroundtrip: IPv4, IPv6, port 0, port 65535to_vec/TryFrom<Vec<u8>>) roundtrippush/popforUdpprotocol componentacquire()produces'staticprotocols correctlymultiaddr/tests/quic.rs— QuicV1 protocol tests:Displayroundtrip: IPv4, IPv6, port 0, port 65535 (with/quic-v1)/p2p/<peer_id>suffixma_validhelper (same pattern as existing onion tests)push/popforQuicV1protocol componentacquire()produces'staticprotocols correctly/dns4/.../udp/.../quic-v1) parse successfully at the multiaddr layer (rejection is deferred to the transport layer in PR 4)multiaddr/tests/quic.rs— Cross-crate compatibility tests (tentacle vs parity-multiaddr):to_string()in both cratespush/popproduces identical results/quic-v1shared prefix (/ip4/.../udp/...) is binary-identical with parity/quic-v1full bytes are not decodable by parity (expected — parity lacks QuicV1)/quic-v1string is not parseable by parity (expected)/quicis not parseable by tentacle (expected)