简介 / Introduction
本脚本基于 Wstunnel 深度开发,旨在为您提供最稳定、最隐蔽的端口转发服务。特别针对 Cloudflare 优选 IP 加速、UDP 游戏/VPN 断流问题进行了内核级优化。
This script is deeply customized based on Wstunnel to provide stable and stealthy port forwarding. It features kernel-level optimizations for Cloudflare CDN acceleration and UDP stability (solving packet loss/jitter in games/VPNs).
核心功能 / Key Features
1. 服务端 (Server):
– [标准模式] 一键开启端口映射 (TCP/UDP)。
[Standard Mode] One-click port mapping.
– [高级复用] 集成 Nginx,单端口 (如 443) 支持多路径分流 + 多域名 (SNI) 共存。
[Advanced Multiplexing] Integrates Nginx to support multiple paths and SNI domains on a single port (e.g., 443).
– [安全合规] 自动检测 HTTP/HTTPS 特征,防止滥用。
[Compliance] Automatically detects HTTP/HTTPS traffic to prevent abuse.
2. 客户端 (Client):
– [Cloudflare 优选] 自动测速并连接最佳 CF 边缘节点,隐藏真实 IP。
[Cloudflare Optimization] Automatically connects to the best CF edge node, hiding your real IP.
– [通用直连] 支持任意 VPS 直连,可自定义伪装域名 (SNI)。
[Direct Connect] Supports direct connection to any VPS with custom SNI.
– [独家优化] “单路稳定模式” (彻底解决断流) + “双发冗余模式” (抗丢包)。
[Exclusive Optimization] “Single-Connection Stable Mode” (Anti-Jitter) + “Dual-Packet Redundancy” (Anti-Loss).
服务端部署指南 / Server Deployment Guide
运行命令 / Run Command:
wget https://ex-files.leikwanhost.com/pf/server.sh && chmod +x server.sh && bash server.sh
— 场景 A: 简单端口映射 (Simple Port Mapping) —
适用于独占端口,不需要伪装网站的情况。
Suitable for dedicated ports without website masking.
1. 选择菜单 “1. 添加新端口映射 (标准模式)”
Select Menu “1. Add New Port Mapping (Standard Mode)”
2. 输入监听端口 (例如 8443)
Enter Listen Port (e.g., 8443)
3. 输入转发目标 (例如 127.0.0.1:22 用于 SSH)
Enter Forward Target (e.g., 127.0.0.1:22 for SSH)
— 场景 B: Nginx 高级复用 (Advanced Multiplexing) —
【推荐】在 443 端口同时运行网站和多个服务 (SSH, VLESS, RDP等),流量伪装成正常的 HTTPS 访问。
[Recommended] Run a website and multiple services (SSH, RDP, etc.) on port 443 simultaneously. Traffic looks like normal HTTPS.
1. 选择菜单 “4. Nginx 高级复用” -> “1. 添加路径分流规则”
Select Menu “4. Nginx Advanced Multiplexing” -> “1. Add Path Rule”
2. 公网端口: 输入 443
Public Port: 443
3. SNI 域名: 输入您的域名 (例如 demo.example.com)
SNI Domain: Enter your domain (e.g., demo.example.com)
4. WebSocket 路径: 输入分流路径 (例如 /ssh,必须以 / 开头)
WebSocket Path: Enter path (e.g., /ssh, must start with /)
5. 转发目标: 输入 127.0.0.1:22
Target: 127.0.0.1:22
结果 / Result:
– 访问 https://demo.example.com -> 显示伪装网页 (Masked Website)
– 连接 wss://demo.example.com/ssh -> 连接到 SSH (Connects to SSH)
客户端配置指南 / Client Configuration Guide
运行命令 / Run Command:
wget https://ex-files.leikwanhost.com/pf/client.sh && chmod +x client.sh && bash client.sh
1. 选择菜单 “1. 添加/修改 转发规则”
Select Menu “1. Add/Modify Forwarding Rule”
2. 按照提示输入:
Follow the prompts:
– 本地监听端口 (Local Port): 您本机使用的入口端口 (如 10022)
– 服务端端口 (Remote Port): 服务器端口 (如 443)
– SNI 域名:
* Cloudflare 模式: 必须填真实域名 (Real Domain)
* 通用模式: 可填伪装域名 (Fake Domain, e.g., www.samsung.com)
3. 选择转发模式 (Select Mode):
– [模式 1] Cloudflare 优选模式 (需自备域名 + 开启 CDN)
[Mode 1] Cloudflare Optimization (Requires Domain + CDN)
– [模式 2] 通用/直连模式 (适合普通 VPS)
[Mode 2] General/Direct Mode (For standard VPS)
4. 选择传输协议 (Select Protocol):
– [TCP] 稳定,通用性好 (Stable, Generic)
– [QUIC/UDP] 极速,穿透性强 (Fast, High Penetration)
5. 【关键】进阶优化 (Optimization Strategy):
– [1. 默认模式] 适合网页浏览、大文件下载 (Web Browsing, Downloading)
– [2. 单路稳定模式] 【VPN/游戏必选】彻底消除多路复用导致的断流/卡顿
[2. Single-Connection Stable Mode] [Must for VPN/Gaming] Eliminates connection drops/lag.
– [3. 激进保活] 适合极不稳定的网络环境
[3. Aggressive Keepalive] For very unstable networks.
典型应用示例 / Typical Usage Scenarios
【示例 1: 搭建防封 SSH 通道 / Secure SSH Tunnel】
目标: 通过 Cloudflare 隐藏 SSH 流量
Goal: Hide SSH traffic behind Cloudflare
[服务端 / Server]
– 菜单: 4 (Nginx 复用)
– 端口: 443
– 域名: my.site.com
– 路径: /ssh
– 目标: 127.0.0.1:22
[客户端 / Client]
– 菜单: 1 (添加规则)
– 本地端口: 2222
– 远程端口: 443
– SNI: my.site.com
– 路径: /ssh
– 模式: 1 (Cloudflare 优选)
– 协议: QUIC (推荐)
[连接方法 / How to Connect]
ssh [email protected] -p 2222
【示例 2: WireGuard/游戏加速 / Gaming & VPN Acceleration】
目标: 极低延迟,无断流
Goal: Low latency, no packet loss
[服务端 / Server]
– 菜单: 1 (标准端口)
– 端口: 51820
– 目标: 127.0.0.1:51820 (你的 WireGuard 端口)
[客户端 / Client]
– 菜单: 1 (添加规则)
– 本地端口: 51820
– 远程端口: 51820
– 模式: 2 (直连/通用) -> 选 3 (QUIC/UDP 极速模式)
– 优化策略: 2 (单路稳定模式) [重要!]
– 双倍发包: 如果丢包严重,选 y (消耗双倍流量换取稳定性)
[注意 / Note]
请务必将 WireGuard 客户端的 MTU 设置为 1280。
Please set WireGuard Client MTU to 1280.
常见问题 / FAQ
Q: 为什么游戏/VPN 会断流? (Why does Game/VPN disconnect?)
A: 请在客户端 “优化策略” 中选择 “2. 单路稳定模式”。默认的多路复用模式会导致 UDP 乱序。
Please select “2. Single-Connection Stable Mode” in client optimization settings.
Q: 什么时候用双倍发包? (When to use Dual-Packet Redundancy?)
A: 当您的网络丢包率 > 5% 时。它会同时用两个不同的端口/IP 发送同一份数据,只要有一份到达即可。
When packet loss > 5%. It sends duplicate data via two paths; if one arrives, it works.
Q: Nginx 模式下证书怎么办? (What about certificates in Nginx mode?)
A: 脚本会自动生成自签名证书。如果您有自己的证书,请替换 /etc/wstunnel/ssl/ 下的文件。
The script generates self-signed certs automatically. You can replace files in /etc/wstunnel/ssl/ with your own.


没有回复内容