From 5299783e35a6ff4314259c7af9239183915ed888 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 10 May 2018 09:48:12 +0100 Subject: [PATCH] Add getTunTap to admin socket --- src/yggdrasil/admin.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 39aceb98..c6af34b1 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -73,6 +73,24 @@ func (a *admin) init(c *Core, listenaddr string) { *out = []byte("Failed to remove peer: " + sport[0] + "\n") } }) + a.addHandler("getTunTap", nil, func(out *[]byte, _ ...string) { + var info admin_nodeInfo + defer func() { + if r := recover(); r != nil { + info = admin_nodeInfo{ + {"Interface name", "none"}, + } + *out = []byte(a.printInfos([]admin_nodeInfo{info})) + } + }() + + info = admin_nodeInfo{ + {"Interface name", a.core.tun.iface.Name()}, + {"TAP mode", strconv.FormatBool(a.core.tun.iface.IsTAP())}, + {"MTU", strconv.Itoa(a.core.tun.mtu)}, + } + *out = []byte(a.printInfos([]admin_nodeInfo{info})) + }) a.addHandler("setTunTap", []string{"", "[]", "[]"}, func(out *[]byte, ifparams ...string) { // Set sane defaults iftapmode := false