add dead codde to bring up iface

This commit is contained in:
Callan Bryant 2020-03-04 19:56:57 +00:00
parent c7e9210a96
commit deef2574e7
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA
2 changed files with 12 additions and 4 deletions

View File

@ -23,6 +23,7 @@ func main() {
dsnet.Add() dsnet.Add()
case "up": case "up":
dsnet.Up()
case "update": case "update":

15
up.go
View File

@ -17,14 +17,14 @@ func CreateInterface(conf *DsnetConfig) {
linkAttrs := netlink.NewLinkAttrs() linkAttrs := netlink.NewLinkAttrs()
linkAttrs.Name = conf.InterfaceName linkAttrs.Name = conf.InterfaceName
iface := &netlink.GenericLink{ link := &netlink.GenericLink{
LinkAttrs: linkAttrs, LinkAttrs: linkAttrs,
LinkType: "wireguard", LinkType: "wireguard",
} }
err := netlink.LinkAdd(iface) err := netlink.LinkAdd(link)
if err != nil { if err != nil {
ExitFail("Could not add '%s' (%v)", linkAttrs.Name, err) ExitFail("Could not add interface '%s' (%v)", linkAttrs.Name, err)
} }
addr := &netlink.Addr{ addr := &netlink.Addr{
@ -34,7 +34,7 @@ func CreateInterface(conf *DsnetConfig) {
}, },
} }
err = netlink.AddrAdd(iface, addr) err = netlink.AddrAdd(link, addr)
if err != nil { if err != nil {
ExitFail("Could not add addr %s to interface %s", addr.IP, err) ExitFail("Could not add addr %s to interface %s", addr.IP, err)
} }
@ -52,4 +52,11 @@ func CreateInterface(conf *DsnetConfig) {
if err != nil { if err != nil {
ExitFail("Could not configure device '%s' (%v)", linkAttrs.Name, err) ExitFail("Could not configure device '%s' (%v)", linkAttrs.Name, err)
} }
// bring up interface (needs conf first)
//err = netlink.LinkSetUp(link)
//
//if err != nil {
// ExitFail("Could not bring up device '%s' (%v)", linkAttrs.Name, err)
//}
} }