5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 12:15:39 +00:00

Add getTunTap to admin socket

This commit is contained in:
Neil Alexander 2018-05-10 09:48:12 +01:00
parent 6d944d8ec8
commit 5299783e35
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -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{"<ifname|auto|none>", "[<tun|tap>]", "[<mtu>]"}, func(out *[]byte, ifparams ...string) {
// Set sane defaults
iftapmode := false