mirror of
https://github.com/unchainese/unchain.git
synced 2026-04-22 23:37:07 +08:00
zh readme.md
This commit is contained in:
+143
@@ -0,0 +1,143 @@
|
||||
# Unchain Proxy Server
|
||||
|
||||
Unchain is a lightweight and easy-to-use proxy server designed to bypass network restrictions, censorship, and surveillance effectively.
|
||||
|
||||
|
||||
## Key Features
|
||||
- **Protocol Support**: Seamlessly handles TCP and UDP (VLESS) packets over WebSocket with TLS/Cloudflare support.
|
||||
- **Build Your Own VPN Business**: Provides a robust platform for starting your own VPN services.
|
||||
- **Compatibility**: Fully compatible with popular proxy clients like v2rayN or any application supporting the VLESS + WebSocket protocol.
|
||||
|
||||
|
||||
## How It Works
|
||||
|
||||
Unchain operates as a proxy/VPN server, compatible with popular proxy clients such as v2rayN or any application that supports the VLESS+WebSocket protocol. It accepts traffic from various client applications, including:
|
||||
|
||||
- [v2rayN](https://github.com/2dust/v2rayN)
|
||||
- [v2rayA](https://github.com/v2rayA/v2rayA)
|
||||
- [Clash](https://github.com/Dreamacro/clash)
|
||||
- [v2rayNG](https://github.com/2dust/v2rayNG)
|
||||
- [iOS app Shadowrocket](https://apps.apple.com/us/app/shadowrocket/id932747118)
|
||||
|
||||
Unchain processes incoming traffic and securely forwards it to the destination server, ensuring both security and efficiency in communication.
|
||||
|
||||
## Unchain Architecture
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Unchain is a dead simple VLESS over websocket proxy server.
|
||||
The core biz logic is only 200 lines of code. [app_ws_vless.go](/internal/node/app_ws_vless.go).
|
||||
|
||||
Unchain server uses a simple architecture that is VLESS over WebSocket (WS) + TLS.
|
||||
|
||||
|
||||
```
|
||||
V2rayN,V2rayA,Clash or ShadowRocket
|
||||
+------------------+
|
||||
| VLESS Client |
|
||||
| +-----------+ |
|
||||
| | TLS Layer | |
|
||||
| +-----------+ |
|
||||
| | WebSocket | |
|
||||
| +-----------+ |
|
||||
+--------|---------+
|
||||
|
|
||||
| Encrypted VLESS Traffic (wss://)
|
||||
|
|
||||
+--------------------------------------+
|
||||
| Internet (TLS Secured) |
|
||||
+--------------------------------------+
|
||||
|
|
||||
|
|
||||
+-----------------------------------+
|
||||
| Reverse Proxy Server |
|
||||
| (e.g., Nginx or Cloudflare) |
|
||||
| |
|
||||
| +---------------------------+ |
|
||||
| | HTTPS/TLS Termination | |
|
||||
| +---------------------------+ |
|
||||
| | WebSocket Proxy (wss://) | |
|
||||
| +---------------------------+ |
|
||||
| Forward to VLESS Server |
|
||||
+------------------|----------------+
|
||||
|
|
||||
+--------------------------------+
|
||||
| Unchain Server |
|
||||
| |
|
||||
| +------------------------+ |
|
||||
| | WebSocket Handler | |
|
||||
| +------------------------+ |
|
||||
| | VLESS Core Processing | |
|
||||
| +------------------------+ |
|
||||
| |
|
||||
| Forward Traffic to Target |
|
||||
+------------------|-------------+
|
||||
|
|
||||
+-----------------+
|
||||
| Target Server |
|
||||
| or Destination |
|
||||
+-----------------+
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Build from Source
|
||||
|
||||
To build from source, follow these steps:
|
||||
|
||||
1. Clone the repository and navigate to the `cmd/node` directory:
|
||||
```sh
|
||||
cd cmd/node
|
||||
```
|
||||
2. Copy the example configuration file and customize it:
|
||||
```sh
|
||||
cp config.example.standalone.toml config.toml
|
||||
```
|
||||
3. Run the application:
|
||||
```sh
|
||||
go run main.go
|
||||
```
|
||||
|
||||
### 2. Deploying on Your Own Ubuntu Server Using GitHub Actions
|
||||
|
||||
You can deploy the application on an Ubuntu server using GitHub Actions. Here's how:
|
||||
|
||||
1. **Fork the repository** to your GitHub account.
|
||||
2. **Create an Environment** named `production` in your repository settings.
|
||||
3. **Add the following SSH connection details** to the Environment Secrets:
|
||||
- `EC2_HOST`: The SSH host with port (e.g., `1.1.1.1:20`).
|
||||
- `EC2_USER`: The SSH user (e.g., `ubuntu`).
|
||||
- `EC2_KEY`: Your SSH private key.
|
||||
|
||||
4. **Add your TOML configuration file content** to the Environment Variables:
|
||||
- `CONFIG_TOML`: Copy the content of your `config.toml` file, replace all `"` with `'`, and paste it here.
|
||||
|
||||
learn more in [.github/workflows/deploy.sh](/.github/workflows/deploy.sh)
|
||||
|
||||
|
||||
[Click to view Chinese deployment tutorial video](https://www.bilibili.com/video/BV1wBrmYmEiN/?share_source=copy_web&vd_source=aec70c249b680fe47ccf03c2051714fe)
|
||||
|
||||
|
||||
### 3. Running the Application
|
||||
|
||||
Once the application is running, you will see a VLESS connection schema URL in the standard output. Copy and paste this URL into your V2rayN client.
|
||||
|
||||
Congratulations! You now have your self-hosted proxy server up and running.
|
||||
|
||||
|
||||
|
||||
|
||||
### 4. (Optional) create your own admin app for Auth and Data-traffic
|
||||
|
||||
create an RESTful API for [chain proxy server push](https://github.com/unchainese/unchain/blob/5ece8c39814684a8a54e8e009d7c888e5988a017/internal/node/app.go#L161) :
|
||||
[Register API example code](https://github.com/unchainese/unchainadmin/blob/035b2232d4262c24ef70b8ad7abb9faebaaecc96/functions/api/nodes.ts#L34)
|
||||
|
||||
|
||||
## Build your own VPN business
|
||||
|
||||
Using [the cloudflare page UnchainAdmin](https://github.com/unchainese/unchainadmin) start your own VPN business.
|
||||
@@ -8,4 +8,4 @@ RegisterToken = ''# can be empty string if you only want to use the node for you
|
||||
AllowUsers = '6fe57e3f-e618-4873-ba96-a76adec22ccd,6fe57e3f-e618-4873-ba96-a76adec22cce' # UUID string eg. '6fe57e3f-e618-4873-ba96-a76adec22ccd,6fe57e3f-e618-4873-ba96-a76adec22cce' can not be empty if you want to use the node for yourself in standalone mode
|
||||
LogFile = '' # can be empty if you don't want to log to file, so the log will be print to stdout
|
||||
DebugLevel = 'debug' # debug, info, warn, error
|
||||
PushIntervalSecond = '7200'
|
||||
IntervalSecond = '7200'
|
||||
+13
-10
@@ -1,11 +1,14 @@
|
||||
#toml 格式的文件,建议字符串使用单引号,大小敏感
|
||||
#
|
||||
#
|
||||
# Warning use ' for string not " if you want to use deploy.sh
|
||||
SubAddresses = 'cf-us1.unchainese.com:443,n-us1.unchainese.com:80' # hosts for generate vless URL
|
||||
Port = '80' # websocket server listen address
|
||||
RegisterUrl = 'https://admin.cf.workers.cn/api/nodes' #the master admin server for user auth,data traffic. can be empty if you only want to use the node for stand alone
|
||||
RegisterToken = 'unchain.people.from.censorship.and.surveillance'# can be empty string if you only want to use the node for yourself
|
||||
AllowUsers = '' # UUID string eg. '6fe57e3f-e618-4873-ba96-a76adec22ccd,6fe57e3f-e618-4873-ba96-a76adec22cce' can not be empty if you want to use the node for yourself in standalone mode
|
||||
LogFile = 'unchain.log' # can be empty if you don't want to log to file, so the log will be print to stdout
|
||||
DebugLevel = 'debug' # debug, info, warn, error
|
||||
PushIntervalSecond = '7200'
|
||||
|
||||
SubAddresses = '9.15.1.1:443,n-us1.libragen.cn:80'# 可以被广域网访问的域名端口,可以是域名也可以是ip,多个地址用逗号分隔
|
||||
Port = '80' # 服务的端口,可以是80,443,在大陆其他的端口不能被访问
|
||||
RegisterUrl = 'https://admin.cf.workers.cn/api/nodes' #主控服务器地址,主要作用是控制用户授权和流量计费,可以为空则为个人模式
|
||||
RegisterToken = 'unchain.people.from.censorship.and.surveillance'# 主控服务器的token
|
||||
AllowUsers = '6fe57e3f-e618-4873-ba96-a76adec22ccd,6fe57e3f-e618-4873-ba96-a76adec22cce' # UUID 可以访问的用户UUID,多个则用逗号分隔.个人模式这里不能为空 在线UUID生成器 https://1024tools.com/uuid
|
||||
LogFile = 'unchain.log' # 日志文件名,可以为空则不记录日志
|
||||
DebugLevel = 'debug' # 日志基本debug, info, warn, error
|
||||
IntervalSecond = '7200' #主控服务器推送流量数据的间隔,个人模式不关心
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Unchain 翻墙服务器搭建和使用教程
|
||||
|
||||
## 服务器要求
|
||||
建议使用linux ubuntu 服务器. 服务器配配置没有内存和CPU限制,任意配置都可以. 最便宜的服务器都可以.
|
||||
|
||||
服务求区域最好选择日本或者美国(访问OpenAI,Claude,Google Gemini友好).
|
||||
|
||||
|
||||
## 安装部署
|
||||
|
||||
从 [https://github.com/unchainese/unchain/releases/tag/v0.0.3](https://github.com/unchainese/unchain/releases/tag/v0.0.3)
|
||||
现在对应服务器架构的二进制文件,解压到任意目录,然后运行即可.
|
||||
|
||||
```bash
|
||||
wget https://github.com/unchainese/unchain/releases/download/v0.0.3/unchain-linux-amd64.unchain.tar.gz
|
||||
tar -zxvf unchain-linux-amd64.unchain.tar.gz
|
||||
```
|
||||
|
||||
在上一步解压之后的可执行文件相同的目录创建 `config.toml`配置文件.
|
||||
创建文件命令 `vim config.toml`.
|
||||
文件内容详见 [https://github.com/unchainese/unchain/blob/v0.0.3/config.example.standalone.toml](https://github.com/unchainese/unchain/blob/v0.0.3/config.example.standalone.toml)
|
||||
|
||||
使用下面命令,来测试配置文件是否正确.
|
||||
```bash
|
||||
# cd 到 unchain 和 config.toml 所在目录
|
||||
chmod +x unchain
|
||||
./unchain
|
||||
```
|
||||
如果没有报错,说明配置文件正确.
|
||||
|
||||
|
||||
## 使用systemctl 管理服务
|
||||
|
||||
在 `/etc/systemd/system/` 目录下创建 `unchain.service` 文件,
|
||||
使用命令 `vim /etc/systemd/system/unchain.service` 创建文件.
|
||||
文件内容如下:
|
||||
[](https://github.com/unchainese/unchain/blob/v0.0.3/unchain.service)
|
||||
|
||||
- `systemctl daemon-reload` 重新加载服务
|
||||
- `systemctl start unchain` 启动服务
|
||||
- `systemctl stop unchain` 停止服务
|
||||
- `systemctl restart unchain` 重启服务
|
||||
- `systemctl status unchain` 查看服务状态
|
||||
|
||||
|
||||
## 使用V2ray/Clash/ShadowRocket 客户端连接
|
||||
|
||||
复制日志中的 VLESS链接,在V2ray/Clash/ShadowRocket 客户端中添加VLESS链接.
|
||||
@@ -16,12 +16,12 @@ import (
|
||||
type Config struct {
|
||||
SubAddresses string `desc:"sub addresses" def:"node1.xxx.cn:80,node2.xxx.cn:443"` //这个信息会帮助你生成V2ray/Clash/ShadowRocket的订阅链接,同时这个是互联网浏览器访问的地址
|
||||
Port string `desc:"port" def:"80"` //golang app 服务端口
|
||||
RegisterUrl string `desc:"register url" def:"https://admin.unchain.people.from.censorship"` //optional,流量,用户鉴权的主控服务器地址
|
||||
RegisterUrl string `desc:"register url" def:""` //optional,流量,用户鉴权的主控服务器地址
|
||||
RegisterToken string `desc:"register token" def:"unchain people from censorship and surveillance"` //optional,流量,用户鉴权的主控服务器token
|
||||
AllowUsers string `desc:"allow users UUID" def:"903bcd04-79e7-429c-bf0c-0456c7de9cdc,903bcd04-79e7-429c-bf0c-0456c7de9cd1"` //单机模式下,允许的用户UUID
|
||||
LogFile string `desc:"log file path" def:""` //日志文件路径
|
||||
DebugLevel string `desc:"debug level" def:"DEBUG"` //日志级别
|
||||
IntervalSecond string `desc:"interval second" def:"360"` //seconds 向主控服务器推送,流量使用情况的间隔时间
|
||||
IntervalSecond string `desc:"interval second" def:"3600"` //seconds 向主控服务器推送,流量使用情况的间隔时间
|
||||
GitHash string `desc:"git hash" def:""` //optional git hash
|
||||
BuildTime string `desc:"build time" def:""` //optional build time
|
||||
RunAt string `desc:"run at" def:""` //optional run at
|
||||
@@ -61,7 +61,7 @@ func (c Config) PushIntervalSecond() int {
|
||||
iv, err := strconv.ParseInt(c.IntervalSecond, 10, 32)
|
||||
if err != nil {
|
||||
log.Println("failed to parse interval second:", err)
|
||||
return 360
|
||||
return 3600
|
||||
}
|
||||
return int(iv)
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
[Unit]
|
||||
Description=Unchain Proxy Node Sever of Vless over Websocket
|
||||
Description=Vless over Websocket Proxy
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
# 可执行二进制文件路 /app 目录可以替换其他的目录路径.
|
||||
ExecStart=/app/unchain
|
||||
Restart=always
|
||||
User=root
|
||||
# 可执行二进制文件的工作目录 /app 目录可以替换其他的目录路径.
|
||||
WorkingDirectory=/app
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user