add get public v6

This commit is contained in:
Fabian Dill 2020-06-14 09:06:37 +02:00
parent a5bb3e3f59
commit aebdf3b66e
1 changed files with 11 additions and 0 deletions

View File

@ -190,6 +190,17 @@ def get_public_ipv4() -> str:
pass # we could be offline, in a local game, so no point in erroring out pass # we could be offline, in a local game, so no point in erroring out
return ip 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: def get_options() -> dict:
if not hasattr(get_options, "options"): if not hasattr(get_options, "options"):