浏览代码

Chore: minor changes AdGuardHome Mapping

SukkaW 1 年之前
父节点
当前提交
cba19c462e
共有 2 个文件被更改,包括 30 次插入13 次删除
  1. 21 13
      Build/build-domestic-direct-lan-ruleset-dns-mapping-module.ts
  2. 9 0
      Source/non_ip/domestic.ts

+ 21 - 13
Build/build-domestic-direct-lan-ruleset-dns-mapping-module.ts

@@ -1,6 +1,6 @@
 // @ts-check
 import path from 'node:path';
-import { DOMESTICS, DOH_BOOTSTRAP } from '../Source/non_ip/domestic';
+import { DOMESTICS, DOH_BOOTSTRAP, AdGuardHomeDNSMapping } from '../Source/non_ip/domestic';
 import { DIRECTS, LAN } from '../Source/non_ip/direct';
 import type { DNSMapping } from '../Source/non_ip/direct';
 import { readFileIntoProcessedArray } from './lib/fetch-text-by-line';
@@ -186,20 +186,28 @@ export const buildDomesticRuleset = task(require.main === module, __filename)(as
       span,
       [
         '# Local DNS Mapping for AdGuard Home',
-        '',
+        'tls://1.12.12.12',
+        'tls://120.53.53.53',
+        'https://1.12.12.12/dns-query',
+        'https://120.53.53.53/dns-query',
         '[//]udp://10.10.1.1:53',
-        ...dataset.flatMap(({ domains, dns: _dns }) => domains.flatMap((domain) => {
-          const dns = _dns === 'system'
-            ? 'udp://10.10.1.1:53'
-            : _dns;
-          if (
-            // AdGuard Home has built-in AS112 / private PTR handling
-            domain.endsWith('.arpa')
-            // Ignore simple hostname
-            || !domain.includes('.')
-          ) {
-            return [];
+        ...(([DOMESTICS, DIRECTS, LAN] as const).flatMap(Object.values) as DNSMapping[]).flatMap(({ domains, dns: _dns }) => domains.flatMap((domain) => {
+          let dns;
+          if (_dns in AdGuardHomeDNSMapping) {
+            dns = AdGuardHomeDNSMapping[_dns as keyof typeof AdGuardHomeDNSMapping].join(' ');
+          } else {
+            console.warn(`Unknown DNS "${_dns}" not in AdGuardHomeDNSMapping`);
+            dns = _dns;
           }
+
+          // if (
+          //   // AdGuard Home has built-in AS112 / private PTR handling
+          //   domain.endsWith('.arpa')
+          //   // Ignore simple hostname
+          //   || !domain.includes('.')
+          // ) {
+          //   return [];
+          // }
           if (domain[0] === '$') {
             return [
               `[/${domain.slice(1)}/]${dns}`

+ 9 - 0
Source/non_ip/domestic.ts

@@ -392,3 +392,12 @@ export const DOH_BOOTSTRAP: Record<string, DNSMapping> = {
     ]
   }
 };
+
+export const AdGuardHomeDNSMapping = {
+  system: ['udp://10.10.1.1:53'],
+  'https://doh.pub/dns-query': ['tls://1.12.12.12', 'tls://120.53.53.53', 'https://1.12.12.12/dns-query', 'https://120.53.53.53/dns-query'],
+  'quic://dns.alidns.com:853': ['quic://223.5.5.5', 'quic://223.6.6.6', 'h3://223.5.5.5/dns-query', 'h3://223.6.6.6/dns-query'],
+  'https://doh.360.cn/dns-query': ['https://doh.360.cn/dns-query', 'tls://dot.360.cn'],
+  '180.76.76.76': ['udp://180.76.76.76'],
+  '180.184.2.2': ['udp://180.184.2.2', 'udp://180.184.1.1']
+};