mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-21 20:40:28 +00:00
Don't allow configuring the same peer more than once
This commit is contained in:
parent
8cf76f841d
commit
428d2375da
@ -188,6 +188,13 @@ func (c *Core) SetLogger(log util.Logger) {
|
|||||||
// This adds the peer to the peer list, so that they will be called again if the
|
// This adds the peer to the peer list, so that they will be called again if the
|
||||||
// connection drops.
|
// connection drops.
|
||||||
func (c *Core) AddPeer(uri string, sourceInterface string) error {
|
func (c *Core) AddPeer(uri string, sourceInterface string) error {
|
||||||
|
var known bool
|
||||||
|
phony.Block(c, func() {
|
||||||
|
_, known = c.config._peers[Peer{uri, sourceInterface}]
|
||||||
|
})
|
||||||
|
if known {
|
||||||
|
return fmt.Errorf("peer already configured")
|
||||||
|
}
|
||||||
u, err := url.Parse(uri)
|
u, err := url.Parse(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user