From b368421dbddf6d3a9857df21d60aa04337fc3a93 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 25 Sep 2018 17:13:35 +0100 Subject: [PATCH] Fix addPeer to make interface= optional --- src/yggdrasil/admin.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 8c4944a..9f57881 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -113,18 +113,22 @@ func (a *admin) init(c *Core, listenaddr string) { return admin_info{"sessions": sessions}, nil }) a.addHandler("addPeer", []string{"uri", "[interface]"}, func(in admin_info) (admin_info, error) { - if a.addPeer(in["uri"].(string), in["interface"].(string)) == nil { + // Set sane defaults + intf := "" + // Has interface been specified? + if itf, ok := in["interface"]; ok { + intf = itf.(string) + } + if a.addPeer(in["uri"].(string), intf) == nil { return admin_info{ "added": []string{ in["uri"].(string), - in["interface"].(string), }, }, nil } else { return admin_info{ "not_added": []string{ in["uri"].(string), - in["interface"].(string), }, }, errors.New("Failed to add peer") }