0fec5f1081
Bug: Threshold calculation used undefined 'hits' variable. Code tried to use lifetime_hits at line 2622, but hits wasn't loaded until line 2652. Result: Adaptive threshold never actually worked - always used default threshold. Fix: Load IP data (score|hits|bot_type|attacks|ban_count|rep_score) from persistent ip_data file BEFORE calculating threshold, so we have accurate lifetime hit count. Now the flow is: 1. Load persistent IP data from ip_data (includes current lifetime hits) 2. Calculate threshold based on CURRENT lifetime hits 3. Check if count > threshold 4. If yes, increment hits and process 5. Write back to ip_data with incremented hits Example: IP with 5 detections in 3 minutes - Detection 1: hits=1, threshold=3, needs 3+ connections - Detection 2: hits=2, threshold=2, needs 2+ connections - Detection 3: hits=3, threshold=2, needs 2+ connections - Detection 4: hits=4, threshold=2, needs 2+ connections - Detection 5: hits=5, threshold=1, needs 1+ connection ✓ If IP has 2+ connections on each scan, detected on scans 2-5+. If IP has 1+ connection on each scan, detected on scan 5+ (or earlier if more connections). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>