From 0abfe78858ae60b2f047ce314503223b21eec07b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 24 Sep 2022 13:46:22 +0100 Subject: [PATCH] Silence error when reconnecting to already connected peer --- src/core/link.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/link.go b/src/core/link.go index 08e8dfc2..4d5cff57 100644 --- a/src/core/link.go +++ b/src/core/link.go @@ -113,17 +113,19 @@ func (l *links) isConnectedTo(info linkInfo) bool { func (l *links) call(u *url.URL, sintf string) error { info := linkInfoFor(u.Scheme, sintf, u.Host) if l.isConnectedTo(info) { - return fmt.Errorf("already connected to this node") + return nil } options := linkOptions{ pinnedEd25519Keys: map[keyArray]struct{}{}, } for _, pubkey := range u.Query()["key"] { - if sigPub, err := hex.DecodeString(pubkey); err == nil { - var sigPubKey keyArray - copy(sigPubKey[:], sigPub) - options.pinnedEd25519Keys[sigPubKey] = struct{}{} + sigPub, err := hex.DecodeString(pubkey) + if err != nil { + return fmt.Errorf("pinned key contains invalid hex characters") } + var sigPubKey keyArray + copy(sigPubKey[:], sigPub) + options.pinnedEd25519Keys[sigPubKey] = struct{}{} } switch info.linkType { case "tcp":