它可以把透明代理的流量转发到socks5代理服务器上。
GOOS=freebsd GOARCH=amd64 go build -o transocks_ng_freebsd .如需ARM64架构,将 GOARCH 改为 arm64。
Usage of ./transocks_ng:
-dial-timeout duration
SOCKS5 连接/握手超时(0 表示不限制,默认 15s)
-idle-timeout duration
转发连接空闲超过该时长后关闭(0 表示不限制,默认关闭)
-l string
local listen address (default "127.0.0.1:8388")
-p string
proxy address (eg. socks5://user:pass@192.168.1.100:1080)
-fakeip-cache-size int
fakeip reverse lookup cache size (default 1024)
-fakeip-cache-ttl duration
fakeip reverse lookup cache ttl (default 1m0s)
-fakeip-prefix string
redis key prefix for fakeip reverse mapping (default "fakeip:ip:")
-redis string
redis address for fakeip reverse lookup (empty disables)
-redis-db int
redis db number
-redis-password string
redis password
当配置了 -redis 时,转发前会用目标 IP 反查 fakeip:ip:<IP>,
命中则把原始域名(去掉末尾点)交给 SOCKS5 建立连接;未命中或 Redis
不可用时回退为直接使用 IP,不影响普通流量。
ipfw add 100 fwd 127.0.0.1,8388 tcp from any to any recv tun1其中tun1是OpenVPN的虚拟网卡。比如在iPad/iPhone设备上安装OpenVPN,将所有tcp流量重定向到OpenVPN Server,再用本工具+防火墙实现大内外网分流。
注意:如果 SOCKS5 代理地址也通过 tun1 可达(例如代理位于 VPN 对端), 本工具与代理之间的连接/回包也会命中上面的 fwd 规则,形成转发循环。 此时需要先加例外规则(把 192.168.1.100 换成你的代理地址):
ipfw add 95 allow tcp from any to 192.168.1.100 1080 recv tun1 ipfw add 96 allow tcp from 192.168.1.100 1080 to any recv tun1 ipfw add 100 fwd 127.0.0.1,8388 tcp from any to any recv tun1
程序收到 SIGINT/SIGTERM 后会先停止接收新连接、等待已有连接结束再退出;再次发送信号可强制退出。