From b86a65819c58574c8204ca8b8c4ad8ebd89ab85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 7 Apr 2026 18:26:34 +0800 Subject: [PATCH] fix(lower): windows ip routing --- lower/tun_windows.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lower/tun_windows.go b/lower/tun_windows.go index 919d4c1..335f129 100644 --- a/lower/tun_windows.go +++ b/lower/tun_windows.go @@ -3,17 +3,24 @@ package lower -import "net" +import ( + "net" + "strconv" +) func (n *NICIO) Up() { execute("cmd", "/c", "netsh interface ip set address name=\""+n.ifce.Name()+"\" source=static addr=\""+n.ip.String()+"\" mask=\""+(net.IP)(n.subnet.Mask).String()+"\" gateway=none") execute("cmd", "/c", "netsh interface ipv4 set subinterface \""+n.ifce.Name()+"\" mtu="+n.mtu) + iface, err := net.InterfaceByName(n.ifce.Name()) + if err != nil { + panic(err) + } for _, c := range n.cidrs { ip, cidr, err := net.ParseCIDR(c) if err != nil { panic(err) } - execute("cmd", "/c", "route ADD "+ip.String()+" MASK "+(net.IP)(cidr.Mask).String()+" "+n.ip.String()) + execute("cmd", "/c", "route ADD "+ip.String()+" MASK "+(net.IP)(cidr.Mask).String()+" "+n.ip.String()+" IF "+strconv.Itoa(iface.Index)) } }