22 lines
1.0 KiB
TypeScript
22 lines
1.0 KiB
TypeScript
import { IpUtils } from '../../../ts/core/utils/ip-utils.js';
|
|
|
|
// Test the overlap case
|
|
const result = IpUtils.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:', IpUtils.isGlobIPMatch(ip, blockedIPs));
|
|
console.log('Step 2 check (is blocked):', (blockedIPs.length > 0 && IpUtils.isGlobIPMatch(ip, blockedIPs)));
|
|
|
|
// Check if IP is allowed
|
|
console.log('allowedIPs length === 0:', allowedIPs.length === 0);
|
|
console.log('isGlobIPMatch for allowed:', IpUtils.isGlobIPMatch(ip, allowedIPs));
|
|
console.log('Step 3 (is allowed):', allowedIPs.length === 0 || IpUtils.isGlobIPMatch(ip, allowedIPs)); |