p2p: enforce connection retry limit on server side (#19684)

The dialer limits itself to one attempt every 30s. Apply the same limit
in Server and reject peers which try to connect too eagerly. The check
against the limit happens right after accepting the connection.

Further changes in this commit ensure we pass the Server logger
down to Peer instances, discovery and dialState. Unit test logging now
works in all Server tests.
This commit is contained in:
Felix Lange
2019-06-11 12:45:33 +02:00
committed by GitHub
parent c0a034ec89
commit c420dcb39c
9 changed files with 518 additions and 292 deletions

View File

@ -24,6 +24,8 @@ import (
"reflect"
"testing"
"time"
"github.com/ethereum/go-ethereum/log"
)
var discard = Protocol{
@ -52,7 +54,7 @@ func testPeer(protos []Protocol) (func(), *conn, *Peer, <-chan error) {
c2.caps = append(c2.caps, p.cap())
}
peer := newPeer(c1, protos)
peer := newPeer(log.Root(), c1, protos)
errc := make(chan error, 1)
go func() {
_, err := peer.run()