implement down

This commit is contained in:
Callan Bryant 2020-03-04 22:11:08 +00:00
parent d9f197c06f
commit c04eeac00f
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA
2 changed files with 25 additions and 0 deletions

View File

@ -31,6 +31,7 @@ func main() {
case "report":
case "down":
dsnet.Down()
default:
help()

24
down.go Normal file
View File

@ -0,0 +1,24 @@
package dsnet
import (
"github.com/vishvananda/netlink"
)
func Down() {
conf := MustLoadDsnetConfig()
DelLink(conf)
}
func DelLink(conf *DsnetConfig) {
linkAttrs := netlink.NewLinkAttrs()
linkAttrs.Name = conf.InterfaceName
link := &netlink.GenericLink{
LinkAttrs: linkAttrs,
}
err := netlink.LinkDel(link)
if err != nil {
ExitFail("Could not delete interface '%s' (%v)", conf.InterfaceName, err)
}
}