8000 wsgi server: address family discovery is not quite right (#1006) · btimby/client_python@6ae7737 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ae7737

Browse files
authored
wsgi server: address family discovery is not quite right (prometheus#1006)
The code introduced to improve binding to an IPv6 address is based on similar code in Python itself, but is missing some critical arguments to the socket.getaddrinfo() call: in particular, the socket type must be set to SOCK_STREAM, because we want a TCP connection; the AI_PASSIVE flag should also be passed because we intend to use the result for binding a listen socket rather than making an outbound connection. Signed-off-by: Joshua M. Clulow <josh@sysmgr.org>
1 parent 1f8ceb7 commit 6ae7737

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prometheus_client/exposition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _get_best_family(address, port):
154154
# binding an ipv6 address is requested.
155155
# This function is based on what upstream python did for http.server
156156
# in https://github.com/python/cpython/pull/11767
157-
infos = socket.getaddrinfo(address, port)
157+
infos = socket.getaddrinfo(address, port, type=socket.SOCK_STREAM, flags=socket.AI_PASSIVE)
158158
family, _, _, _, sockaddr = next(iter(infos))
159159
return family, sockaddr[0]
160160

0 commit comments

Comments
 (0)
0