Ticket #5086 enhancement closed fixed
Accept IPv6 address literals in IReactorUDP.listenUDP
|Reported by:||exarkun||Owned by:||habnabit|
(diff, github, buildbot, log)
Description (last modified by habnabit) (diff)
Similarly to #5084, Twisted should provide low-level support for IPv6 UDP servers. IReactorUDP.listenUDP implementations should accept IPv6 address literals and set up a UDP port bound to that address.
Nothing about how IPv4 support is provided will change - IPv4 address literals and hostnames will continue to listen only on an IPv4 address. The default will still be to listen on INADDR_ANY, which does not include an IPv6 addresses.
The resulting IListeningPort will return an IPv6Address (see #5084) from its getHost implementations.
The protocol will be connected to an IUDPTransport implementation which also returns IPv6Address instances from its getHost implementation.
When a datagram is delivered to the server, the datagramReceived method will be invoked with the address returned by socket.recvfrom (nominally a 4 tuple giving address, port, flow info, and scope id), just as is the case for IPv4 (where only address and port are present in the tuple).
The IUDPTransport.write implementation in this case will also accept a 4 tuple of this sort. Sending to IPv6 addresses in this way is supported, but only if an IPv6 address literal was passed to listenUDP in the first place.
IUDPTransport.getHost is documented as returning IPv4Address instances. This should probably change.
Once this is resolved, Twisted servers should be able to bind UDP ports on IPv6 addresses, eg ::1 or ::, as well as send datagrams to IPv6 address from such ports. Addresses that include an embedded scope id will be supported after #6647 is resolved.