Unchain is a lightweight Go-based VLESS over WebSocket proxy project with support for:
- VLESS over WebSocket proxy server
- TCP and UDP forwarding
- multiple UUID user access control
- optional traffic usage metering
- systemd service installation
- Docker image packaging
- Protocol: VLESS over WebSocket
- Endpoints:
/wsv/{uid},/sub/{uid},/ - Configuration:
.envfile and environment variables - User Management:
ALLOW_USERSaccepts multiple UUIDs - Traffic Metering: enabled via
ENABLE_DATA_USAGE_METERING=true - Modes:
run,install,client
.
├── Dockerfile
├── LICENSE
├── README.md
├── app.go
├── app_ping.go
├── app_sub.go
├── app_ws_vless.go
├── config.go
├── config_util.go
├── example.env
├── go.mod
├── go.sum
├── logger.go
├── main.go
├── socks5.go
├── unchain
├── unchain.service
└── vless.go
git clone https://github.com/unchainese/unchain.git
cd unchaingo mod downloadCopy example.env to .env and modify values as needed:
cp example.env .envgo run main.go rungo run main.go run- start the proxy servergo run main.go install- install systemd service (ifsystemctlis available)go run main.go client- start the built-in SOCKS5 clientgo run main.go help- display help information
Unchain reads configuration from .env or environment variables. The following variables map to the Config struct in config.go:
| Variable | Default | Description |
|---|---|---|
APP_PORT |
80 |
HTTP listen port |
REGISTER_URL |
https://unchain.libragen.cn/api/node |
Control server registration URL; leave empty to disable registration |
REGISTER_TOKEN |
unchain people from censorship and surveillance |
Control server token |
ALLOW_USERS |
903bcd04-79e7-429c-bf0c-0456c7de9cdc,903bcd04-79e7-429c-bf0c-0456c7de9cd1 |
Allowed UUID list |
LOG_FILE |
`` | Log file path; empty means stdout |
DEBUG_LEVEL |
DEBUG |
Log level: DEBUG, INFO, WARN, ERROR |
INTERVAL_SECOND |
3600 |
Interval in seconds to push node info to REGISTER_URL |
GIT_HASH |
`` | Optional build git hash |
BUILD_TIME |
`` | Optional build timestamp |
RUN_AT |
`` | Optional runtime timestamp |
ENABLE_DATA_USAGE_METERING |
true |
Enable traffic metering |
BUFFER_SIZE |
8192 |
Buffer size for WebSocket and TCP/UDP reads |
Note: This project uses
.env/ environment variables for configuration and does not loadconfig.toml.
- On startup, the node registers to
REGISTER_URLif configured. - The application prints VLESS subscription examples.
/sub/{uid}returns VLESS subscription URLs./wsv/{uid}handles VLESS WebSocket connections./returns status and traffic statistics./debug/pprof/...provides pprof profiling endpoints.
| Path | Description |
|---|---|
/wsv/{uid} |
VLESS WebSocket entry point |
/sub/{uid} |
Subscription URL generator |
/ |
Health check and runtime stats |
/debug/pprof/... |
pprof profiling endpoints |
The subscription URL is generated from APP_HOST and looks like:
vless://<UUID>@<host>:<port>?encryption=none&allowInsecure=1&type=ws&path=/wsv/<UUID>?ed=2560#<host>
Running go run main.go client starts a built-in SOCKS5 server.
The client uses a fixed wsURL and vlessUUID defined in socks5.go to forward traffic to a remote WebSocket server. It is intended for testing or experimental use.
docker build -t unchain .docker run -d --name unchain \
-p 8880:8880 \
-e APP_PORT=8880 \
-e REGISTER_URL=https://unchain.libragen.cn/api/node \
-e ALLOW_USERS=903bcd04-79e7-429c-bf0c-0456c7de9cdc \
unchaingo build -o unchain main.go
./unchain runmain.go- entry point and subcommand parsingconfig_util.go- environment loading and config mappingapp.go- HTTP server initialization, run loop, and graceful shutdownapp_ws_vless.go- VLESS over WebSocket forwarding logicapp_sub.go- subscription URL generationapp_ping.go- health check and runtime stats endpointsocks5.go- SOCKS5 client implementationvless.go- VLESS payload encode/decode logiclogger.go- logger setup
- Use a reachable domain in
APP_HOST. - Ensure
ALLOW_USERScontains valid UUIDs. - Leave
REGISTER_URLempty if you do not want registration. - For production, deploy behind a reverse proxy with TLS.
github.com/google/uuidgithub.com/gorilla/websocketgithub.com/joho/godotenv
Apache License 2.0. See LICENSE for details.