|
1 | 1 | # remote-bind
|
2 | 2 | 将本地服务映射到公网
|
3 | 3 |
|
4 |
| -## 示例 |
5 |
| -在服务器 `124.221.61.142` 的 `1234` 端口上运行server,并设置密码为 `passwd` : |
| 4 | +## Install |
| 5 | +Windows / Linux: [releases](https://github.com/rust-net/remote-bind/releases) |
| 6 | + |
| 7 | +Android: [remote-bind-apk](https://github.com/rust-net/remote-bind-apk) |
| 8 | + |
| 9 | +## 服务器中继 |
| 10 | +在服务器 `x.x.x.x` 的 `1234` 端口上运行server,并设置密码为 `passwd` : |
6 | 11 | ```
|
7 | 12 | $ ./server 1234 passwd
|
8 |
| -server started on 124.221.61.142:1234 |
| 13 | +2023-09-04 00:00:00 - [I] - server/src/main.rs:76 -> Server started on x.x.x.x:1234 |
| 14 | +2023-09-04 00:00:00 - [I] - core/src/server.rs:71 -> STUN started on 0.0.0.0:1234 |
| 15 | +2023-09-04 00:00:00 - [I] - core/src/server.rs:71 -> STUN started on 0.0.0.0:1235 |
| 16 | +``` |
| 17 | + |
| 18 | +在局域网主机上运行客户端,将 `127.0.0.1:3389` 服务映射到 `x.x.x.x:13389` 上: |
| 19 | +``` |
| 20 | +$ ./client x.x.x.x:1234 13389 passwd 127.0.0.1:3389 |
| 21 | +2023-09-04 00:00:00 - [I] - client\src\main.rs:97 -> 正在连接服务器:x.x.x.x:1234 |
| 22 | +2023-09-04 00:00:00 - [I] - core\src\client.rs:18 -> 正在连接 |
| 23 | +2023-09-04 00:00:00 - [I] - core\src\client.rs:20 -> 连接完成 |
| 24 | +2023-09-04 00:00:00 - [I] - client\src\main.rs:104 -> 正在绑定端口:13389 |
| 25 | +2023-09-04 00:00:00 - [I] - client\src\main.rs:108 -> 服务已绑定: 127.0.0.1:3389 -> x.x.x.x:13389 |
9 | 26 | ```
|
10 | 27 |
|
11 |
| -在局域网主机上运行客户端,将 `127.0.0.1:3389` 服务映射到 `124.221.61.142:13389` 上: |
| 28 | +## P2P直连 |
| 29 | +在要进行P2P访问的主机上运行客户端,监听 `127.0.0.1:9833` 地址,映射到 `x.x.x.x:13389` 上绑定的服务: |
12 | 30 | ```
|
13 |
| -$ ./client 124.221.61.142:1234 13389 passwd 127.0.0.1:3389 |
14 |
| -Connecting to 124.221.61.142:1234 |
15 |
| -连接服务器成功! 服务 127.0.0.1:3389 已暴露在公网 124.221.61.142:13389 |
| 31 | +$ ./client p2p x.x.x.x:1234 13389 127.0.0.1:9833 |
| 32 | +2023-09-04 00:00:00 - [I] - core\src\client_p2p.rs:27 -> 正在测试 |
| 33 | +2023-09-04 00:00:00 - [I] - core\src\client_p2p.rs:29 -> 测试成功 |
| 34 | +2023-09-04 00:00:00 - [I] - core\src\client_p2p.rs:31 -> 服务已启动: 127.0.0.1:9833 |
16 | 35 | ```
|
| 36 | +> 注意:P2P无法保证100%的成功率 |
0 commit comments