[Minor fix] The domain dns.google may cause a socket.gaierror exception (#3176)

Co-authored-by: guofangze <guofangze@kuaishou.com>
This commit is contained in:
ttbachyinsda 2024-03-05 03:17:12 +08:00 committed by GitHub
parent 9cbc7e5f3b
commit 76e8a70476
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -173,7 +173,7 @@ def get_ip() -> str:
# try ipv4
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(("dns.google", 80)) # Doesn't need to be reachable
s.connect(("8.8.8.8", 80)) # Doesn't need to be reachable
return s.getsockname()[0]
except OSError:
# try ipv6