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

This commit is contained in:
SukkaW 2024-05-08 02:00:50 +08:00
parent 804e14facb
commit c8645a2713
2 changed files with 31 additions and 13 deletions

View File

@ -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 res = await getDomesticDomainsRulesetPromise();
const peeked = Bun.peek(promise);
const res: string[] = peeked === promise
? await promise
: (peeked as string[]);
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')
) )

View File

@ -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',