fix: TUN 子网路由缺失导致客户端无下载流量

- service.go: 移除无意义的 peerIP = serverIP(对端指向自己),改为 nil
- service.go: Configure 之后新增 AddSubnetRoute 调用,确保内核有到 VPN 子网的路由
- tun_linux.go: Configure 增加 peerIP != nil 守卫,nil 时直接走无 peer 分支
- tun_darwin.go: 同上 peerIP != nil 守卫
This commit is contained in:
2026-07-06 18:54:22 +08:00
parent f2bb73a381
commit 808b991483
3 changed files with 11 additions and 13 deletions
+3 -6
View File
@@ -20,13 +20,10 @@ func (t *TUNInterface) Configure(localIP net.IP, prefix int, peerIP net.IP) erro
}
localCidr := fmt.Sprintf("%s/%d", localIP.String(), prefix)
inetType := inetFamily(localIP)
var err error
if t.Iface.IsTUN() && inetType == "inet" {
err = execCmd("ifconfig", t.Name(), inetType, localCidr, peerIP.String(), "up")
} else {
err = execCmd("ifconfig", t.Name(), inetType, localCidr, "up")
if t.Iface.IsTUN() && inetType == "inet" && peerIP != nil {
return execCmd("ifconfig", t.Name(), inetType, localCidr, peerIP.String(), "up")
}
return err
return execCmd("ifconfig", t.Name(), inetType, localCidr, "up")
}
func (t *TUNInterface) AddSubnetRoute(subnet *net.IPNet) error {