Properly handle AF_INET6 requests

Socket addresses in the Python socket interface are represented in
multiple different ways according to the socket family. Both AF_INET and
AF_INET6 families use tuples with the host as the first element.

Currently we extract the host from the first element of such a tuple,
and ignore the other element. Since AF_INET6 has four elements, this
will fail with a ValueError.

To support AF_INET6 requests, make sure to store whatever is left of the
tuple in a list instead.
This commit is contained in:
Wolfgang Müller 2021-10-15 10:01:02 +02:00 committed by Juhani Krekelä
parent cc26741d9c
commit c29417f726
1 changed files with 1 additions and 1 deletions

View File

@ -431,7 +431,7 @@ def listen(port):
while True:
for fd, _ in listening.poll():
# TODO: Threads
conn, (host, _) = sock_by_fd[fd].accept()
conn, (host, *_) = sock_by_fd[fd].accept()
proxy(conn, host)
conn.close()