fix: EROFS dns config, double WS connection, and watchdog timeout
1. EROFS: install.sh pre-writes DNS hijack config to dnsmasq-shared.d since /etc may be read-only at runtime. dns-hijack.js gracefully falls back to checking if config already exists. 2. Double WS: add _connectionStarted guard to prevent _proceedWithConnection from being called twice (via event + hasInternet check). 3. Watchdog: move _startSdNotify() to start() beginning so READY=1 is sent immediately, not delayed until network is ready. Made-with: Cursor
This commit is contained in:
@@ -60,12 +60,16 @@ class ClawClient {
|
||||
async start() {
|
||||
log.info('clawd', `启动中... 服务器 = ${this._cfg.server}`);
|
||||
|
||||
this._startSdNotify();
|
||||
|
||||
// 启动 AP 配网管理器(等待已保存 WiFi 自动连接,超时再开 AP)
|
||||
this._provisionMgr = new ProvisionManager(this._cfg.claw_id);
|
||||
this._connectionStarted = false;
|
||||
|
||||
// 网络就绪时连接云端
|
||||
this._provisionMgr.once('network-ready', () => {
|
||||
if (!this._ws) {
|
||||
// 网络就绪时连接云端(仅触发一次)
|
||||
this._provisionMgr.on('network-ready', () => {
|
||||
if (!this._connectionStarted) {
|
||||
this._connectionStarted = true;
|
||||
this._proceedWithConnection().catch(e => {
|
||||
log.error('clawd', '连接启动失败:', e.message);
|
||||
});
|
||||
@@ -74,8 +78,9 @@ class ClawClient {
|
||||
|
||||
await this._provisionMgr.start();
|
||||
|
||||
// start() 返回后,如果已有网络,直接连
|
||||
if (hasInternet() && !this._ws) {
|
||||
// start() 返回后,如果已有网络且尚未启动连接
|
||||
if (hasInternet() && !this._connectionStarted) {
|
||||
this._connectionStarted = true;
|
||||
await this._proceedWithConnection();
|
||||
} else if (!hasInternet()) {
|
||||
log.info('clawd', '等待网络就绪(WiFi 配网或网线接入)...');
|
||||
@@ -88,7 +93,6 @@ class ClawClient {
|
||||
startTtyd().catch(e => log.warn('ttyd', '启动失败:', e.message)),
|
||||
]);
|
||||
this._dashInfo = dashInfo || {};
|
||||
this._startSdNotify();
|
||||
this._connect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user