5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 14:10:28 +00:00

Add getTunTap to JSON admin socket

This commit is contained in:
Neil Alexander 2018-05-20 19:42:37 +01:00
parent c3ca5c64b1
commit 4ecc7ce860
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -2,8 +2,6 @@ package yggdrasil
import "net" import "net"
import "os" import "os"
// import "bytes"
import "encoding/hex" import "encoding/hex"
import "encoding/json" import "encoding/json"
import "errors" import "errors"
@ -15,7 +13,6 @@ import "strconv"
import "sync/atomic" import "sync/atomic"
import "time" import "time"
// TODO? Make all of this JSON
// TODO: Add authentication // TODO: Add authentication
type admin struct { type admin struct {
@ -133,25 +130,20 @@ func (a *admin) init(c *Core, listenaddr string) {
}, errors.New("Failed to remove peer") }, errors.New("Failed to remove peer")
} }
}) })
/* a.addHandler("getTunTap", nil, func(in admin_info) (r admin_info, e error) {
a.addHandler("getTunTap", nil, func(out *[]byte, _ ...string) { defer func() {
var info admin_nodeInfo recover()
defer func() { r = admin_info{"name": "none"}
if r := recover(); r != nil { e = nil
info = admin_nodeInfo{ }()
{"Interface name", "none"},
}
*out = []byte(a.printInfos([]admin_nodeInfo{info}))
}
}()
info = admin_nodeInfo{ return admin_info{
{"Interface name", a.core.tun.iface.Name()}, "name": a.core.tun.iface.Name(),
{"TAP mode", strconv.FormatBool(a.core.tun.iface.IsTAP())}, "tap_mode": a.core.tun.iface.IsTAP(),
{"mtu", strconv.Itoa(a.core.tun.mtu)}, "mtu": a.core.tun.mtu,
} }, nil
*out = []byte(a.printInfos([]admin_nodeInfo{info})) })
}) /*
a.addHandler("setTunTap", []string{"<ifname|auto|none>", "[<tun|tap>]", "[<mtu>]"}, func(out *[]byte, ifparams ...string) { a.addHandler("setTunTap", []string{"<ifname|auto|none>", "[<tun|tap>]", "[<mtu>]"}, func(out *[]byte, ifparams ...string) {
// Set sane defaults // Set sane defaults
iftapmode := false iftapmode := false
@ -184,6 +176,8 @@ func (a *admin) init(c *Core, listenaddr string) {
*out = []byte(a.printInfos([]admin_nodeInfo{info})) *out = []byte(a.printInfos([]admin_nodeInfo{info}))
} }
}) })
*/
/*
a.addHandler("getAllowedBoxPubs", nil, func(out *[]byte, _ ...string) { a.addHandler("getAllowedBoxPubs", nil, func(out *[]byte, _ ...string) {
*out = []byte(a.getAllowedBoxPubs()) *out = []byte(a.getAllowedBoxPubs())
}) })