This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
EDtunnel is a Cloudflare Worker/Pages-based proxy tool that implements WebSocket transport protocol for tunneling traffic. It runs on Cloudflare's serverless infrastructure and provides a web-based proxy service with multi-protocol support (VLESS and Trojan).
# Local development
npm run dev # Development with Wrangler (remote mode)
npm run dev-local # Local development with src/index.js
# Production
npm run build # Dry-run deployment check
npm run deploy # Deploy to Cloudflare Workers
npm run bundle # Bundle src/index.js to dist/bundle.js
npm run obfuscate # Bundle + obfuscate → _worker.jssrc/
├── index.js # Entry point, exports fetch handler
├── config/
│ ├── constants.js # Protocol constants, ports, DNS servers
│ └── defaults.js # Default UUID and configuration
├── handlers/
│ ├── main.js # Main request router
│ ├── http.js # HTTP request handling
│ └── websocket.js # WebSocket upgrade and protocol processing
├── protocol/
│ ├── vless.js # VLESS protocol parsing
│ ├── trojan.js # Trojan protocol parsing
│ └── dns.js # DNS query handling over UDP
├── proxy/
│ ├── tcp.js # TCP connection management
│ ├── udp.js # UDP connection handling
│ ├── udp-handler.js # UDP packet processing
│ ├── http.js # HTTP proxy support
│ ├── vless.js # VLESS proxy implementation
│ ├── stream.js # Stream processing utilities
│ └── socks5.js # SOCKS5 proxy client
├── generators/
│ ├── config-page.js # Web UI configuration page
│ └── subscription.js # VLESS/Clash subscription generation
└── utils/
├── encoding.js # Base64 encoding/decoding
├── validation.js # UUID validation
├── parser.js # Configuration parsing
├── crypto.js # Cryptographic utilities
├── proxyResolver.js # Proxy address resolution
└── websocket.js # WebSocket utilities
_worker.js- Obfuscated bundle for Cloudflare deploymentwrangler.toml- Cloudflare Worker configurationdist/bundle.js- Non-obfuscated bundle (intermediate build)
src/index.js→ exportsfetchhandlerhandlers/main.js→ routes by URL path (/cf,/{uuid},/sub/{uuid},/trojan)handlers/websocket.js→ WebSocket upgrade for VLESS/Trojan tunnelingprotocol/vless.jsorprotocol/trojan.js→ parse protocol header, extract destinationproxy/tcp.js,proxy/udp.js, orproxy/socks5.js→ establish outbound connection
Environment variables (set in wrangler.toml or Cloudflare Dashboard):
| Variable | Description |
|---|---|
UUID |
User authentication (comma-separated for multiple) |
PROXYIP |
Proxy server addresses (comma-separated, with optional port) |
SOCKS5 |
SOCKS5 proxy (user:pass@host:port) |
TROJAN_PASSWORD |
Trojan protocol password (optional, uses UUID if not set) |
URL query parameters can override: proxyip, socks5 (UUID cannot be overridden for security).
- Uses Cloudflare's
cloudflare:socketsfor TCP connections - VLESS protocol version 0 with WebSocket transport
- Trojan protocol support with SHA-224 password hashing
- UDP support for DNS queries
- Multi-proxy load balancing via random selection
- Subscription formats: VLESS links, Clash YAML, Base64 encoded
Test files are located in the test/ directory. Run tests during development to verify changes.