[issue20215] socketserver.TCPServer can not listen IPv6 address

2016-08-02 Thread Paul Marks

Paul Marks added the comment:

> if the user specifically wants to bind to a numeric IPv4 address, is there 
> any advantage of choosing the dual-stack [...]?

If you're in a position to write AF_INET6-only code, then dualstack sockets can 
make things a bit cleaner (one family for all IP communication).  But given 
that Python couldn't reasonably drop support for AF_INET-only systems, there's 
not a compelling reason to prefer dualstack sockets for IPv4 stuff.

They're just two windows into the same kernel code, so the decision is mostly 
arbitrary.

However, Python likes to expose IP addresses as plain strings without 
transparent :::0.0.0.0/96 handling, which tends to make dualstack sockets a 
leaky abstraction.  Ideally, you'd be able to talk to the kernel using AF_INET 
or AF_INET6 without normal users knowing the difference.

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20215>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20215] socketserver.TCPServer can not listen IPv6 address

2016-08-02 Thread Paul Marks

Paul Marks added the comment:

First off, the server_address=('localhost', port) case: this feature is 
fundamentally broken without support for multiple sockets, because the server 
can listen on at most one address, and any single choice will often be 
inconsistent with clients' expectations.

For the (ip, port) case, the only question is whether an IPv4 address should 
create an AF_INET or dualstack (IPV6_V6ONLY=0) AF_INET6 socket; the latter 
needs a.b.c.d -> :::a.b.c.d translation.

Then there's the typical ('', port) case.  This should ideally create a server 
that accepts a connection on any supported family:
- If the system supports dualstack AF_INET6 sockets, use one.
- If the system only supports AF_INET sockets, use AF_INET.
- If the system only supports AF_INET6 sockets, use AF_INET6.
- If the system supports AF_INET and AF_INET6, but not dualstack, then you need 
multiple sockets.  Or go with AF_INET and hope nobody needs IPv6 on such a 
system.

(The legacy-free simple approach is to hard-code AF_INET6 and let the OS decide 
whether the socket should be dualstack or IPv6-only, but that only supports 2/4 
of the above cases.)

Users of "conn, addr = self.get_request()" often expect addr to be an IPv4 
2-tuple, especially when handling IPv4 requests.  So you have to normalize 
(':::192.0.2.1', 1234, 0, 0) to ('192.0.2.1', 1234).  For real IPv6 
requests, it's often more convenient to keep returning 2-tuples ('2001:db8::1', 
1234) instead of 4-tuples.

Another thing to watch out for is this HTTPServer code:
host, port = self.socket.getsockname()[:2]
self.server_name = socket.getfqdn(host)

getfqdn() has a special case for '0.0.0.0', which doesn't recognize the IPv6 
equivalents:
>>> import socket
>>> socket.getfqdn('0.0.0.0')
   'redacted.corp.google.com'
>>> socket.getfqdn('::')
   '::'
   >>> socket.getfqdn(':::0.0.0.0')
   ':::0.0.0.0'

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20215>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20215] socketserver.TCPServer can not listen IPv6 address

2016-08-02 Thread Paul Marks

Changes by Paul Marks <pma...@google.com>:


--
nosy: +Paul Marks

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20215>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24357] www.python.org lost IPv6 connectivity

2015-06-01 Thread Paul Marks

New submission from Paul Marks:

Python's web servers were formerly reachable from IPv6 clients, as evidenced by 
this example code for socket.getaddrinfo():

https://docs.python.org/3/library/socket.html#socket.getaddrinfo

But today, www.python.org is IPv4-only:

 import socket
 socket.getaddrinfo(www.python.org, 80, proto=socket.IPPROTO_TCP)
[(AddressFamily.AF_INET: 2, SocketType.SOCK_STREAM: 1, 6, '', 
('23.235.40.223', 80))]

Please either restore IPv6 connectivity to www.python.org, or accept the shame 
and defeat of pointing the documentation to someone else's domain.

--
assignee: docs@python
components: Documentation
messages: 244625
nosy: Paul Marks, docs@python
priority: normal
severity: normal
status: open
title: www.python.org lost IPv6 connectivity

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24357
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com