基于 Tokio 实现的反向端口转发系统,隧道转发地址由服务端控制。 expose 1 2099 127.0.0.1:80 2098 expose 1 2099 127.0.0.1:6080 2098 expose 1 2099 127.0.0.1:8686 2098
cargo build --release --target mipsel-unknown-linux-musl
cargo install cross cross build --target mipsel-unknown-linux-musl --release
该系统包含两个主要组件:
cargo build --release
cargo run --example server
服务端默认监听 0.0.0.0:8080 (WebSocket 端口)
cargo run -- ws://localhost:8080/ws client1
参数:
ws://localhost:8080/ws: WebSocket 服务器地址client1: 客户端唯一标识符{
"type": "register",
"client_id": "client1"
}
{
"type": "forward_config",
"tunnel_id": "client1:8080",
"target_host": "localhost",
"target_port": 22
}
{
"type": "stop_forward",
"tunnel_id": "client1:8080"
}
{
"type": "data",
"tunnel_id": "client1:8080",
"data": "base64_encoded_data"
}
{
"type": "close",
"tunnel_id": "client1:8080"
}
{
"type": "error",
"tunnel_id": "client1:8080",
"message": "Error description"
}
cargo run -- ws://your-server.com:8080/ws office-pc
{
"type": "forward_config",
"tunnel_id": "office-pc:2222",
"target_host": "localhost",
"target_port": 22
}
ssh -p 2222 user@your-server.com
{
"type": "forward_config",
"tunnel_id": "office-pc:8080",
"target_host": "localhost",
"target_port": 3000
}
访问 http://your-server.com:8080 即可访问内网的 Web 服务。
| 参数 | 说明 | 示例 |
|---|---|---|
| server_url | WebSocket 服务器地址 | ws://server.com:8080/ws |
| client_id | 客户端唯一标识 | client1 |
| 参数 | 说明 | 默认值 |
|---|---|---|
| ws_port | WebSocket 监听端口 | 8080 |
wss:// (WebSocket Secure) 加密连接可以添加以下功能:
MIT License