Repository navigation
Conversation
quic::connect() opened and connected its UDP socket itself, with nothing to bind it to, so a caller that had been told where to send from could not pass that on. c-ares-async, for DNS over QUIC, accepts c-ares' local address and device and drops them (#54). - Config::local_endpoint is bound before the connect, with port 0 for any port. Only the server's endpoints of its family are tried, and without one of them, connect() fails with address_family_not_supported. - Config::device is SO_BINDTODEVICE, Linux only. A name that no interface can have fails with no_such_device: the kernel would cut it short at a NUL or at 15 characters and bind to another interface. - A socket that cannot be set up fails connect() with what the system said, address_not_available for an address that is not this host's, say, where every failure used to be connection_refused. - Connection::remote_endpoint() tells the server where a connection comes from, and the client where it goes. The HTTP/3 and TCP clients are unchanged. Closes #54 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # include/anyhttp/quic.hpp # src/quic/connection.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #54. Of the two ways the issue leaves open, this takes the fields in
quic::Config, not a hook on the socket: they are what c-ares has (ares_set_local_ip4()/_ip6(),ares_set_local_dev()), and the descriptor stays inside the library. The hook can still come if arbitrary socket options are ever needed.API
quic::Config::local_endpoint, an optionalUdpEndpoint, is bound before the connect, with port 0 for any port. Only the server's endpoints of its family are tried; if none is,connect()fails witherrc::address_family_not_supported.quic::Config::deviceis the interface to send through,SO_BINDTODEVICE, Linux only (errc::operation_not_supportedelsewhere). No interface of that name iserrc::no_such_device.quic::Connection::remote_endpoint()tells the server where a connection comes from, and the client where it goes. Without it, only the colouredlog_prefix()showed that.A socket that cannot be set up now fails
connect()with what the system said,errc::address_not_availablefor an address that is not this host's, say. Every failure used to beerrc::connection_refused, which is still what a failed handshake reports.Implementation
QuicClientSession::init()is split in two:open()sets up the socket (open, device, bind, connect) and returns its error,init()makes the connection on it as before.quic::async_connect()skips the endpoints of the other family and throws what the last attempt failed with.io::bind_to_device()is new innet.hpp, defined once on the native handle. It refuses a name with a NUL in it or longer than 15 characters: the kernel would cut it short silently, and bind to whatever interface has the shorter name.QuicSession::remote_endpoint()reads ngtcp2's current path, on either side.client::Confighas no local endpoint for TCP either.Tests
test/test_quic.cpp, both write modes:address_not_available, one of the other family (::1) withaddress_family_not_supported.lo, a connection works;nonexistent0,"lo\0x"(which the kernel would take aslo) and a 16-character name fail withno_such_device.No test proves that the device changes where packets go. A UDP socket bound to eth0 does not reach a server on loopback, but it sends via the default gateway, so such a test would put packets on the network.
Run locally: the whole suite on
build/andbuild-corosio/(gtest-parallel); the QUIC tests onbuild-gcc/; thedocstarget;check_package.sh(the publicquic.hppincludes<optional>now and has newConfigfields); the include-boundary checks of CLAUDE.md, which print nothing. Not run: the sanitizer and h2v2 trees.🤖 Generated with Claude Code