|
| 1 | +# MPTP Usage |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +MPTP (Multipath Transport Protocol) combines multiple outbound paths into one logical transport channel. |
| 6 | +In Leaf, the common deployment is: |
| 7 | + |
| 8 | +- Client side: local `socks` inbound + `mptp` outbound |
| 9 | +- Server side: `mptp` inbound + `direct` outbound |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +### JSON Config |
| 14 | + |
| 15 | +Client example (`client.json`): |
| 16 | + |
| 17 | +```json |
| 18 | +{ |
| 19 | + "inbounds": [ |
| 20 | + { |
| 21 | + "protocol": "socks", |
| 22 | + "address": "127.0.0.1", |
| 23 | + "port": 1086 |
| 24 | + } |
| 25 | + ], |
| 26 | + "outbounds": [ |
| 27 | + { |
| 28 | + "protocol": "mptp", |
| 29 | + "settings": { |
| 30 | + "actors": [ |
| 31 | + "direct1", |
| 32 | + "direct2" |
| 33 | + ], |
| 34 | + "address": "127.0.0.1", |
| 35 | + "port": 3001 |
| 36 | + } |
| 37 | + }, |
| 38 | + { |
| 39 | + "protocol": "direct", |
| 40 | + "tag": "direct1" |
| 41 | + }, |
| 42 | + { |
| 43 | + "protocol": "direct", |
| 44 | + "tag": "direct2" |
| 45 | + } |
| 46 | + ] |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +Server example (`server.json`): |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "inbounds": [ |
| 55 | + { |
| 56 | + "protocol": "mptp", |
| 57 | + "address": "0.0.0.0", |
| 58 | + "port": 3001 |
| 59 | + } |
| 60 | + ], |
| 61 | + "outbounds": [ |
| 62 | + { |
| 63 | + "protocol": "direct" |
| 64 | + } |
| 65 | + ] |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +Key fields: |
| 70 | + |
| 71 | +- `outbounds[].protocol = "mptp"`: enables MPTP client outbound |
| 72 | +- `settings.actors`: list of outbound tags used as sub-connections |
| 73 | +- `settings.address`, `settings.port`: MPTP server address and port |
| 74 | +- `inbounds[].protocol = "mptp"`: enables MPTP server inbound listener |
| 75 | + |
| 76 | +### conf Config |
| 77 | + |
| 78 | +MPTP outbound can also be configured in `[Proxy Group]`: |
| 79 | + |
| 80 | +```conf |
| 81 | +[Proxy Group] |
| 82 | +MptpOutTag = mptp, actor1, actor2, actor3, address=1.2.3.4, port=10000 |
| 83 | +``` |
| 84 | + |
| 85 | +## Running |
| 86 | + |
| 87 | +Build: |
| 88 | + |
| 89 | +```bash |
| 90 | +cargo build -p leaf-cli --release |
| 91 | +``` |
| 92 | + |
| 93 | +Run server: |
| 94 | + |
| 95 | +```bash |
| 96 | +./target/release/leaf -c server.json |
| 97 | +``` |
| 98 | + |
| 99 | +Run client: |
| 100 | + |
| 101 | +```bash |
| 102 | +./target/release/leaf -c client.json |
| 103 | +``` |
| 104 | + |
| 105 | +## Validation |
| 106 | + |
| 107 | +1. Configure your app to use local SOCKS5 proxy `127.0.0.1:1086`. |
| 108 | +2. Start with simple connectivity checks: |
| 109 | + |
| 110 | +```bash |
| 111 | +curl --socks5 127.0.0.1:1086 https://example.com |
| 112 | +``` |
| 113 | + |
| 114 | +3. Verify configuration syntax before production startup: |
| 115 | + |
| 116 | +```bash |
| 117 | +./target/release/leaf -c client.json -T |
| 118 | +./target/release/leaf -c server.json -T |
| 119 | +``` |
| 120 | + |
| 121 | +## Notes |
| 122 | + |
| 123 | +- `actors` should include at least two outbounds to achieve multipath aggregation. |
| 124 | +- Ensure each actor tag exists in `outbounds`. |
| 125 | +- Open server listening port (for example `3001`) in firewall/security group. |
0 commit comments