diff options
author | gary rong <garyrong0905@gmail.com> | 2019-06-12 19:09:40 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-06-12 19:09:40 +0800 |
commit | c8c3ebd593703a425a5c9ed5b4e9949308d18e21 (patch) | |
tree | 99b2da074419d2aeaf5507ac20ff5ebc37c0271e /les/peer.go | |
parent | b3f7609d7d887657af3c06e9ac74e38276e7fe87 (diff) | |
download | go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar.gz go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar.bz2 go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar.lz go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar.xz go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.tar.zst go-tangerine-c8c3ebd593703a425a5c9ed5b4e9949308d18e21.zip |
les: reject client if it makes too many invalid requests (#19691)
* les: reject client connection if it makes too much invalid req
* les: address comments
* les: use uint32
* les: fix variable name
* les: add invalid counter for duplicate invalid req
Diffstat (limited to 'les/peer.go')
-rw-r--r-- | les/peer.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/les/peer.go b/les/peer.go index 56d316f50..a615c9b73 100644 --- a/les/peer.go +++ b/les/peer.go @@ -42,7 +42,10 @@ var ( errNotRegistered = errors.New("peer is not registered") ) -const maxResponseErrors = 50 // number of invalid responses tolerated (makes the protocol less brittle but still avoids spam) +const ( + maxRequestErrors = 20 // number of invalid requests tolerated (makes the protocol less brittle but still avoids spam) + maxResponseErrors = 50 // number of invalid responses tolerated (makes the protocol less brittle but still avoids spam) +) // capacity limitation for parameter updates const ( @@ -69,7 +72,6 @@ const ( type peer struct { *p2p.Peer - rw p2p.MsgReadWriter version int // Protocol version negotiated @@ -89,6 +91,7 @@ type peer struct { // RequestProcessed is called responseLock sync.Mutex responseCount uint64 + invalidCount uint32 poolEntry *poolEntry hasBlock func(common.Hash, uint64, bool) bool |