fix: stop killing NM's dnsmasq - use dnsmasq-shared.d instead

Killing all dnsmasq processes caused NetworkManager to detect its
hotspot dnsmasq died and tear down the hotspot (AP appears briefly
then disappears).

Now leverage NM's built-in dnsmasq-shared.d config directory:
write DNS hijack config before starting AP so NM's own dnsmasq
picks it up. No separate dnsmasq process needed.

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-16 12:40:19 +08:00
parent f58db93b64
commit 9d8af52bf4
3 changed files with 43 additions and 92 deletions

View File

@@ -98,10 +98,12 @@ class ProvisionManager extends EventEmitter {
if (this._state === 'ap') return;
try {
const ap = startAP(this._clawId);
// 先写 DNS 劫持配置,再启动 AP
// NM 启动热点时会加载 dnsmasq-shared.d/ 下的配置
this._dns = new DnsHijack();
this._dns.start(ap.iface, AP_IP);
this._dns.start('wlan0', AP_IP);
const ap = startAP(this._clawId);
this._server = new CaptiveServer({
clawId: this._clawId,