diff --git a/Utils.py b/Utils.py index e14a9d3c..4e6ac7d9 100644 --- a/Utils.py +++ b/Utils.py @@ -190,6 +190,17 @@ def get_public_ipv4() -> str: pass # we could be offline, in a local game, so no point in erroring out return ip +def get_public_ipv6() -> str: + import socket + import urllib.request + import logging + ip = socket.gethostbyname(socket.gethostname()) + try: + ip = urllib.request.urlopen('https://v6.ident.me').read().decode('utf8').strip() + except Exception as e: + logging.exception(e) + pass # we could be offline, in a local game, so no point in erroring out + return ip def get_options() -> dict: if not hasattr(get_options, "options"):