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:
@@ -15,13 +15,12 @@ func (t *TUNInterface) Configure(localIP net.IP, prefix int, peerIP net.IP) erro
|
||||
return nil
|
||||
}
|
||||
localCidr := fmt.Sprintf("%s/%d", localIP.String(), prefix)
|
||||
args := []string{"addr", "add", "dev", t.Name(), localCidr, "peer", peerIP.String()}
|
||||
if err := execCmd("ip", args...); err != nil {
|
||||
if err2 := execCmd("ip", "addr", "add", "dev", t.Name(), localCidr); err2 != nil {
|
||||
return err
|
||||
if peerIP != nil {
|
||||
if err := execCmd("ip", "addr", "add", "dev", t.Name(), localCidr, "peer", peerIP.String()); err == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return execCmd("ip", "addr", "add", "dev", t.Name(), localCidr)
|
||||
}
|
||||
|
||||
func (t *TUNInterface) AddSubnetRoute(subnet *net.IPNet) error {
|
||||
|
||||
Reference in New Issue
Block a user