From 4013c482b493f8a7154a1e83ba8845a142f2378c Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 30 Dec 2021 17:48:58 +0800 Subject: [PATCH] add route hook in windows --- lower/tun_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lower/tun_windows.go b/lower/tun_windows.go index 179b304..829dbc6 100644 --- a/lower/tun_windows.go +++ b/lower/tun_windows.go @@ -11,6 +11,13 @@ func (n *NIC) prepare() { panic(err) } execute("cmd", "/c", "netsh interface ip set address name=\""+n.ifce.Name()+"\" source=static addr=\""+n.ip+"\" mask=\""+(net.IP)(ipn.Mask).String()+"\" gateway=none") + 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) + } } func (n *NIC) Up() {