Traffics
A simple but powerful port forwarding service
Overview
Traffics is a lightweight port forwarding tool that supports TCP, UDP, and mixed protocol traffic forwarding. It features simple configuration and high performance.
Installation
# Clone the project
git clone --depth=1 --branch=main https://github.com/woshikedayaa/traffics.git
# Build the project
cd traffics/
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags="-w -s" -v -o bin/traffics .
# Optional: Install to system PATH
install -o root -g root -m 0755 bin/traffics /usr/bin/traffics
Architecture
Traffics uses a Binds (listeners) + Remotes (targets) architecture:
- Binds: Local listening configuration, defines ports and protocols to listen on
- Remotes: Remote target configuration, defines destination servers for forwarding
Traffic flow: Client → Bind Listener → Remote Target Server
Usage
Zero Config Mode (Command Line)
Supports multiple forwarding rules:
# Single rule
traffics -l "tcp+udp://:5353?remote=dns" -r "dns://1.1.1.1:53"
# Multiple rules
traffics \
-l "tcp+udp://:5353?remote=dns" \
-l "tcp://:8080?remote=web" \
-r "dns://1.1.1.1:53?timeout=5s" \
-r "web://192.168.1.100:80?tfo=true"
Configuration File Mode
traffics -c config.json
Configuration files support two formats: URL shorthand and complete configuration, which can be mixed.
Basic Structure
{
"log": {
"level": "info"
},
"binds": [
"tcp+udp://:5353?remote=dns&udp_ttl=60s",
{
"listen": "::",
"port": 8080,
"network": "tcp",
"remote": "web"
}
],
"remotes": [
"dns://1.1.1.1:53?strategy=prefer_ipv4&timeout=5s",
{
"name": "web",
"server": "192.168.1.100",
"port": 80,
"timeout": "10s"
}
]
}
Bind URL
protocol://[address]:port?param=value¶m=value
Remote URL
name://server:port?param=value¶m=value
Configuration Reference
Log Configuration
disable: Disable logging (default: false)
level: Log level - trace, debug, info, warn, error, fatal, panic
Bind Configuration
Required fields:
listen: Listen address
port: Listen port
remote: Associated remote service name
Optional fields:
name: Bind configuration name
network: Network protocol - tcp, udp, tcp+udp (default: tcp+udp)
family: IP version - 4 or 6
interface: Bind to network interface
reuse_addr: Enable address reuse
tfo: TCP Fast Open
mptcp: Multipath TCP
udp_ttl: UDP connection timeout (e.g., "60s")
udp_buffer_size: UDP buffer size (default: 65507)
udp_fragment: UDP fragmentation support
Remote Configuration
Required fields:
server: Target server address
port: Target server port
name: Remote service name (corresponds to remote field in bind)
Optional fields:
dns: Custom DNS server
strategy: DNS resolution strategy - prefer_ipv4, prefer_ipv6, ipv4_only, ipv6_only
interface: Outbound network interface
timeout: Connection timeout (e.g., "5s")
reuse_addr: Enable address reuse
bind_address4: IPv4 bind address
bind_address6: IPv6 bind address
fwmark: Firewall marka
mptcp: Multipath TCP
udp_fragment: UDP fragmentation support
Note: URL parameters use the same field names as JSON configuration.
Example Configuration
{
"log": {
"level": "info"
},
"binds": [
"tcp+udp://:5353?remote=dns&udp_ttl=60s",
{
"listen": "0.0.0.0",
"port": 8080,
"network": "tcp",
"remote": "web",
"tfo": true
}
],
"remotes": [
"dns://1.1.1.1:53?strategy=prefer_ipv4&timeout=10s",
{
"name": "web",
"server": "backend.example.com",
"port": 80,
"timeout": "15s"
}
]
}
Important Notes
- In
tcp+udp mode, both TCP and UDP traffic will be forwarded to the same remote service
- The
remote field in binds must match the name field in remotes configuration
- URL parameters and JSON field names are identical
- Both URL and complete configuration formats can be mixed in the same configuration file
Acknowledgments
This project uses the following excellent open-source libraries:
- tfo-go - TCP Fast Open implementation for Go
- dns - DNS library in Go
- sing - Universal proxy platform
We are grateful to all contributors and maintainers of these projects for their valuable work.