From 92c8bf0e6549261c0da07feae6fa9d7ad5912725 Mon Sep 17 00:00:00 2001 From: Virgil Clyne Date: Mon, 21 Oct 2024 12:33:57 +0800 Subject: [PATCH] feat: rule type Update rule.ts --- .../modkit/shared/src/types/source/rule.ts | 76 ++++++++++--------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/packages/modkit/shared/src/types/source/rule.ts b/packages/modkit/shared/src/types/source/rule.ts index 689c575..a5014fa 100644 --- a/packages/modkit/shared/src/types/source/rule.ts +++ b/packages/modkit/shared/src/types/source/rule.ts @@ -1,30 +1,43 @@ +export type RuleType = + | 'DOMAIN' + | 'DOMAIN-SUFFIX' + | 'DOMAIN-KEYWORD' + | 'DOMAIN-SET' + | 'IP-CIDR' + | 'IP-CIDR6' + | 'GEOIP' + | 'IP-ASN' + | 'USER-AGENT' + | 'URL-REGEX' + | 'PROCESS-NAME' + | 'AND' + | 'OR' + | 'NOT' + | 'SUBNET' + | 'DEST-PORT' + | 'IN-PORT' + | 'SRC-PORT' + | 'SRC-IP' + | 'PROTOCOL' + | 'SCRIPT' + | 'CELLULAR-RADIO' + | 'DEVICE-NAME' + | 'RULE-SET' + | 'FINAL'; + +export type policyNameType = + | 'DIRECT' + | 'REJECT' + | 'REJECT-NO-DROP' + | 'REJECT-TINYGIF' + | 'CELLULAR' + | 'CELLULAR-ONLY' + | 'HYBRID' + | 'NO-HYBRID' + | string; + export interface Rule { - type: - | 'DOMAIN' - | 'DOMAIN-SUFFIX' - | 'DOMAIN-KEYWORD' - | 'DOMAIN-SET' - | 'IP-CIDR' - | 'IP-CIDR6' - | 'GEOIP' - | 'IP-ASN' - | 'USER-AGENT' - | 'URL-REGEX' - | 'PROCESS-NAME' - | 'AND' - | 'OR' - | 'NOT' - | 'SUBNET' - | 'DEST-PORT' - | 'IN-PORT' - | 'SRC-PORT' - | 'SRC-IP' - | 'PROTOCOL' - | 'SCRIPT' - | 'CELLULAR-RADIO' - | 'DEVICE-NAME' - | 'RULE-SET' - | 'FINAL'; + type: RuleType; content?: string; /** * 对应 `source.assets` 中的 key @@ -33,16 +46,7 @@ export interface Rule { /** * 策略名 */ - policyName?: - | 'DIRECT' - | 'REJECT' - | 'REJECT-NO-DROP' - | 'REJECT-TINYGIF' - | 'CELLULAR' - | 'CELLULAR-ONLY' - | 'HYBRID' - | 'NO-HYBRID' - | string; + policyName?: policyNameType; /** * 描述 */