Spaces:
Paused
Paused
Download dns_fix.py from mohammed978/hostbot: direct link, hf CLI and curl.
- Browser
- Download file 571 Bytes
-
https://huggingface.co/spaces/mohammed978/hostbot/resolve/main/dns_fix.py
- Command line
-
hf download hf://spaces/mohammed978/hostbot/dns_fix.py
-
curl -L -o dns_fix.py https://huggingface.co/spaces/mohammed978/hostbot/resolve/main/dns_fix.py
571 Bytes
| import socket | |
| def patch_dns(): | |
| print("[DNS FIX] Patching socket.getaddrinfo to force IPv4 resolution...") | |
| _orig_getaddrinfo = socket.getaddrinfo | |
| def new_getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): | |
| # Force AF_INET (IPv4) resolution except for localhost | |
| if host and host not in ('localhost', '127.0.0.1', '::1'): | |
| return _orig_getaddrinfo(host, port, socket.AF_INET, type, proto, flags) | |
| return _orig_getaddrinfo(host, port, family, type, proto, flags) | |
| socket.getaddrinfo = new_getaddrinfo | |
| patch_dns() | |