1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-07 17:00:24 +08:00
Files
WireGold/lower/tun_windows.go
2021-12-30 17:48:58 +08:00

32 lines
840 B
Go

//go:build windows
// +build windows
package lower
import "net"
func (n *NIC) prepare() {
_, ipn, err := net.ParseCIDR(n.subnet)
if err != nil {
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() {
// execute("netsh", "interface", "set", "interface", n.ifce.Name(), "enabled")
// don't need to bring up the device by hand
}
func (n *NIC) Down() {
// execute("netsh", "interface", "set", "interface", n.ifce.Name(), "disabled")
// don't need to bring up the device by hand
}