mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-28 02:37:48 +00:00
Fix addPeer to make interface= optional
This commit is contained in:
parent
1796000b05
commit
b368421dbd
@ -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")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user