Skip to content

Commit

Permalink
Chore: minor changes AdGuardHome Mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Dec 19, 2024
1 parent 412ac53 commit cba19c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Build/build-domestic-direct-lan-ruleset-dns-mapping-module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`
Expand Down
9 changes: 9 additions & 0 deletions Source/non_ip/domestic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
};

0 comments on commit cba19c4

Please sign in to comment.