Spaces:
Sleeping
Sleeping
fix: write DNS results to /etc/hosts for undici/fetch compatibility
Browse filesTelegram's grammY library uses undici (Node 22 built-in fetch) which
bypasses dns.lookup monkey-patching. Writing resolved IPs to /etc/hosts
ensures all DNS clients (including undici) can reach api.telegram.org.
Also chmod 666 /etc/hosts in Dockerfile so the node user can write to it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Dockerfile +1 -0
- scripts/dns-resolve.py +11 -0
Dockerfile
CHANGED
|
@@ -14,6 +14,7 @@ RUN echo "[build][layer1] System deps + tools..." && START=$(date +%s) \
|
|
| 14 |
&& chown node:node /app \
|
| 15 |
&& mkdir -p /home/node/.openclaw/workspace /home/node/.openclaw/credentials \
|
| 16 |
&& chown -R node:node /home/node \
|
|
|
|
| 17 |
&& echo "[build][layer1] System deps + tools: $(($(date +%s) - START))s"
|
| 18 |
|
| 19 |
# ββ εζ’ε° node η¨ζ·οΌεη»ζζζδ½ι½δ»₯ node θΊ«δ»½οΌζ ι chownοΌβββββββββββββββ
|
|
|
|
| 14 |
&& chown node:node /app \
|
| 15 |
&& mkdir -p /home/node/.openclaw/workspace /home/node/.openclaw/credentials \
|
| 16 |
&& chown -R node:node /home/node \
|
| 17 |
+
&& chmod 666 /etc/hosts \
|
| 18 |
&& echo "[build][layer1] System deps + tools: $(($(date +%s) - START))s"
|
| 19 |
|
| 20 |
# ββ εζ’ε° node η¨ζ·οΌεη»ζζζδ½ι½δ»₯ node θΊ«δ»½οΌζ ι chownοΌβββββββββββββββ
|
scripts/dns-resolve.py
CHANGED
|
@@ -94,6 +94,17 @@ def main() -> None:
|
|
| 94 |
with open(output_file, "w") as f:
|
| 95 |
json.dump(results, f, indent=2)
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
print(f"[dns] Resolved {len(results)}/{len(DOMAINS)} domains -> {output_file}")
|
| 98 |
|
| 99 |
|
|
|
|
| 94 |
with open(output_file, "w") as f:
|
| 95 |
json.dump(results, f, indent=2)
|
| 96 |
|
| 97 |
+
# Also write to /etc/hosts so undici/fetch (which bypasses dns.lookup) works
|
| 98 |
+
if results:
|
| 99 |
+
try:
|
| 100 |
+
with open("/etc/hosts", "a") as f:
|
| 101 |
+
f.write("\n# === HuggingClaw DoH resolved domains ===\n")
|
| 102 |
+
for domain, ip in results.items():
|
| 103 |
+
f.write(f"{ip} {domain}\n")
|
| 104 |
+
print(f"[dns] Wrote {len(results)} entries to /etc/hosts")
|
| 105 |
+
except PermissionError:
|
| 106 |
+
print("[dns] WARNING: cannot write /etc/hosts (permission denied)")
|
| 107 |
+
|
| 108 |
print(f"[dns] Resolved {len(results)}/{len(DOMAINS)} domains -> {output_file}")
|
| 109 |
|
| 110 |
|