somratpro commited on
Commit
2c3158f
·
1 Parent(s): 83aef87

docs: add task summary

Browse files
Files changed (1) hide show
  1. TASK_SUMMARY.md +51 -0
TASK_SUMMARY.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Task Summary: Fixing Outbound Connectivity on Hugging Face Spaces
2
+
3
+ ## Objective
4
+ Enable `n8n` (running on Hugging Face Spaces) to connect to blocked external services like Telegram API and Discord, bypassing the platform's network restrictions.
5
+
6
+ ## Paths Explored
7
+
8
+ ### 1. DNS Resolution Fix (DoH)
9
+ - **Problem**: HF Spaces intercept standard UDP/TCP DNS queries and return sinkholed IPs or `ENOTFOUND` for specific domains (Telegram, WhatsApp, Discord).
10
+ - **Solution**: Implemented a `dns-fix.js` preload script using `NODE_OPTIONS="--require /opt/dns-fix.js"`.
11
+ - **Method**: Monkey-patched `dns.lookup` to fall back to **DNS-over-HTTPS (DoH)** via Cloudflare (`1.1.1.1`) when system DNS fails.
12
+ - **Result**: Successfully resolved the correct IP addresses for `api.telegram.org`.
13
+
14
+ ### 2. Forced DoH & IPv4 Priority
15
+ - **Observation**: Even when DNS worked, connections often failed with `ECONNRESET` or `SSL alert 0`.
16
+ - **Exploration**: Forced DoH for known blocked domains even if system DNS seemed to work (to bypass sinkholed IPs) and set `--dns-result-order=ipv4first`.
17
+ - **Result**: DNS was correct, but TCP/TLS handshakes were still being dropped by the HF firewall.
18
+
19
+ ### 3. Transparent Application-Level Proxy
20
+ - **Idea**: Use Node.js 22's native `fetch()` (based on `undici`) which handles HF's networking better (Happy Eyeballs).
21
+ - **Method**: Monkey-patched `http.request` and `https.request` to route blocked domains through `fetch()`.
22
+ - **Result**: Encountered `Maximum call stack size exceeded` due to recursion between the patch and n8n's `axios`/`follow-redirects` library.
23
+
24
+ ### 4. Comparison with HuggingClaw
25
+ - **Context**: The user pointed to `HuggingClaw` as a working example.
26
+ - **Analysis**: HuggingClaw uses an identical `dns-fix.js` and `Dockerfile` configuration.
27
+ - **Finding**: HuggingClaw's networking works because it likely connects to services that aren't strictly blocked or uses a different internal routing that `n8n` (a larger app) might be disrupting.
28
+
29
+ ## Final Conclusion & Recommendations
30
+
31
+ The connectivity issue on Hugging Face Spaces for `n8n` is a two-layer problem:
32
+ 1. **DNS Layer**: Blocked by intercepting standard DNS queries. **Fixed** via `dns-fix.js`.
33
+ 2. **Network/SNI Layer**: Blocked by a Deep Packet Inspection (DPI) firewall that drops connections to specific hostnames (SNI) or IP ranges even if DNS is correct.
34
+
35
+ ### Best Way Forward
36
+ To reliably connect n8n to Telegram/Discord on HF Spaces, an **Outbound Proxy** is required because the HF firewall is too restrictive for direct connections.
37
+
38
+ **Recommended Proxy Strategy:**
39
+ 1. **Cloudflare Worker Proxy**: A simple 5-line script on a custom `workers.dev` domain (not blocked by HF) to forward requests to Telegram.
40
+ - Example: `https://my-proxy.workers.dev/botTOKEN/getMe` -> `https://api.telegram.org/botTOKEN/getMe`
41
+ 2. **N8N Configuration**:
42
+ - Update `HTTP Request` nodes to use the proxy URL.
43
+ - OR set `N8N_HTTP_PROXY` if using a standard SOCKS5/HTTP proxy (though n8n support for this varies by node type).
44
+
45
+ ## Current State of Repository
46
+ - `dns-fix.js`: Robust DoH fallback with recursion guards.
47
+ - `Dockerfile`: Configured to preload the DNS fix.
48
+ - `access.md`: Contains test tokens and execution logs.
49
+
50
+ > [!IMPORTANT]
51
+ > The current setup fixes the **DNS issue**, but the **Firewall/SNI issue** remains. Future work should focus on implementing a lightweight outbound proxy or using a service like Cloudflare Tunnel if possible.