feat(wire): add subnet/CIDR support to BanMan#899
Draft
Micah-Shallom wants to merge 2 commits intogetfloresta:masterfrom
Draft
feat(wire): add subnet/CIDR support to BanMan#899Micah-Shallom wants to merge 2 commits intogetfloresta:masterfrom
Micah-Shallom wants to merge 2 commits intogetfloresta:masterfrom
Conversation
Introduce a BanMan struct that centralizes IP ban tracking, replacing the scattered ban logic across AddressMan and peer_man. - Add BanMan with add_ban() and is_banned() methods - Wire BanMan into NodeCommon alongside AddressMan - Check banned status before creating new connections - Register bans in both disconnect_and_ban() and increase_banscore() - Add PeerBanned variant to WireError Closes getfloresta#820 (partial — single-IP banning only)
Add BanSubnet struct with bitwise mask matching so BanMan can ban entire subnets (e.g. 192.168.1.0/24) instead of only single IPs. Single-IP bans are represented as /32 (IPv4) or /128 (IPv6). Closes getfloresta#820 (subnet support)
3 tasks
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
BanSubnetto support banning entire subnets (e.g.192.168.1.0/24) instead of only single IPs. Uses bitwise mask matching, same approach as Bitcoin Core'sCSubNet::Match.BanSubnetholds anIpAddr+ prefix length, withcontains(ip)for matchingBanMankeyed byBanSubnetinstead ofIpAddr;is_banned()does linear scan over all entries/32or/128subnetspeer_man.rswrapped withBanSubnet::from_ip()Follow-up to #892 as discussed — showing the direction for subnet banning.
Test plan
test_subnet_ban_covers_all_ips_in_range— bans /24, checks IPs inside and outside