aboutsummaryrefslogtreecommitdiff
path: root/src/net_permissions.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2021-06-30 11:52:40 -0700
committerPieter Wuille <pieter@wuille.net>2021-07-15 12:52:38 -0700
commit0d64b8f709b4655d8702f810d4876cd8d96ded82 (patch)
tree8cb80df524d325c9fddd5f7e43202176375951ec /src/net_permissions.h
parenta88fa1a555195af6543cdc802e8e1c2e1668dd38 (diff)
Rate limit the processing of incoming addr messages
While limitations on the influence of attackers on addrman already exist (affected buckets are restricted to a subset based on incoming IP / network group), there is no reason to permit them to let them feed us addresses at more than a multiple of the normal network rate. This commit introduces a "token bucket" rate limiter for the processing of addresses in incoming ADDR and ADDRV2 messages. Every connection gets an associated token bucket. Processing an address in an ADDR or ADDRV2 message from non-whitelisted peers consumes a token from the bucket. If the bucket is empty, the address is ignored (it is not forwarded or processed). The token counter increases at a rate of 0.1 tokens per second, and will accrue up to a maximum of 1000 tokens (the maximum we accept in a single ADDR or ADDRV2). When a GETADDR is sent to a peer, it immediately gets 1000 additional tokens, as we actively desire many addresses from such peers (this may temporarily cause the token count to exceed 1000). The rate limit of 0.1 addr/s was chosen based on observation of honest nodes on the network. Activity in general from most nodes is either 0, or up to a maximum around 0.025 addr/s for recent Bitcoin Core nodes. A few (self-identified, through subver) crawler nodes occasionally exceed 0.1 addr/s.
Diffstat (limited to 'src/net_permissions.h')
-rw-r--r--src/net_permissions.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/net_permissions.h b/src/net_permissions.h
index c00689465e..bc979e3792 100644
--- a/src/net_permissions.h
+++ b/src/net_permissions.h
@@ -31,7 +31,8 @@ enum class NetPermissionFlags : uint32_t {
NoBan = (1U << 4) | Download,
// Can query the mempool
Mempool = (1U << 5),
- // Can request addrs without hitting a privacy-preserving cache
+ // Can request addrs without hitting a privacy-preserving cache, and send us
+ // unlimited amounts of addrs.
Addr = (1U << 7),
// True if the user did not specifically set fine grained permissions