-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Introduce BanMan #11457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce BanMan #11457
Conversation
8f30300 to
a006ca2
Compare
src/banman.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding GUARDED_BY(…) (see #10866 and #11226) annotations here?
Like this:
CCriticalSection m_cs_banned;
banmap_t m_banned GUARDED_BY(m_cs_banned);
bool m_is_dirty GUARDED_BY(m_cs_banned);
Nit: The lock was renamed from cs_setBanned to m_cs_banned. All CCriticalSection:s in the code base except m_cs_callbacks_pending are named with the cs_ prefix (as opposed to m_cs_). Is m_cs_ the recommended prefix going forward? More specifically, what prefix is recommended for my work in #10866? :-)
I think there is a point in having consistent naming for the locks in order to allow for easy grepping of the locks. Personally I use grepping frequently (e.g. git grep ' cs_[a-zA-Z0-9]\+;' -- "*.h" "*.cpp") in the scripts that keep tracks of the locks to cover in #10866).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class member variables have a m_ prefix.
So yes, m_cs_foo is the recommended syntax going forward for member mutexes, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding GUARDED_BY(…) (see #10866 and #11226) annotations here?
Will do. Additionally, this actually needs another mutex for the db. I've been debating whether it should be fixed as part of this PR, but event-driven db flushes can actually collide with the one on a timer. addrman has the same issue, and that may be the cause of some addrman corruption we've seen lately (#11252, #11409, #11454).
|
Concept ACK modulo |
|
Concept Ack! |
jimpo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/addrdb.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
src/banman.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a class-level comment? (Like placed right above class BanMan)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BanMan still needs class-level comment.
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking godd, will give it a full review when it quiets down.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt these technically be in the opposite order? Isnt there otherwise a (supidly rare) race where a new connection can come in and slip behind the ban?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point. Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inverting opens another dumb case: ban -> (unban -> connect) -> disconnect 🙄 Do you think DisconnectNode() should be called inside Ban() while the lock is held?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this could reasonably happen. Anyway, it's not a departure from the current behavior.
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review. Concept ACK.
src/banman.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif // BITCOIN_BANMAN_H
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use std::make_unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's c++14 :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inverting opens another dumb case: ban -> (unban -> connect) -> disconnect 🙄 Do you think DisconnectNode() should be called inside Ban() while the lock is held?
src/test/DoS_tests.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use std::make_unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use std::make_unique.
It's not available in c++11, but we do have MakeUnique in src/util.h
|
Nice! |
src/banman.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to move ClearBanned() to a subclass that's only used by the test suite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a misleading comment that needs to be dropped. This is used by the clearbanned rpc as well.
|
Rebased and addressed most of the feedback here. |
sdaftuar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. Left a few comments/questions, but looks pretty good. I still need to verify the move-only-ness of a758cebfc66e0a694506291d925f2ef156661654.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to invoke the new DisconnectNode() method that takes a CNetAddr, rather than just the nodeid, in order to keep the behavior the same (ie disconnect all peers on the same subnet)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When accepting an ip as a string from the user I agree. But in this case the request is for a specific node, so I would argue that the id is more in line with what the user would expect.
I don't care hugely either way though.
As an aside, what we really need here is kick/ban/kick+ban options. But I don't think it's worth adding the complexity?
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a place where a constexpr is preferred over just const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will change.
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same question as before, about whether constexpr should be preferred?)
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly an aside, since we're already doing it this way with connman, but I'm curious why we're not using shared pointers here instead of this unique_ptr.get() stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because these aren't intended to be actual globals. We just don't (yet) have the infrastructure to pass them into RPC and qt. Once banman/addrman are split out, I'll be PRing a set of changes that make RPC instantiated. With that done, the ui (rpc/qt/whatever else) will have these interfaces passed in, and they can assume that the pointers are good for their lifetime.
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a circumstance where g_banman would not exist here? If so a comment would be nice; if not then I'm wondering if we should assert instead, or otherwise enforce a shutdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original thinking was that if we add a -nop2p option (which I'm hoping we can do soon), the bandb would be disabled as well. But thinking about it now, one doesn't exclude the other. So yes, an assert makes more sense here. Will do.
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this, if the BanMan already dumps its banlist in its destructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will remove.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Does this rpc error change require a release note mention? If so, we should track this in an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't bother with docs because as far as I know, it's been impossible to receive this error in practice because g_connman always exists. It won't be until we have a -nop2p that it's relevant.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before about using nodeid rather than address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same response :)
Note that these comments are a bit stale. We used to track down the entry by looking through all node addresses, but now we use the id directly. I'll update those comments independently.
Also, see the behavior of disconnectSelectedNode above. I think it makes sense to be consistent with that?
For the sake of not over-complicating this, It may make sense to just keep the old behavior for this PR and switch to id in a follow-up.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consider adding a release-note to do for the rpc error change in this rpc call as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. These could be asserts for now, but imo we're less likely to forget about these if errors are hooked up in advance.
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to pass gArgs.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME) here? Or else I'm missing how the command line argument gets used after this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much so, thanks for catching that.
e335678 to
7a0452f
Compare
|
Addressed @sdaftuar's feedback. I went ahead and changed the Disconnect() in qt/rpcconsole back to using IP rather than nodeid to avoid adding unnecessary behavioral changes in a PR that should otherwise be a code refactor. |
|
Concept ACK, needs rebase. |
|
rebased. |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit net: Break disconnecting out of Ban(),
Missing call DisconnectNode() after:
bitcoin/src/net_processing.cpp
Line 2844 in 3bdf242
| connman->Ban(pnode->addr, BanReasonNodeMisbehaving); |
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit net: Break disconnecting out of Ban(),
Why bool if the return value is not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be consistent with the others.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit net: Break disconnecting out of Ban(),
Nit, add space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
This is handled by setting fDisconnect directly above. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behavior change when banning a remote IP in net_processing - we no longer disconnect any other connections from the same peer, only block new ones and disconnect the specific connection that made us ban them. Don't know that its a big deal, but might be nice to disconnect-by-ip there, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Disconnecting the single node seems more correct to me, but I'll revert to the current behavior here to avoid the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "net: Break disconnecting out of Ban()"
This is a behavior change
Seems to be fixed by the new change: #11457 (comment), but it would be clearer if commit message also said this commit does not change current behavior.
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it seems like our trend is to move things like this into the constructor/init logic for the subsystem/module itself instead of shoving everything in init. I rather liked that trend....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the schedule in this case is bitcoind specific. There's no reason for BanMan to know about it, and it's not exclusive to net. Throwing in an app-specific schedule would kinda defeat the purpose of breaking it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I mean the other annoying bit is that init.o is, by far, our largest compilation module. Any excuse to pull stuff out of init and put knowledge of a module in that module instead of init seems like the right direction to me. Also because we're telling the scheduler to schedule calling a function in that module based on a timer set in that module's header just seems...weird to me. If we want to ensure its easy to add unit tests later you can easily make the scheduler an optional arg and skip dumping if one isn't provided to the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "banman: create and split out banman"
Well the schedule in this case is bitcoind specific. There's no reason for BanMan to know about it, and it's not exclusive to net. Throwing in an app-specific schedule would kinda defeat the purpose of breaking it out.
I'm surprised the scheduler would be considered "bitcoind specific" / "app-specific" but BanMan would not be. How could that be true? On the surface, it seems reasonable for BanMan to use the scheduler since it relies on a scheduler to function, and would seem to simplify init.cpp and anything else using BanMan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryanofsky BanMan doesn't rely on a scheduler to function any more than the wallet does, that's a bitcoind thing. Banman just loads/unloads the bandb when it's told.
Imagine a small util to dump/edit the bandb, (which would be completely reasonable). The scheduler would just be a needless dependency.
@TheBlueMatt It's time to create an app context class (and .h/cpp) anyway, that holds these types of objects for the life of bitcoind. I figured one of us would get around to that once enough stuff had piled up in init.cpp :p .
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a dead store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will remove.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really worth checking? We already check for g_banman further up, are we really anticipating having a g_banman but not a g_connman?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I think it may be useful in the future to run with -p2p=0 in order to view/cleanup your bandb.
src/net.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cant say I really understand the desire to avoid the argparsing dep, when you include <util.h> either way. Seems like useless indirection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we can test independent of the cmdline args.
|
Addressed @TheBlueMatt's review and squashed. Diff from before (minus the rebase to master): diff --git a/src/net.cpp b/src/net.cpp
index 78c08b1..46e7783 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2125,4 +2125,2 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
- nStart = GetTimeMillis();
-
uiInterface.InitMessage(_("Starting network threads..."));
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 2981413..e8d731c 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2852,3 +2852,2 @@ bool PeerLogicValidation::SendRejectsAndCheckIfBanned(CNode* pnode)
else {
- pnode->fDisconnect = true;
if (pnode->addr.IsLocal())
@@ -2861,2 +2860,4 @@ bool PeerLogicValidation::SendRejectsAndCheckIfBanned(CNode* pnode)
}
+ // Disconnect all nodes with this address
+ connman->DisconnectNode(pnode->addr);
}
|
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit [banman: create and split out banman].
I feel like this should be checked outside the surrounding if (pnode->addr.IsLocal()) statement. Doesn't make sense to log "not banning local peer" if it wouldn't have been banned anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will fix.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit [banman: create and split out banman].
g_banman is guaranteed to exist given the check at the top of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will fix.
src/rpc/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit [banman: create and split out banman].
Perhaps pull the common DisconnectNode code out of this if/else statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One is a subnet, the other is an address. CSubNet is a subclass of CNetAddr, so we could potentially store a generic one, but imo duplicating the disconnect is more straightforward.
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 8c91ffe777ffcd2724f576490068abcbb95d60c0
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "net: Break disconnecting out of Ban()"
Maybe drop this C cast. It doesn't do anything and could cause bugs if class definitions change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
src/net.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "net: Break disconnecting out of Ban()"
This is a behavior change
Seems to be fixed by the new change: #11457 (comment), but it would be clearer if commit message also said this commit does not change current behavior.
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "net: Break disconnecting out of Ban()"
Is this a behavior change in the IsLocal case? It would be helpful if commit message clarified whether this is supposed be a pure refactoring or a behavior change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the behavior change would be, so I guess not :)
src/test/DoS_tests.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "tests: remove member connman/peerLogic in TestingSetup"
Could abbreviate auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
src/test/DoS_tests.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use std::make_unique.
It's not available in c++11, but we do have MakeUnique in src/util.h
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "banman: create and split out banman"
Well the schedule in this case is bitcoind specific. There's no reason for BanMan to know about it, and it's not exclusive to net. Throwing in an app-specific schedule would kinda defeat the purpose of breaking it out.
I'm surprised the scheduler would be considered "bitcoind specific" / "app-specific" but BanMan would not be. How could that be true? On the surface, it seems reasonable for BanMan to use the scheduler since it relies on a scheduler to function, and would seem to simplify init.cpp and anything else using BanMan.
|
Rebased with only trivial changes, with one exception: 2335579. As @TheBlueMatt and @ryanofsky pointed out, it wasn't clear if any behavioral changes were introduced in SendRejectsAndCheckIfBanned, and it turned out that the new code indeed did not match master's behavior exactly, as pointed out by rpc tests. That's now fixed and behavior should be exactly as before. |
|
utACK 0950d72 |
|
Did some light testing on macOS banning and unbanning unsuspecting testnet nodes. Didn't get in trouble. |
These are separate events which need to be carried out by separate subsystems. This also cleans up some whitespace and tabs in qt to avoid getting flagged by the linter. Current behavior is preserved.
Some say he has always been.
There's no need to hard-code the path here. Passing it in means that there are no ordering concerns wrt establishing the datadir.
Removes the dependency on arg parsing.
-BEGIN VERIFY SCRIPT- sed -i "s/clientInterface/m_client_interface/g" src/banman.h src/banman.cpp sed -i "s/setBannedIsDirty/m_is_dirty/g" src/banman.h src/banman.cpp sed -i "s/cs_setBanned/m_cs_banned/g" src/banman.h src/banman.cpp sed -i "s/setBanned/m_banned/g" src/banman.h src/banman.cpp -END VERIFY SCRIPT-
Also remove misleading comment. ClearBanned is used by rpc as well.
|
rebased. I just shoved g_banman into NodeImpl for now, but obviously we'll want it broken out as a next step. |
|
utACK 521ebf3 |
18185b5 scripted-diff: batch-recase BanMan variables (Carl Dong) c2e04d3 banman: Add, use CBanEntry ctor that takes ban reason (Carl Dong) 1ffa4ce banman: reformulate nBanUtil calculation (Carl Dong) daae598 banman: add thread annotations and mark members const where possible (Cory Fields) 84fc3fb scripted-diff: batch-rename BanMan members (Cory Fields) af3503d net: move BanMan to its own files (Cory Fields) d0469b2 banman: pass in default ban time as a parameter (Cory Fields) 2e56702 banman: pass the banfile path in (Cory Fields) 4c0d961 banman: create and split out banman (Cory Fields) 83c1ea2 net: split up addresses/ban dumps in preparation for moving them (Cory Fields) 136bd79 tests: remove member connman/peerLogic in TestingSetup (Cory Fields) 7cc2b9f net: Break disconnecting out of Ban() (Cory Fields) Pull request description: **Old English à la Beowulf** ``` Banman wæs bréme --blaéd wíde sprang-- Connmanes eafera Coreum in. aéglaéca léodum forstandan Swá bealdode bearn Connmanes guma gúðum cúð gódum daédum· dréah æfter dóme· nealles druncne slóg ``` **Modern English Translation** ``` Banman was famed --his renown spread wide-- Conman's hier, in Core-land. against the evil creature defend the people Thus he was bold, the son of Connman man famed in war, for good deeds; he led his life for glory, never, having drunk, slew ``` -- With @theuni's blessing, here is Banman, rebased. Original PR: #11457 -- Followup PRs: 1. Give `CNode` a `Disconnect` method ([source](#14605 (comment))) 2. Add a comment to `std::atomic_bool fDisconnect` in `net.h` that setting this to true will cause the node to be disconnected the next time `DisconnectNodes()` runs ([source](#14605 (comment))) Tree-SHA512: 9c207edbf577415c22c9811113e393322d936a843d4ff265186728152a67c057779ac4d4f27b895de9729f7a53e870f828b9ebc8bcdab757520c2aebe1e9be35
18185b5 scripted-diff: batch-recase BanMan variables (Carl Dong) c2e04d3 banman: Add, use CBanEntry ctor that takes ban reason (Carl Dong) 1ffa4ce banman: reformulate nBanUtil calculation (Carl Dong) daae598 banman: add thread annotations and mark members const where possible (Cory Fields) 84fc3fb scripted-diff: batch-rename BanMan members (Cory Fields) af3503d net: move BanMan to its own files (Cory Fields) d0469b2 banman: pass in default ban time as a parameter (Cory Fields) 2e56702 banman: pass the banfile path in (Cory Fields) 4c0d961 banman: create and split out banman (Cory Fields) 83c1ea2 net: split up addresses/ban dumps in preparation for moving them (Cory Fields) 136bd79 tests: remove member connman/peerLogic in TestingSetup (Cory Fields) 7cc2b9f net: Break disconnecting out of Ban() (Cory Fields) Pull request description: **Old English à la Beowulf** ``` Banman wæs bréme --blaéd wíde sprang-- Connmanes eafera Coreum in. aéglaéca léodum forstandan Swá bealdode bearn Connmanes guma gúðum cúð gódum daédum· dréah æfter dóme· nealles druncne slóg ``` **Modern English Translation** ``` Banman was famed --his renown spread wide-- Conman's hier, in Core-land. against the evil creature defend the people Thus he was bold, the son of Connman man famed in war, for good deeds; he led his life for glory, never, having drunk, slew ``` -- With @theuni's blessing, here is Banman, rebased. Original PR: bitcoin#11457 -- Followup PRs: 1. Give `CNode` a `Disconnect` method ([source](bitcoin#14605 (comment))) 2. Add a comment to `std::atomic_bool fDisconnect` in `net.h` that setting this to true will cause the node to be disconnected the next time `DisconnectNodes()` runs ([source](bitcoin#14605 (comment))) Tree-SHA512: 9c207edbf577415c22c9811113e393322d936a843d4ff265186728152a67c057779ac4d4f27b895de9729f7a53e870f828b9ebc8bcdab757520c2aebe1e9be35
BanMan is not a bad Man, he's just a different class of Man. He's an ex-ConnMan Man, looking to take a different path and make a new namespace for himself.
Beware BanMan's banhammer as he banishes bandits with the bandwidth to jam him. Not standing for non-canon, he’ll ban and he’ll ban. Some heroes wear capes, but BanMan? A Bandana.
--
Despite the diff size, this is mostly move-only. It breaks the ban/unban functions out of CConnman and into a new class because, while logically bans are tied to connections, they're really just entries in a database. Like CConnman, a global is still required due to RPC (and qt). I plan to address this along with CAddrMan, which I'll be breaking out next.
This also makes testing easier as different implementations can be dropped in.
There are a few small behavioral changes here, which are pretty insignificant: