mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 07:30:27 +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
|
return admin_info{"sessions": sessions}, nil
|
||||||
})
|
})
|
||||||
a.addHandler("addPeer", []string{"uri", "[interface]"}, func(in admin_info) (admin_info, error) {
|
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{
|
return admin_info{
|
||||||
"added": []string{
|
"added": []string{
|
||||||
in["uri"].(string),
|
in["uri"].(string),
|
||||||
in["interface"].(string),
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
} else {
|
} else {
|
||||||
return admin_info{
|
return admin_info{
|
||||||
"not_added": []string{
|
"not_added": []string{
|
||||||
in["uri"].(string),
|
in["uri"].(string),
|
||||||
in["interface"].(string),
|
|
||||||
},
|
},
|
||||||
}, errors.New("Failed to add peer")
|
}, errors.New("Failed to add peer")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user