5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-21 21:50:29 +00:00

Don't allow configuring the same peer more than once

This commit is contained in:
Neil Alexander 2022-10-02 12:39:18 +01:00
parent 8cf76f841d
commit 428d2375da

View File

@ -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
// connection drops.
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)
if err != nil {
return err