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

Fix addPeer to make interface= optional

This commit is contained in:
Neil Alexander 2018-09-25 17:13:35 +01:00
parent 1796000b05
commit b368421dbd
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -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")
}