mirror of
https://github.com/f-droid/fdroidserver.git
synced 2026-02-19 15:57:47 -05: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:
@@ -37,9 +37,13 @@ class RetryServer:
|
||||
self.stop_event.set()
|
||||
|
||||
def run_fake_server(self):
|
||||
server_sock = socket.socket()
|
||||
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
server_sock.bind(('localhost', self.port))
|
||||
addr = ('localhost', self.port)
|
||||
if socket.has_dualstack_ipv6():
|
||||
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.settimeout(5)
|
||||
time.sleep(0.001) # wait for it to start
|
||||
|
||||
Reference in New Issue
Block a user