diff options
author | obscuren <geffobscura@gmail.com> | 2015-05-07 04:54:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-07 04:54:21 +0800 |
commit | 062fa049d0322f17f8ba831203a609d048f623f1 (patch) | |
tree | 1600884f30471066b9f54cc26c2a9e95b9b20989 /p2p/handshake.go | |
parent | 24d44f35f2cf17b07330a7e7be79abc2b6b92fc6 (diff) | |
parent | 4accc187d5cf6a100d6c10c0e0f35780f52871a0 (diff) | |
download | go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar.gz go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar.bz2 go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar.lz go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar.xz go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.tar.zst go-tangerine-062fa049d0322f17f8ba831203a609d048f623f1.zip |
fixed merge issue
Diffstat (limited to 'p2p/handshake.go')
-rw-r--r-- | p2p/handshake.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/p2p/handshake.go b/p2p/handshake.go index 79395f23f..8e611cfd5 100644 --- a/p2p/handshake.go +++ b/p2p/handshake.go @@ -70,21 +70,21 @@ type protoHandshake struct { // If dial is non-nil, the connection the local node is the initiator. // If atcap is true, the connection will be disconnected with DiscTooManyPeers // after the key exchange. -func setupConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, dial *discover.Node, atcap bool) (*conn, error) { +func setupConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, dial *discover.Node, atcap bool, trusted map[discover.NodeID]bool) (*conn, error) { if dial == nil { - return setupInboundConn(fd, prv, our, atcap) + return setupInboundConn(fd, prv, our, atcap, trusted) } else { - return setupOutboundConn(fd, prv, our, dial, atcap) + return setupOutboundConn(fd, prv, our, dial, atcap, trusted) } } -func setupInboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, atcap bool) (*conn, error) { +func setupInboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, atcap bool, trusted map[discover.NodeID]bool) (*conn, error) { secrets, err := receiverEncHandshake(fd, prv, nil) if err != nil { return nil, fmt.Errorf("encryption handshake failed: %v", err) } rw := newRlpxFrameRW(fd, secrets) - if atcap { + if atcap && !trusted[secrets.RemoteID] { SendItems(rw, discMsg, DiscTooManyPeers) return nil, errors.New("we have too many peers") } @@ -99,13 +99,13 @@ func setupInboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, a return &conn{rw, rhs}, nil } -func setupOutboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, dial *discover.Node, atcap bool) (*conn, error) { +func setupOutboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake, dial *discover.Node, atcap bool, trusted map[discover.NodeID]bool) (*conn, error) { secrets, err := initiatorEncHandshake(fd, prv, dial.ID, nil) if err != nil { return nil, fmt.Errorf("encryption handshake failed: %v", err) } rw := newRlpxFrameRW(fd, secrets) - if atcap { + if atcap && !trusted[secrets.RemoteID] { SendItems(rw, discMsg, DiscTooManyPeers) return nil, errors.New("we have too many peers") } |