From 57aecb868f9b57f42c3a32bce0b453e60061432d Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 14 Nov 2014 14:01:11 +0000 Subject: [PATCH] Add check during initial handshake whether we already have an established connection to this peer --- router/connection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/router/connection.go b/router/connection.go index 488f9a48..64b4ee04 100644 --- a/router/connection.go +++ b/router/connection.go @@ -345,6 +345,11 @@ func (conn *LocalConnection) handshake(acceptNewPeer bool) error { return fmt.Errorf("Found unknown remote name: %s at %s", name, conn.remoteTCPAddr) } } + if existingConn, found := conn.local.ConnectionTo(name); found { + if existingConn.Established() { + return fmt.Errorf("Already have connection to %s at %s", name, existingConn.RemoteTCPAddr()) + } + } uidStr, err := checkHandshakeStringField("UID", "", handshakeRecv) if err != nil {