Open PluieM opened 1 week ago
The updates encompass significant enhancements focused on peer banning based on configurable rules, utilizing state machines for more robust ban management. New modules and refactors streamline the configuration and execution of these rules. Key additions include a disconnect timeout feature, an updated and centralized rule system, and expanded capabilities for handling peer interactions through new classes and methods.
File(s) | Summary |
---|---|
pom.xml |
Added cola-component-statemachine dependency. |
PeerBanHelperServer.java |
Added disconnectTimeout , overhauled peer banning with state machine logic, enhanced banning logic and modular registration. |
ProfileUpdateScript.java |
Added subModuleUpdate() method for module rule configurations. Adjusted existing methods for configuration updates. |
DatabaseHelper.java , RuleSubLog.java |
Renamed IPBanRuleUpdateType to RuleUpdateType , affecting method and record parameters. |
AbstractRuleBlocker.java , MatchEvents.java , ... |
Introduced foundational classes and enums (RuleBlocker interface, AbstractRuleBlocker class, new enum s) for rule-based blocking. |
PeerIdBlocker.java , RuleSubBlocker.java , ... |
Implemented rule-based peer blocking mechanisms (PeerIdBlocker , RuleSubBlocker ). Refactored methods for rule matching logic. |
RuleSubController.java |
Adjusted method signatures and logic to incorporate renamed entities and new rule types. |
Lang.java |
Renamed constants related to rule actions, added new constants for subscription rule handling. |
RuleMatcher.java , PrefixMatcher.java , ... |
Introduced abstract and specific matcher classes (RuleMatcher , PrefixMatcher , SubStrMatcher ), handling rule-based evaluations. |
sequenceDiagram
participant Peer as Peer
participant Server as PeerBanHelperServer
participant Matcher as RuleMatcher
participant State as StateMachine<PeerState, MatchEvents, PeerMatchContext>
Peer ->> Server: Connect
Server ->> Matcher: Evaluate Peer
alt Rule Match
Matcher ->> State: Trigger HIT Event
State ->> Server: Update Peer Status (Ban/Active)
else No Match
Matcher ->> State: Trigger PASS Event
end
Note over Server, Peer: Peer Status Updated based on State
activate Server
loop Periodically
Server ->> Peer: Check Connection Status
alt Timeout
Server ->> State: Trigger TIMEOUT Event
State ->> Server: Disconnect Peer
else Active
Server ->> State: Trigger ACTIVE Event
State ->> Server: Maintain Connection
end
end
deactivate Server
🐇✨ In the code where peer flags toss, New rules and states cross, Disconnects timed, bans refine,
Peers in line, a stricter sign, Matchers check, state machines bind, Configuration perfect, intertwined.
From fortress code the rabbits cheer, Rules are clear, no peer shall veer! With carrots shared, and code so fair. 🌟💻
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
使用简单状态机托管Peer状态切换
在一次轮询中每个Peer最多只会被Ban一次
RuleBlocker为状态机的接口定义
Summary by CodeRabbit
New Features
Refactor
IPBanRuleUpdateType
toRuleUpdateType
.IPBanMatcher
toIPMatcher
, with significant changes in logic and method signatures.Enhancements
PrefixMatcher
andSubStrMatcher
.New Classes/Enums
AbstractRuleBlocker
,MatchEvents
,MatchResultDetail
,PeerMatchContext
,PeerMatchRecord
,PeerState
,RuleBlocker
,RuleMatcher
,RuleType
,PrefixMatcher
, andSubStrMatcher
.Bug Fixes