From 236692bdc42accdfecd43ffd6730df80f20a7a22 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 5 Mar 2019 17:55:46 +0000 Subject: [PATCH] Add getTunnelRouting and setTunnelRouting (fixes #362) --- src/yggdrasil/admin.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index b42b2315..a7b5bd95 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -252,6 +252,23 @@ func (a *admin) init(c *Core) { }, errors.New("Failed to remove allowed key") } }) + a.addHandler("getTunnelRouting", []string{}, func(in admin_info) (admin_info, error) { + enabled := false + a.core.router.doAdmin(func() { + enabled = a.core.router.cryptokey.isEnabled() + }) + return admin_info{"enabled": enabled}, nil + }) + a.addHandler("setTunnelRouting", []string{"enabled"}, func(in admin_info) (admin_info, error) { + enabled := false + if e, ok := in["enabled"].(bool); ok { + enabled = e + } + a.core.router.doAdmin(func() { + a.core.router.cryptokey.setEnabled(enabled) + }) + return admin_info{"enabled": enabled}, nil + }) a.addHandler("addSourceSubnet", []string{"subnet"}, func(in admin_info) (admin_info, error) { var err error a.core.router.doAdmin(func() {