Skip to content

Commit

Permalink
CI: ignore invalid hostname of some macos runners (ArchipelagoMW#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver authored Oct 2, 2023
1 parent 485aa23 commit f9761ad
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import collections
import importlib
import logging
import warnings

from argparse import Namespace
from settings import Settings, get_settings
Expand Down Expand Up @@ -216,7 +217,13 @@ def get_cert_none_ssl_context():
def get_public_ipv4() -> str:
import socket
import urllib.request
ip = socket.gethostbyname(socket.gethostname())
try:
ip = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
# if hostname or resolvconf is not set up properly, this may fail
warnings.warn("Could not resolve own hostname, falling back to 127.0.0.1")
ip = "127.0.0.1"

ctx = get_cert_none_ssl_context()
try:
ip = urllib.request.urlopen("https://checkip.amazonaws.com/", context=ctx, timeout=10).read().decode("utf8").strip()
Expand All @@ -234,7 +241,13 @@ def get_public_ipv4() -> str:
def get_public_ipv6() -> str:
import socket
import urllib.request
ip = socket.gethostbyname(socket.gethostname())
try:
ip = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
# if hostname or resolvconf is not set up properly, this may fail
warnings.warn("Could not resolve own hostname, falling back to ::1")
ip = "::1"

ctx = get_cert_none_ssl_context()
try:
ip = urllib.request.urlopen("https://v6.ident.me", context=ctx, timeout=10).read().decode("utf8").strip()
Expand Down

0 comments on commit f9761ad

Please sign in to comment.