The bootstrap mode is used only for bootstrap nodes.
A bootstrap node will maintain a tree of the whole dht
up to 6 bits deep (8*2^6 = 4096 nodes).
This allows to provide better initial answers to new nodes.
Bootstrap nodes act otherwise normally.
This patch makes search nodes candidates when they failed to reply
to a first message. This allows the search operations to go forward,
while preserving the node opportunity to reply.
A candidate flag is added to new search nodes when a search
is already synced.
The flag is waived when a token is retreived from the node.
Candidate nodes behave normally but are not considered
to evaluate the search state (synced etc.).
The behavior of searches if also changed so GET_NODES
updates are now done the same way, no matter if the search
is currently synced. This allow candidate nodes to behave
normally and makes token update asynchronous, causing
less frequent performance hickups.
We filter out incoming packet if my_v field is not known.
This prevents to be flooded by others bittorrent-like clients.
Signed-off-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
ASAN build shows a buffer-overflow that happens frequently
when blacklistNode tryies to remove blacklisted node from
searches using erase/remove_if std C++ pattern.
This is more frequent using optimized build (gcc -O3).
erase/remove_if pattern is a valid design, so it may be a
failure in stdc++ implementation (not confirmed).
To solve that we fallback to an explicit search loop/erase
pattern.
Signed-off-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>