From deef2574e76291a74a98d86766669fb46303079b Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Wed, 4 Mar 2020 19:56:57 +0000 Subject: [PATCH] add dead codde to bring up iface --- cmd/dsnet.go | 1 + up.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/dsnet.go b/cmd/dsnet.go index 99d4bee..4dad8f3 100644 --- a/cmd/dsnet.go +++ b/cmd/dsnet.go @@ -23,6 +23,7 @@ func main() { dsnet.Add() case "up": + dsnet.Up() case "update": diff --git a/up.go b/up.go index 0547120..07f2b72 100644 --- a/up.go +++ b/up.go @@ -17,14 +17,14 @@ func CreateInterface(conf *DsnetConfig) { linkAttrs := netlink.NewLinkAttrs() linkAttrs.Name = conf.InterfaceName - iface := &netlink.GenericLink{ + link := &netlink.GenericLink{ LinkAttrs: linkAttrs, LinkType: "wireguard", } - err := netlink.LinkAdd(iface) + err := netlink.LinkAdd(link) 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{ @@ -34,7 +34,7 @@ func CreateInterface(conf *DsnetConfig) { }, } - err = netlink.AddrAdd(iface, addr) + err = netlink.AddrAdd(link, addr) if err != nil { ExitFail("Could not add addr %s to interface %s", addr.IP, err) } @@ -52,4 +52,11 @@ func CreateInterface(conf *DsnetConfig) { if err != nil { 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) + //} }