### Using Recommended IPs and CDN Domains (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Bash examples demonstrating how to use recommended Cloudflare IPs and CDN domains in client configurations. Includes direct IP usage and CDN domain usage, as well as V2rayN client load balancing setup. ```bash # 直接使用官方 IP 作为节点地址 vless://uuid@104.16.0.0:443?... # 使用 CDN 优选域名 vless://uuid@yg1.ygkkk.dpdns.org:443?... # 客户端负载均衡配置(V2rayN) # 添加多个节点使用不同 IP 节点1: 104.16.0.0:443 节点2: 104.17.0.0:443 节点3: 104.18.0.0:443 # 启用自动选择或负载均衡模式 ``` -------------------------------- ### Client Usage Examples with Standard Ports (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Bash examples demonstrating VLESS client configurations using standard Cloudflare ports for both TLS and non-TLS connections. These examples show how to specify ports and other parameters in the VLESS URL format. ```bash # TLS 节点(443系列端口) vless://uuid@104.16.0.0:443?encryption=none&security=tls&sni=your-worker.workers.dev&type=ws&host=your-worker.workers.dev&path=/#TLS-443 vless://uuid@104.16.0.0:2053?encryption=none&security=tls&sni=your-worker.workers.dev&type=ws&host=your-worker.workers.dev&path=/#TLS-2053 # 非TLS 节点(80系列端口) vless://uuid@104.16.0.0:80?encryption=none&security=none&type=ws&host=your-worker.workers.dev&path=/#NoTLS-80 vless://uuid@104.16.0.0:8080?encryption=none&security=none&type=ws&host=your-worker.workers.dev&path=/#NoTLS-8080 ``` -------------------------------- ### Client Subscription URL Usage Examples (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Bash examples demonstrating how to use subscription URLs in various clients like V2rayN, V2rayNG, Clash, and Sing-box. These commands illustrate adding subscription links for automatic configuration updates. ```bash # V2rayN/V2rayNG 客户端 # 1. 打开客户端 # 2. 订阅设置 -> 添加订阅 # 3. 输入订阅地址: https://your-worker.workers.dev/your-uuid/ty # 4. 更新订阅 # Clash 客户端 # 1. 配置 -> 远程配置 # 2. 添加 URL: https://your-worker.workers.dev/your-uuid/cl # 3. 更新配置 # Sing-box 客户端 # 1. 配置文件 # 2. 从 URL 导入: https://your-worker.workers.dev/your-uuid/sb # 3. 应用配置 ``` -------------------------------- ### Install CF Preferred IP Script (Bash) Source: https://github.com/yonggekkk/cloudflare_vless_trojan/blob/main/README.md This script automates the selection and setup of preferred Cloudflare IPs for VLESS/Trojan connections. It is designed for Android and iOS devices and requires a supported environment like Termux or iSH. Ensure you have the correct versions of Termux or iSH installed before running. ```bash curl -sSL https://raw.githubusercontent.com/yonggekkk/Cloudflare_vless_trojan/main/cf/cf.sh -o cf.sh && chmod +x cf.sh && bash cf.sh ``` -------------------------------- ### Pages Subscription Path Examples (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Bash examples showing how to construct subscription URLs for Cloudflare Pages deployments. These URLs are used to fetch configurations for different clients like generic, Clash, and Sing-box. ```bash # Pages 通用订阅: /${uuid}/pty 或 /${pswd}/pty # Pages Clash 订阅: /${uuid}/pcl 或 /${pswd}/pcl # Pages Sing-box 订阅: /${uuid}/psb 或 /${pswd}/psb # 示例 curl https://your-project.pages.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40/pty curl https://your-project.pages.dev/trojan/pcl ``` -------------------------------- ### Install CF CDN Preferred Domain Script (Bash) Source: https://github.com/yonggekkk/cloudflare_vless_trojan/blob/main/README.md This script is used to set up preferred Cloudflare CDN public domain names for VLESS/Trojan connections. It is intended for use on mobile devices (Android/iOS) via Termux or iSH. Follow the environment setup instructions before executing. ```bash curl -sSL https://gitlab.com/rwkgyg/CFwarp/raw/main/point/CFcdnym.sh -o CFcdnym.sh && chmod +x CFcdnym.sh && bash CFcdnym.sh ``` -------------------------------- ### Path-Level ProxyIP Configuration Examples (Bash/JSON) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt These examples demonstrate how to dynamically set the ProxyIP for individual nodes using URL path parameters, without affecting the global configuration. This is shown for VLESS and Trojan protocols in bash, and a corresponding client configuration is provided in JSON format for V2rayN/V2rayNG. ```bash # IPv4 地址示例 vless://uuid@优选IP:端口?path=/pyip=192.168.1.1#节点名称 # IPv6 地址示例 vless://uuid@优选IP:端口?path=/pyip=[2001:db8::1]#节点名称 # 域名示例 vless://uuid@优选IP:端口?path=/pyip=proxy.example.com#节点名称 # 非443端口示例 vless://uuid@优选IP:端口?path=/pyip=192.168.1.1:8443#节点名称 # Trojan 协议示例 trojan://password@优选IP:端口?path=/pyip=proxy.example.com#节点名称 ``` ```json // V2rayN/V2rayNG 配置 { "address": "104.16.0.0", "port": 443, "uuid": "86c50e3a-5b87-49dd-bd20-03c7f2735e40", "network": "ws", "path": "/pyip=proxy.example.com", "host": "your-worker.workers.dev", "tls": "tls" } ``` -------------------------------- ### Environment Variable Configuration Examples (JSON) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt These JSON examples illustrate how to configure environment variables for VLESS and Trojan proxies within Cloudflare Workers/Pages. They specify settings like UUID, proxy IPs, CDN IPs, and ports. The 'proxyip' configuration supports various formats including IPv4, IPv6, and domain names, with optional port specification. ```json // VLESS 环境变量配置 { "uuid": "自定义-UUID-格式字符串", "proxyip": "自定义ProxyIP地址", "cdnip": "www.visa.com.sg", "ip1": "www.visa.com", "ip2": "cis.visa.com", "ip8": "usa.visa.com", "pt1": "80", "pt8": "443" } // Trojan 环境变量配置 { "pswd": "自定义密码", "proxyip": "自定义ProxyIP地址", "cdnip": "www.visa.com.sg", "ip1": "www.visa.com", "pt1": "80", "pt8": "443" } ``` ```javascript // ProxyIP 配置示例: // IPv4 地址(443端口) "proxyip": "192.168.1.1" // IPv4 地址(非443端口) "proxyip": "192.168.1.1:8443" // IPv6 地址(443端口) "proxyip": "[2001:db8::1]" // IPv6 地址(非443端口) "proxyip": "[2001:db8::1]:8443" // 域名(443端口) "proxyip": "proxy.example.com" // 域名(非443端口) "proxyip": "proxy.example.com:8443" ``` -------------------------------- ### Install CF Preferred IP Script with Speed Test (Bash) Source: https://github.com/yonggekkk/cloudflare_vless_trojan/blob/main/README.md This script installs a Cloudflare preferred IP selection tool that includes a speed test feature. It is suitable for mobile platforms like Android and iOS when run within Termux or iSH. Prior to execution, ensure necessary dependencies are installed. ```bash curl -sSL https://gitlab.com/rwkgyg/CFwarp/raw/main/point/cfip.sh -o cfip.sh && chmod +x cfip.sh && bash cfip.sh ``` -------------------------------- ### Cloudflare Pages Deployment Configuration (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Bash commands and instructions for deploying the proxy service on Cloudflare Pages. This includes steps for project creation, file uploads, environment variable setup, and accessing the deployed service. ```bash # 1. 登录 Cloudflare Pages 控制台 # 2. 创建新项目 # 3. 上传文件(重命名为 _worker.js) # VLESS Pages 部署 # 上传文件: Vless_workers_pages/nat64套壳版混淆.js # 重命名为: _worker.js # 特点: 自动填充 nat64 ProxyIP,无需手动设置 # Trojan Pages 部署 # 上传文件: Trojan_workers_pages/_worker混淆.js # 重命名为: _worker.js # 需要: 必须手动设置 ProxyIP 环境变量 # 4. 设置环境变量 # 进入 Pages 项目 -> 设置 -> 环境变量 # 添加变量: uuid 或 pswd # 添加变量: proxyip (如需访问 CF 类网站) # 5. 部署完成后访问 # https://your-project.pages.dev/your-uuid # https://your-project.pages.dev/your-pswd ``` -------------------------------- ### Clash Subscription Format (YAML) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Example YAML output for Clash subscription. This format defines proxy server configurations, including protocol type, server address, port, UUID, TLS settings, and WebSocket options. ```yaml proxies: - name: "USA" type: vless server: usa.visa.com port: 443 uuid: 86c50e3a-5b87-49dd-bd20-03c7f2735e40 tls: true servername: your-worker.workers.dev network: ws ws-opts: path: / headers: Host: your-worker.workers.dev ``` -------------------------------- ### Sing-box Subscription Format (JSON) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Example JSON output for Sing-box subscription. This format is used for configuring outbound connections in Sing-box clients, specifying server details, UUID, and transport options. ```json { "outbounds": [ { "type": "vless", "tag": "USA", "server": "usa.visa.com", "server_port": 443, "uuid": "86c50e3a-5b87-49dd-bd20-03c7f2735e40", "tls": { "enabled": true, "server_name": "your-worker.workers.dev" }, "transport": { "type": "ws", "path": "/", "headers": { "Host": "your-worker.workers.dev" } } } ] } ``` -------------------------------- ### Serv00 One-Click Script for sing-box-yg Source: https://github.com/yonggekkk/cloudflare_vless_trojan/blob/main/README.md This bash script is specifically designed for Serv00 environments to set up sing-box with support for VLESS-reality, VMess-WS (argo), and Hysteria2. It enhances the default sing-box installation by adding support for Cloudflare VLESS/Trojan nodes' proxy IPs and non-standard port reverse proxy IPs. ```bash bash <(curl -Ls https://raw.githubusercontent.com/yonggekkk/sing-box-yg/main/serv00.sh) ``` -------------------------------- ### Cloudflare Standard Port Configuration (JavaScript) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt JavaScript arrays defining standard HTTP and HTTPS ports supported by Cloudflare. Also includes an example JSON object for configuring these ports as environment variables for proxy services. ```javascript // HTTP 端口(80系列 - 关闭TLS) const HTTP_PORTS = [80, 8080, 8880, 2052, 2082, 2086, 2095]; // HTTPS 端口(443系列 - 开启TLS) const HTTPS_PORTS = [443, 2053, 2083, 2087, 2096, 8443]; // 环境变量端口配置示例 { "pt1": "80", // HTTP端口1 "pt2": "8080", // HTTP端口2 "pt3": "8880", // HTTP端口3 "pt4": "2052", // HTTP端口4 "pt5": "2082", // HTTP端口5 "pt6": "2086", // HTTP端口6 "pt7": "2095", // HTTP端口7 "pt8": "443", // HTTPS端口1 "pt9": "8443", // HTTPS端口2 "pt10": "2053", // HTTPS端口3 "pt11": "2083", // HTTPS端口4 "pt12": "2087", // HTTPS端口5 "pt13": "2096" // HTTPS端口6 } ``` -------------------------------- ### Subscription Format Conversion Interface (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt The project provides an interface through Cloudflare Workers/Pages to automatically generate subscription links in multiple formats, ensuring compatibility with various client applications. These subscription links are Base64 encoded and are accessible via specific paths, such as '/${uuid}/ty' for VLESS or '/${pswd}/ty' for Trojan. ```bash # 通用订阅格式(Base64编码) # 路径: /${uuid}/ty 或 /${pswd}/ty # 格式: vless:// 和 trojan:// 链接的 Base64 编码 ``` -------------------------------- ### VLESS Worker Deployment API Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt This API allows for the deployment of VLESS protocol proxies via Cloudflare Workers. It supports WebSocket connections and provides various subscription format exports. ```APIDOC ## VLESS Worker Deployment API ### Description This API endpoint facilitates the deployment of VLESS protocol proxies through Cloudflare Workers. It enables WebSocket connections and offers multiple subscription format exports for client configuration. ### Method GET ### Endpoint `/your-worker.workers.dev/{userID}` `/your-worker.workers.dev/{userID}/ty` `/your-worker.workers.dev/{userID}/sb` `/your-worker.workers.dev/{userID}/cl` ### Parameters #### Path Parameters - **userID** (string) - Required - Your unique user identifier (UUID). #### Query Parameters None #### Request Body None ### Request Example ```bash # Access configuration page to get node information curl https://your-worker.workers.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40 # Get generic subscription link curl https://your-worker.workers.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40/ty # Get sing-box subscription curl https://your-worker.workers.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40/sb # Get clash subscription curl https://your-worker.workers.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40/cl ``` ### Response #### Success Response (200) - **Content** (string) - The response content varies based on the requested path. It can be HTML for the configuration page or plain text/JSON for subscription links. #### Response Example ```html VLESS Config

VLESS Node Configuration

Address: your-worker.workers.dev

Port: 443

UUID: 86c50e3a-5b87-49dd-bd20-03c7f2735e40

Path: /

Security: auto

Encryption: none

``` ```json // Example for sing-box subscription { "version": "2", "ports": { "socks": 1080, "http": 1081 }, "socks-port": 1080, "redir-port": 1088, "mixed-port": 1087, "bind-address": "127.0.0.1", "ipv6": false, "mode": "local", "log-level": "info", "allow-lan": true, "external-controller": "127.0.0.1:9090", "dns": { "servers": [ "1.1.1.1" ], "rules": [ { "domain": ".all.google.com", "server": "1.1.1.1" } ], "finally": [ { "domain": ".googledomains.com", "ip_version": "4", "server": "8.8.8.8" } ] }, "proxy-providers": { "default": { "type": "http", "url": "https://your-worker.workers.dev/86c50e3a-5b87-49dd-bd20-03c7f2735e40/ty", "interval": 3600 } }, "proxies": [ { "name": "VLESS-WS-TLS", "server": "your-worker.workers.dev", "port": 443, "type": "vless", "uuid": "86c50e3a-5b87-49dd-bd20-03c7f2735e40", "flow": "", "cipher": "auto", "network": "ws", "tls": { "enabled": true, "serverName": "your-worker.workers.dev", "allowInsecure": false, "alpn": [] }, "ws-opts": { "path": "/", "headers": { "Host": "your-worker.workers.dev" } } } ], "rules": [ { "domain": ".youtube.com", "type": "field", "outbound-tag": "proxy" }, { "domain": ".google.com", "type": "field", "outbound-tag": "proxy" }, { "ip": "1.1.1.1", "type": "field", "outbound-tag": "proxy" }, { "rule-set": "https://example.com/rule.yaml", "type": "field", "outbound-tag": "proxy" }, { "type": "field", "outbound-tag": "direct" } ], "strategy": "ipv4", "routing-core": "geosite", "geosite": "geo/geosite.dat", "geoip": "geo/geoip.dat" } ``` -------------------------------- ### Recommended Cloudflare IPs and CDN Domains (JavaScript) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt JavaScript arrays containing recommended Cloudflare IPv4 and IPv6 addresses, along with CDN domains for optimized routing. These can be used directly in client configurations or for load balancing. ```javascript // IPv4 官方 IP 列表 const RECOMMENDED_IPS_V4 = [ "104.16.0.0", "104.17.0.0", "104.18.0.0", "104.19.0.0", "104.20.0.0", "104.21.0.0", "104.22.0.0", "104.24.0.0", "104.25.0.0", "104.26.0.0", "104.27.0.0", "172.66.0.0", "172.67.0.0", "162.159.0.0" ]; // IPv6 官方 IP const RECOMMENDED_IPS_V6 = [ "2606:4700::0" // 需要 IPv6 网络环境 ]; // CDN 优选域名(甬哥维护) const CDN_DOMAINS = [ "yg1.ygkkk.dpdns.org", // yg1-yg11 任意数字 "yg2.ygkkk.dpdns.org", "yg3.ygkkk.dpdns.org", "yg4.ygkkk.dpdns.org", "yg5.ygkkk.dpdns.org" ]; ``` -------------------------------- ### Subscription Format Conversion API Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Cloudflare Workers/Pages automatically provide subscription links in various formats compatible with different clients. ```APIDOC ## Subscription Format Conversion API ### Description Workers and Pages automatically generate subscription links in multiple formats to ensure compatibility with a wide range of client applications. ### Available Subscription Formats - **General Subscription (Base64 Encoded)**: - **Path**: `/${uuid}/ty` for VLESS or `/${pswd}/ty` for Trojan. - **Format**: This link contains Base64 encoded strings for `vless://` and `trojan://` URLs. ### Usage Access the specific path for the desired protocol to retrieve the Base64 encoded subscription link. ``` -------------------------------- ### Cloudflare Optimized IP Selection Script (Bash) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt This bash script, designed for environments like Termux on Android or iSH on iOS, automates the process of testing and selecting optimal Cloudflare IP addresses. It downloads necessary tools and IP lists, performs tests, and categorizes results by region. The script includes options for IPv4, IPv6, or combined optimization, resetting configuration, and exiting. ```bash #!/bin/bash # 文件: cf/cf.sh # 下载并运行脚本 curl -sSL https://raw.githubusercontent.com/yonggekkk/Cloudflare_vless_trojan/main/cf/cf.sh -o cf.sh chmod +x cf.sh bash cf.sh # 脚本会提示选择优选类型 # 1、仅IPV4优选 # 2、仅IPV6优选 # 3、IPV4+IPV6优选 # 4、重置配置文件 # 5、退出 # 选择1进行 IPv4 优选 # 输入: 1 # 脚本自动下载测试程序和 IP 列表 # 测试完成后输出结果 ``` ```bash # 脚本工作流程: # 1. 检测系统架构 case "$(uname -m)" in x86_64 | x64 | amd64 ) cpu=amd64 ;; armv8 | arm64 ) cpu=arm64 ;; armv7l ) cpu=arm ;; esac # 2. 下载对应架构的测试程序 curl -L -o cf https://raw.githubusercontent.com/.../cf/$cpu chmod +x cf # 3. 下载 IP 列表和地理位置数据 curl -s -o locations.json https://raw.githubusercontent.com/.../locations.json curl -s -o ips-v4.txt https://raw.githubusercontent.com/.../ips-v4.txt # 4. 执行测试并输出结果 ./cf -ips 4 -outfile 4.csv # 5. 按地区分类并排序 awk -F ',' '$2 ~ /LAX|SFO|SEA/' 4.csv | sort -t ',' -k5,5n | head -n 3 > US-4.csv awk -F ',' '$2 ~ /HKG|SIN|TPE/' 4.csv | sort -t ',' -k5,5n | head -n 3 > AS-4.csv awk -F ',' '$2 ~ /LHR|FRA|AMS/' 4.csv | sort -t ',' -k5,5n | head -n 3 > EU-4.csv ``` -------------------------------- ### Environment Variable Configuration API Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt This section describes the environment variables that can be set in the Cloudflare Workers/Pages console to customize the proxy configuration for both VLESS and Trojan protocols. ```APIDOC ## Environment Variable Configuration API ### Description Set environment variables in the Cloudflare Workers/Pages console to customize proxy configurations. This allows for flexible setup of UUIDs, proxy IPs, CDN origins, and port forwarding rules. ### Parameters #### VLESS Environment Variables - **uuid** (string) - Optional - Custom UUID for VLESS protocol. - **proxyip** (string) - Optional - Custom Proxy IP address or domain. Can include port (e.g., `192.168.1.1:8443`). - **cdnip** (string) - Optional - CDN IP address, defaults to `www.visa.com.sg`. - **ip1** (string) - Optional - Preferred IP address for direct connection, defaults to `www.visa.com`. - **ip2** (string) - Optional - Another preferred IP address, defaults to `cis.visa.com`. - **ip8** (string) - Optional - Yet another preferred IP address, defaults to `usa.visa.com`. - **pt1** (string) - Optional - Port for `ip1`, defaults to `80`. - **pt8** (string) - Optional - Port for `ip8`, defaults to `443`. #### Trojan Environment Variables - **pswd** (string) - Optional - Custom password for Trojan protocol, defaults to `trojan`. - **proxyip** (string) - Optional - Custom Proxy IP address or domain. Can include port (e.g., `192.168.1.1:8443`). - **cdnip** (string) - Optional - CDN IP address, defaults to `www.visa.com.sg`. - **ip1** (string) - Optional - Preferred IP address for direct connection, defaults to `www.visa.com`. - **pt1** (string) - Optional - Port for `ip1`, defaults to `80`. - **pt8** (string) - Optional - Port for `ip8`, defaults to `443`. ### ProxyIP Configuration Examples - IPv4 Address (port 443): `192.168.1.1` - IPv4 Address (custom port): `192.168.1.1:8443` - IPv6 Address (port 443): `[2001:db8::1]` - IPv6 Address (custom port): `[2001:db8::1]:8443` - Domain (port 443): `proxy.example.com` - Domain (custom port): `proxy.example.com:8443` ``` -------------------------------- ### Trojan Worker Deployment (JavaScript) Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt This JavaScript code deploys a Trojan protocol proxy using Cloudflare Workers with password authentication. It handles WebSocket connections, serves configuration pages, and supports dynamic ProxyIP settings via environment variables or URL parameters. Dependencies include 'cloudflare:sockets'. ```javascript // 部署到 Cloudflare Workers // 文件: Trojan_workers_pages/_worker.js import { connect } from "cloudflare:sockets"; // 配置密码 let Pswd = "trojan"; // 配置 ProxyIP const proxyIPs = [""]; // 配置优选域名和 IP let CDNIP = 'www.visa.com.sg'; let IP1 = 'www.visa.com'; export default { async fetch(request, env, ctx) { // 从环境变量读取密码 Pswd = env.pswd || Pswd; // 处理 ProxyIP 配置 const { proxyip } = env; if (proxyip) { [proxyIP, proxyPort = '443'] = proxyip.split(':'); } // 生成 SHA224 哈希密码 sha224Password = sha256.sha224(Pswd); const upgradeHeader = request.headers.get("Upgrade"); const url = new URL(request.url); if (!upgradeHeader || upgradeHeader !== "websocket") { // 返回配置页面 if (url.pathname === `/${Pswd}`) { const ygkkkConfig = getygkkkConfig(Pswd, request.headers.get("Host")); return new Response(ygkkkConfig, { status: 200, headers: { "Content-Type": "text/html;charset=utf-8" } }); } // 订阅路径 if (url.pathname === `/${Pswd}/ty`) { const tyConfig = gettyConfig(Pswd, request.headers.get('Host')); return new Response(tyConfig, { status: 200, headers: { "Content-Type": "text/plain;charset=utf-8" } }); } } else { // 处理 WebSocket 连接 if(url.pathname.includes('/pyip=')) { const tmp_ip = url.pathname.split("=")[1]; if(isValidIP(tmp_ip)) { proxyIP = tmp_ip; } } return await ygkkkOverWSHandler(request); } } }; ``` -------------------------------- ### Trojan Worker Deployment API Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt This API endpoint allows deployment of a Trojan protocol proxy through Cloudflare Workers using password authentication. It also provides access to configuration pages and subscription links. ```APIDOC ## Trojan Worker Deployment API ### Description This API endpoint allows deployment of a Trojan protocol proxy through Cloudflare Workers using password authentication. It also provides access to configuration pages and subscription links. ### Method GET ### Endpoint `/{password}` (for configuration page) `/{password}/ty` (for general subscription) ### Parameters #### Query Parameters - **Host** (string) - Required - The hostname of the Cloudflare Worker. ### Request Example ```bash # Accessing the configuration page curl https://your-worker.workers.dev/trojan # Getting the general subscription link curl https://your-worker.workers.dev/trojan/ty ``` ### Response #### Success Response (200) - **Configuration Page**: Returns an HTML page with deployment and configuration details. - **Subscription Link**: Returns a plain text subscription link (Base64 encoded). #### Response Example (HTML for configuration page or plain text for subscription link) ``` -------------------------------- ### VLESS Worker 部署接口 - JavaScript Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt 该 JavaScript 代码用于部署 VLESS 协议代理到 Cloudflare Workers。它处理 WebSocket 连接,并根据用户 ID 和请求路径提供节点配置、通用订阅、sing-box 订阅和 clash 订阅。配置项包括 UUID、ProxyIP、CDNIP 和优选 IP。 ```javascript import { connect } from "cloudflare:sockets"; // 配置 UUID(用户标识) let userID = "86c50e3a-5b87-49dd-bd20-03c7f2735e40"; // 配置 ProxyIP 用于访问 CF 类网站 const proxyIPs = [""]; // 配置优选域名 let CDNIP = 'www.visa.com.sg'; // 配置 HTTP 端口的优选 IP let IP1 = 'www.visa.com'; let IP2 = 'cis.visa.com'; // 配置 HTTPS 端口的优选 IP let IP8 = 'usa.visa.com'; let IP9 = 'myanmar.visa.com'; export default { async fetch(request, env, ctx) { // 从环境变量读取配置 userID = env.uuid || userID; const { proxyip } = env; // 处理 ProxyIP 配置 if (proxyip) { if (proxyip.includes(']:')) { let lastColonIndex = proxyip.lastIndexOf(':'); proxyPort = proxyip.slice(lastColonIndex + 1); proxyIP = proxyip.slice(0, lastColonIndex); } } const upgradeHeader = request.headers.get("Upgrade"); const url = new URL(request.url); // 非 WebSocket 请求返回配置信息 if (!upgradeHeader || upgradeHeader !== "websocket") { if (url.pathname === `/${userID}`) { // 返回节点配置页面 const vlessConfig = getVlessConfig(userID, request.headers.get("Host")); return new Response(vlessConfig, { status: 200, headers: { "Content-Type": "text/html;charset=utf-8" } }); } // 订阅路径示例 if (url.pathname === `/${userID}/ty`) { // 返回通用订阅 const tyConfig = gettyConfig(userID, request.headers.get('Host')); return new Response(tyConfig, { status: 200, headers: { "Content-Type": "text/plain;charset=utf-8" } }); } if (url.pathname === `/${userID}/sb`) { // 返回 sing-box 订阅 const sbConfig = getsbConfig(userID, request.headers.get('Host')); return new Response(sbConfig, { status: 200, headers: { "Content-Type": "application/json;charset=utf-8" } }); } if (url.pathname === `/${userID}/cl`) { // 返回 clash 订阅 const clConfig = getclConfig(userID, request.headers.get('Host')); return new Response(clConfig, { status: 200, headers: { "Content-Type": "text/plain;charset=utf-8" } }); } } else { // 处理 WebSocket 连接 if(url.pathname.includes('/pyip=')) { // 从路径中提取 ProxyIP const tmp_ip = url.pathname.split("=")[1]; if(isValidIP(tmp_ip)) { proxyIP = tmp_ip; [proxyIP, proxyPort = '443'] = proxyIP.split(':'); } } return await vlessOverWSHandler(request); } } }; ``` -------------------------------- ### Path-Level ProxyIP Configuration Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt Dynamically set the ProxyIP for individual nodes using URL path parameters, without affecting the global configuration. ```APIDOC ## Path-Level ProxyIP Configuration ### Description Dynamically set the ProxyIP for individual nodes using URL path parameters, without affecting the global configuration. This is useful for creating specific client configurations. ### Method GET ### Endpoint `/pyip=` (within the WebSocket upgrade path) ### Parameters #### Path Parameters - **proxy_ip** (string) - Required - The IP address or domain to be used as the proxy IP. Can include a port number. ### Request Example ```bash # VLESS protocol with IPv4 address vless://uuid@preferred_ip:port?path=/pyip=192.168.1.1#NodeName # VLESS protocol with IPv6 address vless://uuid@preferred_ip:port?path=/pyip=[2001:db8::1]#NodeName # VLESS protocol with domain vless://uuid@preferred_ip:port?path=/pyip=proxy.example.com#NodeName # VLESS protocol with custom port vless://uuid@preferred_ip:port?path=/pyip=192.168.1.1:8443#NodeName # Trojan protocol trojan://password@preferred_ip:port?path=/pyip=proxy.example.com#NodeName ``` ### Client Configuration Example (V2rayN/V2rayNG) ```json { "address": "104.16.0.0", "port": 443, "uuid": "86c50e3a-5b87-49dd-bd20-03c7f2735e40", "network": "ws", "path": "/pyip=proxy.example.com", "host": "your-worker.workers.dev", "tls": "tls" } ``` ``` -------------------------------- ### CF IP Optimization Script Source: https://context7.com/yonggekkk/cloudflare_vless_trojan/llms.txt A script to automatically test and select the best Cloudflare IP addresses for optimizing connection performance. Can be run on Android Termux or iOS iSH. ```APIDOC ## CF IP Optimization Script ### Description This script automatically tests and selects optimal Cloudflare IP addresses to improve connection performance. It can be executed in environments like Android Termux or iOS iSH. ### Usage 1. Download and make the script executable: ```bash curl -sSL https://raw.githubusercontent.com/yonggekkk/Cloudflare_vless_trojan/main/cf/cf.sh -o cf.sh chmod +x cf.sh ``` 2. Run the script: ```bash bash cf.sh ``` 3. Follow the on-screen prompts to choose the optimization type (IPv4 only, IPv6 only, IPv4+IPv6, reset config, exit). ### Optimization Types - `1`: IPv4 optimization only - `2`: IPv6 optimization only - `3`: IPv4 + IPv6 optimization - `4`: Reset configuration - `5`: Exit ### Output Example (US IPv4 Optimization Results) ```bash 104.16.1.1,LAX,200ms,100.00%,5.2MB/s 104.17.2.2,SFO,210ms,100.00%,5.0MB/s 104.18.3.3,SEA,220ms,100.00%,4.8MB/s ``` ### Script Workflow Overview 1. **Detect System Architecture**: Identifies the CPU architecture (e.g., `amd64`, `arm64`). 2. **Download Test Program**: Downloads a binary suitable for the detected architecture. 3. **Download IP List and Geo-location Data**: Fetches necessary data files for testing. 4. **Execute Tests**: Runs the test program against IP addresses. 5. **Categorize and Sort Results**: Organizes and sorts the test results by region and performance metrics. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.