Fix CloudMounter

This commit is contained in:
SukkaW
2024-08-13 23:30:28 +08:00
parent e81d718a35
commit 64552966dd
3 changed files with 34 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import picocolors from 'picocolors';
import { domainWildCardToRegex } from './misc';
import { isProbablyIpv4, isProbablyIpv6 } from './is-fast-ip';
const identity = <T>(x: T): T => x;
const unsupported = Symbol('unsupported');
@@ -14,6 +15,18 @@ const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => s
'IP-CIDR': identity,
'IP-CIDR6': identity,
'IP-ASN': identity,
'SRC-IP': (_raw, _type, value) => {
if (value.includes('/')) {
return `SRC-IP-CIDR,${value}`;
}
if (isProbablyIpv4(value)) {
return `SRC-IP-CIDR,${value}/32`;
}
if (isProbablyIpv6(value)) {
return `SRC-IP-CIDR6,${value}/128`;
}
return '';
},
'SRC-IP-CIDR': identity,
'SRC-PORT': identity,
'DST-PORT': identity,