DejavuMoe/warpsocks
소개
Cloudflare WARP as a SOCKS5 proxy (TCP/UDP) in a tiny container — consumer, WARP+ and Zero Trust, kernel WireGuard + hev-socks5-server. 在微型容器中将 Cloudflare WARP 用作 SOCKS5 代理(TCP/UDP)——支持 Consumer、WARP+ 和 Zero Trust,内核 WireGuard + hev-socks5-server
시스템 및 인프라측정된 스타 증가
- in 24h
- 0
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalwarpsocks
A small container that turns Cloudflare WARP into a SOCKS5 proxy (TCP and UDP).
- Consumer WARP (no account), WARP+ and Cloudflare Zero Trust (service token)
- IPv4 and IPv6 egress, even on an IPv4-only host
- Kernel WireGuard + hev-socks5-server; no official client
- 5 MB image download, 5 MiB memory at idle; about twice the download speed of the official client on one vCPU
- Registers once and keeps the identity; repairs the tunnel on its own
How it works
flowchart LR
client(["SOCKS5 client"]) -- "TCP · UDP" --> hev
subgraph ns["warpsocks container · own network namespace"]
direction LR
hev["hev-socks5-server<br/>uid 65532"] -- "policy route<br/>uid 65532 → table 51820" --> wg0["wg0<br/>kernel WireGuard"]
ctl["warpsocks<br/>control plane · root"] -. "netlink · nftables" .-> wg0
ctl -. "supervise" .-> hev
end
wg0 -- "WireGuard over UDP" --> edge["Cloudflare WARP"] --> net(("Internet"))
ctl -- "register · refresh<br/>HTTPS, main table" --> api["Cloudflare API"]
warpsocks registers a device with Cloudflare, configures wg0 inside the container's network namespace and
routes everything the SOCKS server sends (including its DNS lookups) through it. Nothing else in the container,
and nothing on the host, is routed through WARP. The data path is the kernel and hev, both written in C;
warpsocks only sets it up and watches it.
flowchart LR
start(["start"]) --> id{"identity.json?"}
id -- "no" --> reg["register device<br/>consumer · Zero Trust"] --> up
id -- "yes" --> up["configure wg0, routes,<br/>nftables, resolv.conf"]
up --> run["start hev as uid 65532"] --> probe{{"watchdog · every 30 s<br/>handshake + CONNECT through SOCKS"}}
probe -- "healthy" --> probe
probe -- "failing" --> repair
subgraph repair["repair · next step on each failed check"]
direction TB
s1["check registration<br/>re-register if deleted"] --> s2["rotate endpoint<br/>4 ports × IPv4/IPv6"] --> s3["refetch config<br/>rebuild tunnel"] --> s4(["exit<br/>Docker restarts it"])
end
repair -. "recovered" .-> probe
Requirements
- Linux host with kernel 5.6+ (built-in WireGuard) and nftables support
- Docker with Compose; the container needs
NET_ADMIN
Quick start
mkdir warpsocks && cd warpsocks
curl -fsSLO https://raw.githubusercontent.com/DejavuMoe/warpsocks/master/compose.yaml
curl -fsSL https://raw.githubusercontent.com/DejavuMoe/warpsocks/master/.env.example -o .env
docker compose up -d
curl -x socks5h://127.0.0.1:1080 https://www.cloudflare.com/cdn-cgi/trace
The output should contain warp=on. The identity is stored in ./data; keep it to avoid registering a new
device on every start.
Configuration
Set variables in .env. Secrets also accept a *_FILE variant (Docker secrets).
| Variable | Default | Description |
|---|---|---|
BIND_IP |
127.0.0.1 |
Host address the ports are published on (see Exposing the proxy) |
SOCKS_PORT |
1080 |
SOCKS5 port (TCP) and first UDP relay port |
UDP_PORT_COUNT / UDP_PORT_LAST |
32 / 1111 |
UDP relay ports SOCKS_PORT..UDP_PORT_LAST; keep both consistent |
SOCKS_USER / SOCKS_PASS |
Enable username/password authentication | |
WARP_MODE |
consumer |
consumer or zerotrust |
WARP_LICENSE |
WARP+ license key (consumer) | |
ZT_TEAM |
Zero Trust team name | |
ZT_CLIENT_ID / ZT_CLIENT_SECRET |
Zero Trust service token | |
WARP_EGRESS |
auto |
auto (IPv4 + IPv6), ipv4 or ipv6 |
WARP_ENDPOINT |
auto |
auto, v4, v6 or a fixed IP:port |
WARP_MTU |
1280 |
Tunnel MTU; 1420 can be slightly faster |
WARP_DNS |
Cloudflare | Comma-separated resolvers for SOCKS domain names (queried through WARP) |
LOG_LEVEL |
info |
debug, info, warn or error |
UDP: each UDP relay port carries one association per client IP at a time, so UDP_PORT_COUNT is the number of
concurrent UDP associations per client. Host and container port numbers must be identical.
Zero Trust
Create a service token: Zero Trust → Access controls → Service credentials → Create Service Token. Save the Client ID (
….access) and Client Secret.Create a policy: Access controls → Policies → Add a policy, Action: Service Auth, Include → Service Token → the token from step 1.
Allow enrollment: Team & Resources → Devices → Management → Device enrollment permissions → Manage, add the policy and Save.
Set in
.env:WARP_MODE=zerotrust ZT_TEAM=<team> # <team>.cloudflareaccess.com ZT_CLIENT_ID=<id>.access ZT_CLIENT_SECRET=<secret>
sequenceDiagram
participant W as warpsocks
participant A as team.cloudflareaccess.com
participant D as Cloudflare device API
W->>A: GET /warp (service token headers)
A-->>W: 302 com.cloudflare.warp://…?token=JWT
W->>D: POST /v0/reg (WireGuard public key, JWT)
D-->>W: device id, addresses, peer key, endpoints
Note over W: identity.json (0600), tunnel up
Device profile settings (split tunnels, local domain fallback, service mode) apply to the official client only and
are ignored. Keep the profile's tunnel protocol on WireGuard. Gateway policies are optional; without them the
trace shows gateway=off, which is expected.
Exposing the proxy
By default the ports are published on 127.0.0.1 and only the host can use the proxy. To share it, set
BIND_IP to a public or tailnet address and enable authentication.
Host firewalls do not protect published ports. Docker DNATs them in
prerouting, so the traffic takes theforwardpath and aninputchain withpolicy drop(nftables or ufw) never sees it. To restrict access, add a forward chain, for example in your own nftables table:chain forward { type filter hook forward priority filter; policy accept; ct status dnat ct original proto-dst 1080-1111 iifname != "tailscale0" drop }Do not use
flush rulesetin/etc/nftables.conf; it removes Docker's rules on reload.Tailnet address: the address must exist when the container starts. Order Docker after Tailscale:
# /etc/systemd/system/docker.service.d/tailscale.conf [Unit] After=tailscaled.service Wants=tailscaled.service
Commands
docker exec warpsocks warpsocks status # registration, tunnel, IPv4/IPv6 egress
docker exec warpsocks warpsocks healthcheck # handshake + TCP + UDP through SOCKS5
docker exec warpsocks warpsocks diag # links, rules, routes, nftables, WireGuard
docker exec warpsocks warpsocks license <key> # bind a WARP+ license
docker exec warpsocks warpsocks unregister # delete the device at Cloudflare
Performance
Compared with cmj2002/warp-docker (official warp-svc + GOST) on the
same 1 vCPU VPS (Geekbench 5 single-core ≈ 400, 2 GB RAM, Debian 13, kernel 6.12, consumer WARP via LAX), one
container at a time. Each figure is the mean of 5 rounds; latency is the mean of 50 samples. Memory is the
container's cgroup usage without page cache, as docker stats reports it.
%%{init: {"themeVariables": {"xyChart": {"plotColorPalette": "#b8b8b8, #f38020"}}}}%%
xychart-beta
title "Memory, MiB (lower is better) · orange: warpsocks, grey: warp-docker"
x-axis ["idle", "4 downloads", "1,000 connections"]
y-axis "MiB" 0 --> 150
bar [78.2, 84.0, 145.0]
bar [5.1, 10.4, 23.3]
%%{init: {"themeVariables": {"xyChart": {"plotColorPalette": "#f38020, #b8b8b8"}}}}%%
xychart-beta
title "Throughput, MB/s (higher is better) · orange: warpsocks, grey: warp-docker"
x-axis ["download", "upload", "4 parallel downloads"]
y-axis "MB/s" 0 --> 50
bar [43.7, 41.1, 32.7]
bar [22.6, 26.3, 17.3]
| warpsocks | warp-docker | |
|---|---|---|
| Image download (amd64, compressed) | 5.1 MB | 386.4 MB |
| Memory: idle / 4 downloads / 1,000 connections | 5.1 / 10.4 / 23.3 MiB | 78.2 / 84.0 / 145.0 MiB |
| CPU at idle | 0.24 % | 2.0 % |
| Download / upload, one stream | 43.7 / 41.1 MB/s | 22.6 / 26.3 MB/s |
| Download, 4 streams (host CPU) | 32.7 MB/s (84 %) | 17.3 MB/s (81 %) |
| TLS handshake through the proxy (direct: 25 ms) | 33.9 ms | 40.1 ms |
| UDP DNS round trip (direct: 1.7 ms) | 2.8 ms | no reply |
| Restart until traffic flows | 3.8–24 s, median 9.2 s | 13.1–13.6 s |
The host's own connection measured 48–91 MB/s in the same runs. With one vCPU, kernel WireGuard crypto is the limit, so four streams get less than one. warpsocks configures the tunnel within 0.1 s of starting; when the device was connected moments before, Cloudflare sometimes holds back data for about 15 s, which is where the restart range comes from. After a blocked endpoint or a deleted Zero Trust device, traffic is back in about a minute.
Building
docker build -t warpsocks .
go test -race ./...
Release archives contain the static warpsocks and hev-socks5-server binaries for running outside Docker
(root or CAP_NET_ADMIN required).
Acknowledgements
- hev-socks5-server — the SOCKS5 server
- wgcf — consumer registration API and TLS fingerprint
- wgcf-mesh — Zero Trust service token enrollment
Disclaimer
This project is not affiliated with Cloudflare. Use of WARP is subject to Cloudflare's terms of service; it is intended for personal use.
License
관련 프로젝트 살펴보기
불러오는 중…