Feat: Surge DOMAIN-WILDCARD -> Clash DOMAIN-REGEX

This commit is contained in:
SukkaW
2024-08-13 02:01:15 +08:00
parent 5bceb6cac7
commit f35958208f
6 changed files with 35 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import picocolors from 'picocolors';
import { domainWildCardToRegex } from './misc';
const identity = <T>(x: T): T => x;
const unsupported = Symbol('unsupported');
@@ -8,6 +9,7 @@ const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => s
DOMAIN: identity,
'DOMAIN-SUFFIX': identity,
'DOMAIN-KEYWORD': identity,
'DOMAIN-WILDCARD': (_raw, _type, value) => `DOMAIN-REGEX,${domainWildCardToRegex(value)}`,
GEOIP: identity,
'IP-CIDR': identity,
'IP-CIDR6': identity,
@@ -17,8 +19,8 @@ const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => s
'DST-PORT': identity,
'PROCESS-NAME': identity,
'PROCESS-PATH': identity,
'DEST-PORT': (_raw, type, value) => `DST-PORT,${value}`,
'IN-PORT': (_raw, type, value) => `SRC-PORT,${value}`,
'DEST-PORT': (_raw, _type, value) => `DST-PORT,${value}`,
'IN-PORT': (_raw, _type, value) => `SRC-PORT,${value}`,
'URL-REGEX': unsupported,
'USER-AGENT': unsupported
};