From 428d2375da391b15ac9e2b525ad65351f5128d0c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 2 Oct 2022 12:39:18 +0100 Subject: [PATCH] Don't allow configuring the same peer more than once --- src/core/api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/api.go b/src/core/api.go index 75d9d7b3..dfc309d3 100644 --- a/src/core/api.go +++ b/src/core/api.go @@ -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