ソースを参照

Feat: make DoH supports multiple IP (w/ Hosts)

SukkaW 1 年間 前
コミット
c8645a2713
2 ファイル変更31 行追加13 行削除
  1. 9 7
      Build/build-domestic-ruleset.ts
  2. 22 6
      Source/non_ip/domestic.ts

+ 9 - 7
Build/build-domestic-ruleset.ts

@@ -27,11 +27,7 @@ export const buildDomesticRuleset = task(import.meta.path, async (span) => {
     'This file contains known addresses that are avaliable in the Mainland China.'
     'This file contains known addresses that are avaliable in the Mainland China.'
   ];
   ];
 
 
-  const promise = getDomesticDomainsRulesetPromise();
-  const peeked = Bun.peek(promise);
-  const res: string[] = peeked === promise
-    ? await promise
-    : (peeked as string[]);
+  const res = await getDomesticDomainsRulesetPromise();
 
 
   return Promise.all([
   return Promise.all([
     createRuleset(
     createRuleset(
@@ -53,11 +49,17 @@ export const buildDomesticRuleset = task(import.meta.path, async (span) => {
         '[Host]',
         '[Host]',
         ...Object.entries(DOMESTICS)
         ...Object.entries(DOMESTICS)
           .flatMap(
           .flatMap(
-            ([, { domains, dns }]) => domains.flatMap((domain) => [
+            ([, { domains, dns, ...rest }]) => [
+              ...(
+                'hosts' in rest
+                  ? Object.entries(rest.hosts).flatMap(([dns, ips]: [dns: string, ips: string[]]) => `${dns} = ${ips.join(', ')}`)
+                  : []
+              ),
+              ...domains.flatMap((domain) => [
               `${domain} = server:${dns}`,
               `${domain} = server:${dns}`,
               `*.${domain} = server:${dns}`
               `*.${domain} = server:${dns}`
             ])
             ])
-          )
+      ])
       ],
       ],
       path.resolve(import.meta.dir, '../Modules/sukka_local_dns_mapping.sgmodule')
       path.resolve(import.meta.dir, '../Modules/sukka_local_dns_mapping.sgmodule')
     )
     )

+ 22 - 6
Source/non_ip/domestic.ts

@@ -1,7 +1,10 @@
 // @ts-check
 // @ts-check
 export const DOMESTICS = {
 export const DOMESTICS = {
   ALIBABA: {
   ALIBABA: {
-    dns: 'quic://223.6.6.6:853',
+    hosts: {
+      'dns.alidns.com': ['223.5.5.5', '223.6.6.6', '2400:3200:baba::1', '2400:3200::1'],
+    },
+    dns: 'quic://dns.alidns.com:853',
     domains: [
     domains: [
       'uc.cn',
       'uc.cn',
       'ucweb.com',
       'ucweb.com',
@@ -77,7 +80,12 @@ export const DOMESTICS = {
     ]
     ]
   },
   },
   TENCENT: {
   TENCENT: {
-    dns: 'https://120.53.53.53/dns-query',
+    hosts: {
+      'dot.pub': ['120.53.53.53', '1.12.12.12'],
+      'doh.pub': ['120.53.53.53', '1.12.12.12'],
+      'dns.pub': ['162.14.21.178', '162.14.21.56']
+    },
+    dns: 'https://doh.pub/dns-query',
     domains: [
     domains: [
       'dns.pub',
       'dns.pub',
       'doh.pub',
       'doh.pub',
@@ -131,7 +139,7 @@ export const DOMESTICS = {
     ]
     ]
   },
   },
   BILIBILI_ALI: {
   BILIBILI_ALI: {
-    dns: 'quic://223.5.5.5:853',
+    dns: 'quic://dns.alidns.com:853',
     domains: [
     domains: [
       'upos-sz-mirrorali.bilivideo.com'
       'upos-sz-mirrorali.bilivideo.com'
     ]
     ]
@@ -143,7 +151,7 @@ export const DOMESTICS = {
     ]
     ]
   },
   },
   BILIBILI: {
   BILIBILI: {
-    dns: 'https://120.53.53.53/dns-query',
+    dns: 'https://doh.pub/dns-query',
     domains: [
     domains: [
       'upos-sz-mirrorcoso1.bilivideo.com',
       'upos-sz-mirrorcoso1.bilivideo.com',
       'acg.tv',
       'acg.tv',
@@ -169,7 +177,7 @@ export const DOMESTICS = {
     ]
     ]
   },
   },
   XIAOMI: {
   XIAOMI: {
-    dns: 'https://120.53.53.53/dns-query',
+    dns: 'https://doh.pub/dns-query',
     domains: [
     domains: [
       'mi.com',
       'mi.com',
       'duokan.com',
       'duokan.com',
@@ -249,7 +257,15 @@ export const DOMESTICS = {
     ]
     ]
   },
   },
   QIHOO360: {
   QIHOO360: {
-    dns: 'https://101.198.198.198/dns-query',
+    hosts: {
+      'doh.360.cn': ['101.198.198.198', '101.198.199.200'],
+      'dot.360.cn': ['101.198.198.198', '101.198.199.200'],
+      'dns.360.cn': ['101.198.198.198', '101.198.199.200'],
+      'doh.360.net': ['101.198.198.198', '101.198.199.200'],
+      'dot.360.net': ['101.198.198.198', '101.198.199.200'],
+      'dns.360.net': ['101.198.198.198', '101.198.199.200']
+    },
+    dns: 'https://dns.360.net/dns-query',
     domains: [
     domains: [
       'qhimg.com',
       'qhimg.com',
       'qhimgs0.com',
       'qhimgs0.com',