Traffic Forwarding
Traffic Forwarding
Read this in other languages: 中文.
Quick Start
Prerequisite: The server already has a Rust environment.
Installation:
Upon successful installation, you will see the following path:
)
)
【Non-root Account】 Add a soft link to /usr/bin:
sudo ln -s /home/youre_account/.cargo/bin/traffic_forward /usr/bin/traffic_forward
View version:
Or:
Usage:
- Add forwarding:
# Use local port 5555 to forward to 192.102.11.44:8000
- List of existing rules:
sudo traffic_forward list
0.0.0.0:5555 -> 192.102.11.44:8000
- Query traffic consumption for a specific IP:
sudo traffic_forward query 192.102.11.44
- Delete forwarding rule for a specific IP:
- Start the web API:
Web API Interface
Add
- uri: iptables/add
- method: post
- request
{
"target_ip": "192.168.50.50",
"target_port": "4488",
"local_port": "4433",
}
- response
{
"code": 1,
"msg": "Success",
"data": null
}
Delete
- uri: iptables/del
- method: post
- request
{
"target_ip": "192.168.50.50"
}
- response
{
"code": 1,
"msg": "Success",
"data": null
}
List
- uri: iptables/list
- method: get
- request: empty (change next version will)
- response
{
"code": 1,
"msg": "Success",
"data": {
"list": [
{
"ip": "192.168.50.50",
"target_port": "4488",
"local_port": "4433"
}
]
}
}