import { IpMatcher } from '../../../ts/core/routing/matchers/ip.js'; const isGlobIPMatch = (ip: string, patterns: string[]): boolean => patterns.some((pattern) => IpMatcher.match(pattern, ip)); const isIPAuthorized = (ip: string, allowedIPs: string[], blockedIPs: string[]): boolean => IpMatcher.isAuthorized(ip, allowedIPs, blockedIPs); // Test the overlap case const result = isIPAuthorized('127.0.0.1', ['127.0.0.1'], ['127.0.0.1']); console.log('Result of IP that is both allowed and blocked:', result); // Trace through the code logic const ip = '127.0.0.1'; const allowedIPs = ['127.0.0.1']; const blockedIPs = ['127.0.0.1']; console.log('Step 1 check:', (!ip || (allowedIPs.length === 0 && blockedIPs.length === 0))); // Check if IP is blocked - blocked IPs take precedence console.log('blockedIPs length > 0:', blockedIPs.length > 0); console.log('isGlobIPMatch result:', isGlobIPMatch(ip, blockedIPs)); console.log('Step 2 check (is blocked):', (blockedIPs.length > 0 && isGlobIPMatch(ip, blockedIPs))); // Check if IP is allowed console.log('allowedIPs length === 0:', allowedIPs.length === 0); console.log('isGlobIPMatch for allowed:', isGlobIPMatch(ip, allowedIPs)); console.log('Step 3 (is allowed):', allowedIPs.length === 0 || isGlobIPMatch(ip, allowedIPs));