fix: kill NetworkManager's dnsmasq before starting our own
NetworkManager auto-starts its own dnsmasq when creating a hotspot, which conflicts with our DNS-hijacking dnsmasq on the same interface. Now kill ALL dnsmasq instances before starting ours. Made-with: Cursor
This commit is contained in:
@@ -61,8 +61,10 @@ class DnsHijack {
|
||||
fs.writeFileSync(DNSMASQ_CONF, conf, 'utf8');
|
||||
log.info('dns', `dnsmasq 配置已写入: ${DNSMASQ_CONF}`);
|
||||
|
||||
// 终止系统可能残留的 dnsmasq
|
||||
try { execSync('pkill -f "dnsmasq.*clawd"', { timeout: 3000 }); } catch (_) {}
|
||||
// 终止所有 dnsmasq(包括 NetworkManager 自动启动的)
|
||||
try { execSync('pkill -9 dnsmasq', { timeout: 3000 }); } catch (_) {}
|
||||
// 等待端口释放
|
||||
try { execSync('sleep 1'); } catch (_) {}
|
||||
|
||||
// 查找 dnsmasq 二进制(/usr/sbin 可能不在普通用户 PATH 中)
|
||||
const dnsmasqBin = findBin('dnsmasq');
|
||||
@@ -90,7 +92,7 @@ class DnsHijack {
|
||||
this._watchdog.stop();
|
||||
this._watchdog = null;
|
||||
}
|
||||
try { execSync('pkill -f "dnsmasq.*clawd"', { timeout: 3000 }); } catch (_) {}
|
||||
try { execSync('pkill -9 dnsmasq', { timeout: 3000 }); } catch (_) {}
|
||||
try { fs.unlinkSync(DNSMASQ_CONF); } catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user