Skip to content

Commit 800b16a

Browse files
committed
Fix: opt-in Surge DNS's special handling for .local
1 parent 7f261b8 commit 800b16a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ export const buildDomesticRuleset = task(require.main === module, __filename)(as
233233
const ruleset_name = cur[0].toLowerCase();
234234
const mihomo_ruleset_id = `mihomo_nameserver_policy_${ruleset_name}`;
235235

236-
acc.dns['nameserver-policy'][`rule-set:${mihomo_ruleset_id}`] = dns;
236+
if (dns) {
237+
acc.dns['nameserver-policy'][`rule-set:${mihomo_ruleset_id}`] = dns;
238+
}
237239

238240
acc['rule-providers'][mihomo_ruleset_id] = {
239241
type: 'http',
@@ -257,7 +259,9 @@ export const buildDomesticRuleset = task(require.main === module, __filename)(as
257259
break;
258260
}
259261

260-
acc.dns['nameserver-policy'][domain] = dns;
262+
if (dns) {
263+
acc.dns['nameserver-policy'][domain] = dns;
264+
}
261265
});
262266
}
263267

@@ -297,6 +301,10 @@ export const buildDomesticRuleset = task(require.main === module, __filename)(as
297301
'https://doh.pub/dns-query',
298302
'[//]udp://10.10.1.1:53',
299303
...(([DOMESTICS, DIRECTS, LAN, HOSTS] as const).flatMap(Object.values) as DNSMapping[]).flatMap(({ domains, dns: _dns }) => domains.flatMap((domain) => {
304+
if (!_dns) {
305+
return [];
306+
}
307+
300308
let dns;
301309
if (_dns in AdGuardHomeDNSMapping) {
302310
dns = AdGuardHomeDNSMapping[_dns as keyof typeof AdGuardHomeDNSMapping].join(' ');

Source/non_ip/direct.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface DNSMapping {
66
realip: boolean,
77
/** should convert to ruleset */
88
ruleset: boolean,
9-
dns: string,
9+
dns: string | null,
1010
/**
1111
* domain[0]
1212
*
@@ -47,6 +47,18 @@ export const DIRECTS = {
4747
} as const satisfies Record<string, DNSMapping>;
4848

4949
export const LAN = {
50+
// By default, all hostnames with the suffix '.local' will be resolved by the system.
51+
// Some app like OrbStack uses mDNS and this TLD (orb.local) via mDNS.
52+
// Surge already handles .local with mDNS properly, we should not map to server:system
53+
LOCAL_SPECIAL: {
54+
dns: null,
55+
hosts: {},
56+
realip: false,
57+
ruleset: false,
58+
domains: [
59+
'+local'
60+
]
61+
},
5062
LAN_WITHOUT_REAL_IP: {
5163
dns: 'system',
5264
hosts: {
@@ -139,7 +151,10 @@ export const LAN = {
139151
ruleset: true,
140152
domains: [
141153
'+lan',
142-
'+local',
154+
// By default, all hostnames with the suffix '.local' will be resolved by the system.
155+
// Some app like OrbStack uses mDNS and this TLD (orb.local) via mDNS.
156+
// Surge already handles .local with mDNS properly, we should not map to server:system
157+
// '+local',
143158
'+internal',
144159
// 'amplifi.lan',
145160
// '$localhost',

0 commit comments

Comments
 (0)