ソースを参照

Chore: fix singbox & clash processPath, more TODO

SukkaW 1 年間 前
コミット
a3aec826f5
3 ファイル変更12 行追加4 行削除
  1. 1 2
      Build/lib/clash.ts
  2. 9 0
      Build/lib/create-file.ts
  3. 2 2
      Build/lib/singbox.ts

+ 1 - 2
Build/lib/clash.ts

@@ -30,8 +30,7 @@ const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => s
   'SRC-IP-CIDR': identity,
   'SRC-PORT': identity,
   'DST-PORT': identity,
-  'PROCESS-NAME': identity,
-  'PROCESS-PATH': identity,
+  'PROCESS-NAME': (_raw, _type, value) => ((value.includes('/') || value.includes('\\')) ? `PROCESS-PATH,${value}` : `PROCESS-NAME,${value}`),
   'DEST-PORT': (_raw, _type, value) => `DST-PORT,${value}`,
   'IN-PORT': (_raw, _type, value) => `SRC-PORT,${value}`,
   'URL-REGEX': unsupported,

+ 9 - 0
Build/lib/create-file.ts

@@ -31,6 +31,7 @@ const sortTypeOrder: Record<string | typeof defaultSortTypeOrder, number> = {
   'URL-REGEX': 100,
   AND: 300,
   OR: 300,
+  GEOIP: 400,
   'IP-CIDR': 400,
   'IP-CIDR6': 400
 };
@@ -43,6 +44,14 @@ abstract class RuleOutput {
   protected ipcidrNoResolve = new Set<string>();
   protected ipcidr6 = new Set<string>();
   protected ipcidr6NoResolve = new Set<string>();
+  // TODO: add sourceIpcidr
+  // TODO: add sourcePort
+  // TODO: add port
+  // TODO: processName
+  // TODO: processPath
+  // TODO: userAgent
+  // TODO: urlRegex
+
   protected otherRules: Array<[raw: string, orderWeight: number]> = [];
   protected abstract type: 'domainset' | 'non_ip' | 'ip';
 

+ 2 - 2
Build/lib/singbox.ts

@@ -34,8 +34,8 @@ const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => [
   'SRC-IP-CIDR': (_1, _2, value) => ['source_ip_cidr', value.endsWith(',no-resolve') ? value.slice(0, -11) : value],
   'SRC-PORT': (_1, _2, value) => toNumberTuple('source_port', value),
   'DST-PORT': (_1, _2, value) => toNumberTuple('port', value),
-  'PROCESS-NAME': (_1, _2, value) => ['process_name', value],
-  'PROCESS-PATH': (_1, _2, value) => ['process_path', value],
+  'PROCESS-NAME': (_1, _2, value) => ((value.includes('/') || value.includes('\\')) ? ['process_path', value] : ['process_name', value]),
+  // 'PROCESS-PATH': (_1, _2, value) => ['process_path', value],
   'DEST-PORT': (_1, _2, value) => toNumberTuple('port', value),
   'IN-PORT': (_1, _2, value) => toNumberTuple('source_port', value),
   'URL-REGEX': unsupported,