Merge pull request #2 from YunoHost/fix-ipv6

ipv6 support
This commit is contained in:
Alexandre Aubin 2020-04-11 16:12:26 +02:00 committed by GitHub
commit 6216deb5cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,7 +59,10 @@ def check_rate_limit(key, now):
async def check_port_is_open(ip, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if ":" in ip:
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
result = sock.connect_ex((ip, port))
sock.close()