中文 | English
A SOCKS5 proxy port forwarding tool supporting both TCP and UDP.
- TCP Forwarding: Forward local TCP port traffic to target servers through a SOCKS5 proxy
- UDP Forwarding: Support SOCKS5 UDP ASSOCIATE for UDP traffic forwarding
- Dual Protocol Listening: Simultaneously listen on the same port for TCP and UDP
- Bind Specific IP: Support binding to specific IP addresses (IPv4/IPv6)
- TCP Optimization: Support KeepAlive and TCP_NODELAY
- Protocol Differentiation: TCP and UDP can specify different target addresses
- Config File Support: Automatically loads
config.yamlwhen run without arguments - Windows System Tray: When run without arguments on Windows, minimizes to the system tray (bottom-right) instead of the taskbar
Place a config.yaml file next to redirect.exe, then double-click redirect.exe:
- The console window is hidden automatically and an icon appears in the system tray
- Right-click the tray icon to exit
- Logs are written to
redirect.logalongside the executable
Example config.yaml (see config.yaml.example in this repo):
listen: tcp://:8889,udp://:8889
proxy: 127.0.0.1:1080
remote: target.com:443
keepalive: false
ttl: 30
nodelay: falseSupported keys match the command-line flags: listen (-l), proxy (-s), remote (-r), keepalive, ttl, nodelay.
redirect.exe -l <listen_address> -s <SOCKS5_proxy> -r <target_address>When any CLI argument is provided, the program runs in normal console mode and does not enter tray mode.
| Parameter | Required | Description | Example |
|---|---|---|---|
-l |
Yes | Local listen address | tcp://:8889 |
-s |
Yes | SOCKS5 proxy address | 127.0.0.1:1080 |
-r |
Yes | Target server address | target.com:443 |
-keepalive |
No | Enable TCP KeepAlive (default false) | -keepalive |
-ttl |
No | TCP KeepAlive interval in seconds (default 30) | -ttl=10 |
-nodelay |
No | Enable TCP_NODELAY (default false) | -nodelay |
-h |
No | Show help information | -h |
Listen Address (-l):
tcp://[ip:]port- Listen on TCP portudp://[ip:]port- Listen on UDP port[ip:]port- Default to TCP listening- Multiple addresses separated by commas
Proxy Address (-s):
host:portsocks5://host:port
Target Address (-r):
host:port- Same target for TCP and UDPtcp://host:port,udp://host:port- Specify targets separately
Forward local port 8889 TCP traffic through SOCKS5 proxy to target.com:443:
redirect.exe -l tcp://:8889 -s 127.0.0.1:1080 -r target.com:443Listen on both TCP and UDP port 8889:
redirect.exe -l tcp://:8889,udp://:8889 -s 127.0.0.1:1080 -r target.com:443Only listen on 127.0.0.1:8889:
redirect.exe -l tcp://127.0.0.1:8889 -s 127.0.0.1:1080 -r target.com:443Bind to IPv6 address:
redirect.exe -l tcp://[::1]:8889 -s 127.0.0.1:1080 -r target.com:443Forward TCP to tcp-target:443 and UDP to udp-target:53:
redirect.exe -l tcp://:8889,udp://:8889 -s 127.0.0.1:1080 -r tcp://tcp-target:443,udp://udp-target:53Enable KeepAlive and TCP_NODELAY:
redirect.exe -l tcp://:8889 -s 127.0.0.1:1080 -r target.com:443 -keepalive -nodelaySet KeepAlive interval to 10 seconds:
redirect.exe -l tcp://:8889 -s 127.0.0.1:1080 -r target.com:443 -keepalive -ttl=10# Windows (recommended: GUI subsystem, no console/terminal window on double-click)
go build -ldflags "-H=windowsgui -s -w" -o redirect.exe .
# Windows (debug: keep console subsystem)
go build -o redirect.exe .
# Linux/Mac
go build -o redirect .
⚠️ On systems with Windows Terminal installed, you MUST build with-H=windowsgui; otherwise Windows Terminal's host window cannot be hidden and will remain in the taskbar.
- TCP and UDP use different protocol stacks, so they can bind to the same IP and port simultaneously
- UDP forwarding depends on SOCKS5 proxy's UDP ASSOCIATE support
- Target addresses support IPv4, IPv6, and domain names
- When launched without arguments (double-click),
config.yamlmust be in the same directory asredirect.exe - In tray mode, logs are written to
redirect.lognext to the executable for troubleshooting - System tray support is Windows-only; on Linux/macOS, the no-argument mode runs in the foreground