1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00
Files
WireGold/lower/tun_darwin.go
2024-08-03 16:42:16 +08:00

29 lines
694 B
Go

//go:build darwin
// +build darwin
package lower
import "net"
func (n *NICIO) Up() {
execute("ifconfig", n.ifce.Name(), "mtu", n.mtu) // max: 9159
execute(
"ifconfig", n.ifce.Name(),
"inet", n.ip.String(), n.ip.String(),
"netmask", (net.IP)(n.subnet.Mask).String(),
"up",
)
execute("route", "add", n.subnet.String(), "-interface", n.ifce.Name())
for _, c := range n.cidrs {
execute("route", "add", c, "-interface", n.ifce.Name())
}
}
func (n *NICIO) Down() {
execute("route", "delete", n.subnet.String(), "-interface", n.ifce.Name())
for _, c := range n.cidrs {
execute("route", "delete", c, "-interface", n.ifce.Name())
}
execute("ifconfig", n.ifce.Name(), "down")
}