Browse Source

Feat: enable merge for IP rules

SukkaW 1 year ago
parent
commit
7acda2b5a4
1 changed files with 3 additions and 1 deletions
  1. 3 1
      Build/lib/rules/ip.ts

+ 3 - 1
Build/lib/rules/ip.ts

@@ -3,6 +3,8 @@ import { appendArrayFromSet } from '../misc';
 import type { SingboxSourceFormat } from '../singbox';
 import type { SingboxSourceFormat } from '../singbox';
 import { RuleOutput } from './base';
 import { RuleOutput } from './base';
 
 
+import { merge } from 'fast-cidr-tools';
+
 export class IPListOutput extends RuleOutput {
 export class IPListOutput extends RuleOutput {
   protected type = 'ip' as const;
   protected type = 'ip' as const;
 
 
@@ -13,7 +15,7 @@ export class IPListOutput extends RuleOutput {
   private $merged: string[] | null = null;
   private $merged: string[] | null = null;
   get merged() {
   get merged() {
     if (!this.$merged) {
     if (!this.$merged) {
-      this.$merged = appendArrayFromSet(appendArrayFromSet([], this.ipcidr), this.ipcidr6);
+      this.$merged = merge(appendArrayFromSet([], [this.ipcidr, this.ipcidr6]));
     }
     }
     return this.$merged;
     return this.$merged;
   }
   }