`get_ip()`: Fix ipv4 ipv6 dualstack (#2408)

This commit is contained in:
Yunfeng Bai 2024-01-10 11:39:58 -08:00 committed by GitHub
parent 79d64c4954
commit 4b61c6b669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -58,7 +58,9 @@ def in_wsl() -> bool:
def get_ip() -> str:
return socket.gethostbyname(socket.gethostname())
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80)) # Doesn't need to be reachable
return s.getsockname()[0]
def get_open_port() -> int: