Spaces:
Sleeping
Sleeping
fix: add Telegram domains to DNS-over-HTTPS pre-resolution
Browse filesTelegram Bot API (api.telegram.org) was failing with network errors
on HF Spaces due to DNS resolution issues. Added api.telegram.org
to the DoH pre-resolve list alongside WhatsApp domains.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- scripts/dns-resolve.py +8 -4
- scripts/entrypoint.sh +1 -1
scripts/dns-resolve.py
CHANGED
|
@@ -22,14 +22,17 @@ DOH_ENDPOINTS = [
|
|
| 22 |
"https://dns.google/resolve", # Google (hostname)
|
| 23 |
]
|
| 24 |
|
| 25 |
-
# Domains that WhatsApp/Baileys
|
| 26 |
DOMAINS = [
|
|
|
|
| 27 |
"web.whatsapp.com",
|
| 28 |
"g.whatsapp.net",
|
| 29 |
"mmg.whatsapp.net",
|
| 30 |
"pps.whatsapp.net",
|
| 31 |
"static.whatsapp.net",
|
| 32 |
"media.fmed1-1.fna.whatsapp.net",
|
|
|
|
|
|
|
| 33 |
]
|
| 34 |
|
| 35 |
|
|
@@ -70,13 +73,14 @@ def main() -> None:
|
|
| 70 |
try:
|
| 71 |
import socket
|
| 72 |
socket.getaddrinfo("web.whatsapp.com", 443, socket.AF_INET)
|
| 73 |
-
|
|
|
|
| 74 |
# Write empty file so dns-fix.cjs knows it's not needed
|
| 75 |
with open(output_file, "w") as f:
|
| 76 |
json.dump({}, f)
|
| 77 |
return
|
| 78 |
-
except (socket.gaierror, OSError):
|
| 79 |
-
print("[dns] System DNS
|
| 80 |
|
| 81 |
results = {}
|
| 82 |
for domain in DOMAINS:
|
|
|
|
| 22 |
"https://dns.google/resolve", # Google (hostname)
|
| 23 |
]
|
| 24 |
|
| 25 |
+
# Domains that WhatsApp/Baileys and Telegram need to connect to
|
| 26 |
DOMAINS = [
|
| 27 |
+
# WhatsApp / Baileys
|
| 28 |
"web.whatsapp.com",
|
| 29 |
"g.whatsapp.net",
|
| 30 |
"mmg.whatsapp.net",
|
| 31 |
"pps.whatsapp.net",
|
| 32 |
"static.whatsapp.net",
|
| 33 |
"media.fmed1-1.fna.whatsapp.net",
|
| 34 |
+
# Telegram Bot API
|
| 35 |
+
"api.telegram.org",
|
| 36 |
]
|
| 37 |
|
| 38 |
|
|
|
|
| 73 |
try:
|
| 74 |
import socket
|
| 75 |
socket.getaddrinfo("web.whatsapp.com", 443, socket.AF_INET)
|
| 76 |
+
socket.getaddrinfo("api.telegram.org", 443, socket.AF_INET)
|
| 77 |
+
print("[dns] System DNS works for WhatsApp & Telegram β DoH not needed")
|
| 78 |
# Write empty file so dns-fix.cjs knows it's not needed
|
| 79 |
with open(output_file, "w") as f:
|
| 80 |
json.dump({}, f)
|
| 81 |
return
|
| 82 |
+
except (socket.gaierror, OSError) as e:
|
| 83 |
+
print(f"[dns] System DNS failed ({e}) β using DoH fallback")
|
| 84 |
|
| 85 |
results = {}
|
| 86 |
for domain in DOMAINS:
|
scripts/entrypoint.sh
CHANGED
|
@@ -7,7 +7,7 @@ echo "[entrypoint] OpenClaw HuggingFace Spaces Entrypoint"
|
|
| 7 |
echo "[entrypoint] ======================================="
|
| 8 |
|
| 9 |
# ββ DNS pre-resolution (run in BACKGROUND β was 121s blocking) ββββββββββββββ
|
| 10 |
-
echo "[entrypoint] Resolving WhatsApp domains via DNS-over-HTTPS (background)..."
|
| 11 |
DNS_START=$(date +%s)
|
| 12 |
(
|
| 13 |
python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1
|
|
|
|
| 7 |
echo "[entrypoint] ======================================="
|
| 8 |
|
| 9 |
# ββ DNS pre-resolution (run in BACKGROUND β was 121s blocking) ββββββββββββββ
|
| 10 |
+
echo "[entrypoint] Resolving WhatsApp & Telegram domains via DNS-over-HTTPS (background)..."
|
| 11 |
DNS_START=$(date +%s)
|
| 12 |
(
|
| 13 |
python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1
|