From aebdf3b66ee8d623502a11dff416ad0229580fcc Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 14 Jun 2020 09:06:37 +0200 Subject: [PATCH] add get public v6 --- Utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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"):