Accept IPv6 address literals (with embedded scope ids) in IReactorTCP.listenTCP
|Reported by:||exarkun||Owned by:||exarkun|
(github, coverage, patch, buildbot, log)
As an early step towards good IPv6 support, the reactor needs to be able to set up listening TCP ports on IPv6 addresses. Since previously it was an error to pass an IPv6 literal to any listenTCP implementation, we can begin supporting that without breaking any existing software.
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 from its getHost implementations.
When a connection is established to the server, the factory's buildProtocol method will be invoked with an IPv6Address instance giving the peer's address.
The protocol will be connected to an ITCPTransport implementation which also returns IPv6Address instances from its getHost and getPeer implementations.
ITCPTransport.getPeer and ITCPTransport.getHost are documented as returning IPv4Address instances. This should probably change.
IPv6Address is very similar to IPv4Address. It has host and port attributes. It might even be possible to use the same class for each of these, but having two makes it easier to tell the address family apart so I think it's a good idea. If we ever support scopeid or flowid more explicitly, it may be useful to expose those as attributes on IPv6Address as well.
Once this is resolved, Twisted servers should be able to listen for TCP connections on IPv6 addresses, eg ::1 or fe80::1%lo0 or ::. Note that where the platform requires the scope id, listenTCP will require the scope id.
Change History (16)
comment:6 Changed 5 years ago by exarkun
- Branch changed from branches/listentcp-ipv6-5084 to branches/listentcp-ipv6-5084-2
comment:7 Changed 5 years ago by exarkun
- Branch changed from branches/listentcp-ipv6-5084-2 to branches/listentcp-ipv6-5084-3
comment:13 Changed 4 years ago by exarkun
- Branch changed from branches/listentcp-ipv6-5084-3 to branches/listentcp-ipv6-5084-4