-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add setban/listbanned RPC commands #6158
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
Conversation
9792d11 to
ab10e9d
Compare
|
I'm open to alternatives (naming) for |
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 was/is this returning a bool, if it seems to be only true?
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.
Right. I didn't want to change this in this PR and i kept it for legacy reasons and to lower the risk of breaking something.
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.
Understood, but IMHO a function that doesn't need it could just be void. Perhaps you can just add a commit for that at the end? At least it could be changed for GetBanned as you just added it :).
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.
Agreed. Added a commit on top.
f2a123b to
8339b26
Compare
|
Added a |
83cd720 to
9f1394b
Compare
|
Concept ACK, did not test or review code yet, this will be after 0.11 release |
|
Great; I had an old bitrotted version of this and had implemented almost exactly the same interface. One thing this can't accomplish though is banning netgroups. (thats actually what held up my code: I found issues with out netgroup parser that broke my tests) |
|
In light of what gmaxwell said, perhaps allowing for -- setban 12. * .12.12 or setban 50.50.50. * would make sense as well. To allow for banning of entire octets. |
|
@LeMiner Good idea, but I'd say the interface should use |
|
Agreed with @laanwj. |
|
Yep, agreed as well. |
|
|
14a37e8 to
1a7ec8a
Compare
|
Extended this PR to allow subnet banning/unbanning. |
12d6265 to
2eff5b8
Compare
|
ut ACK |
|
Needs rebase. |
d416fe3 to
83b0cc6
Compare
|
Rebased and added the possibility of setting an absolute bantime with |
src/netbase.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 this should be:
return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0));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 catch! Thanks for the review.
Fixed.
83b0cc6 to
bb69fd8
Compare
46d242a to
10da816
Compare
|
Rebased and added also tests for the new |
f04a3ac to
9d79afe
Compare
9d79afe add RPC tests for setban & disconnectnode (Jonas Schnelli) 1f02b80 setban: add RPCErrorCode (Jonas Schnelli) d624167 fix CSubNet comparison operator (Jonas Schnelli) 4e36e9b setban: rewrite to UniValue, allow absolute bantime (Jonas Schnelli) 3de24d7 rename json field "bannedtill" to "banned_until" (Jonas Schnelli) 433fb1a [RPC] extend setban to allow subnets (Jonas Schnelli) e8b9347 [net] remove unused return type bool from CNode::Ban() (Jonas Schnelli) 1086ffb [QA] add setban/listbanned/clearbanned tests (Jonas Schnelli) d930b26 [RPC] add setban/listbanned/clearbanned RPC commands (Jonas Schnelli) 2252fb9 [net] extend core functionallity for ban/unban/listban (Jonas Schnelli)
|
Thanks for the merge. I now try to extend this to the UI peers window. |
Bitcoin 0.12 RPC PRs 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6266 - bitcoin/bitcoin#6257 - bitcoin/bitcoin#6271 - bitcoin/bitcoin#6158 - bitcoin/bitcoin#6307 - bitcoin/bitcoin#6290 - bitcoin/bitcoin#6262 - bitcoin/bitcoin#6088 - bitcoin/bitcoin#6339 - bitcoin/bitcoin#6299 (partial, remainder in #2099) - bitcoin/bitcoin#6350 - bitcoin/bitcoin#6247 - bitcoin/bitcoin#6362 - bitcoin/bitcoin#5486 - bitcoin/bitcoin#6417 - bitcoin/bitcoin#6398 (partial, remainder was included in #1950) - bitcoin/bitcoin#6444 - bitcoin/bitcoin#6456 (partial, remainder was included in #2082) - bitcoin/bitcoin#6380 - bitcoin/bitcoin#6970 Part of #2074.
Groundwork for #5866.
If this makes it into master i'd like to add a GUI context menu for the peers table.
A simple disconnect (without banning) would be possible with
setban <ip> add 1(where 1 is the bantime).At the moment the banned set does not survive a restart (should be added once).
Also currently banning is per IP and not per Node which results in disconnecting all nodes of a given IP (if the nodes uses the same ip but different ports).
Also includes some whitespace fixes for
httpbasics.pytest.