mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
fix localhost network tests on systems with IPv6
Thanks to themill from Debian for this suggestion: > https://docs.python.org/3/library/socket.html#socket.socket makes me > think socket.socket has done an ipv4 only but urilib3 will do > whatever localhost resolves to. I suspect the test code should be > using socket.create_server - there's an example at > https://docs.python.org/3/library/socket.html#socket.create_server
This commit is contained in:
parent
99c3ea9966
commit
f01628ca6b
1 changed files with 7 additions and 3 deletions
|
@ -37,9 +37,13 @@ class RetryServer:
|
||||||
self.stop_event.set()
|
self.stop_event.set()
|
||||||
|
|
||||||
def run_fake_server(self):
|
def run_fake_server(self):
|
||||||
server_sock = socket.socket()
|
addr = ('localhost', self.port)
|
||||||
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
if socket.has_dualstack_ipv6():
|
||||||
server_sock.bind(('localhost', self.port))
|
server_sock = socket.create_server(
|
||||||
|
addr, family=socket.AF_INET6, dualstack_ipv6=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
server_sock = socket.create_server(addr)
|
||||||
server_sock.listen(5)
|
server_sock.listen(5)
|
||||||
server_sock.settimeout(5)
|
server_sock.settimeout(5)
|
||||||
time.sleep(0.001) # wait for it to start
|
time.sleep(0.001) # wait for it to start
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue