@clawlabz/clawnetwork 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +11 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare function setInterval(fn: () => void, ms: number): unknown
|
|
|
7
7
|
declare function clearInterval(id: unknown): void
|
|
8
8
|
declare function fetch(url: string, init?: Record<string, unknown>): Promise<{ status: number; ok: boolean; text: () => Promise<string>; json: () => Promise<unknown> }>
|
|
9
9
|
|
|
10
|
-
const VERSION = '0.1.
|
|
10
|
+
const VERSION = '0.1.23'
|
|
11
11
|
const PLUGIN_ID = 'clawnetwork'
|
|
12
12
|
const GITHUB_REPO = 'clawlabz/claw-network'
|
|
13
13
|
const DEFAULT_RPC_PORT = 9710
|
|
@@ -505,12 +505,14 @@ function isNodeRunning(): { running: boolean; pid: number | null } {
|
|
|
505
505
|
return { running: false, pid: null }
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
/** Check if a TCP port is in use
|
|
508
|
+
/** Check if a TCP port is in use via nc -z (works across users, no bind needed) */
|
|
509
509
|
function isPortInUse(port: number): boolean {
|
|
510
510
|
try {
|
|
511
|
-
execFileSync('
|
|
512
|
-
return true
|
|
513
|
-
} catch {
|
|
511
|
+
execFileSync('nc', ['-z', '127.0.0.1', String(port)], { timeout: 2000, stdio: 'ignore' })
|
|
512
|
+
return true // connection succeeded → something is listening
|
|
513
|
+
} catch {
|
|
514
|
+
return false // connection refused → port is free
|
|
515
|
+
}
|
|
514
516
|
}
|
|
515
517
|
|
|
516
518
|
/** Find available ports starting from the configured ones, skipping occupied ports */
|
|
@@ -526,10 +528,10 @@ function findAvailablePorts(rpcPort: number, p2pPort: number, api: OpenClawApi):
|
|
|
526
528
|
rpc++
|
|
527
529
|
}
|
|
528
530
|
|
|
529
|
-
// Find available P2P port
|
|
531
|
+
// Find available P2P port (must also differ from RPC port)
|
|
530
532
|
for (let i = 0; i < MAX_TRIES; i++) {
|
|
531
|
-
if (!isPortInUse(p2p)) break
|
|
532
|
-
api.logger?.info?.(`[clawnetwork] P2P port ${p2p} in use, trying ${p2p + 1}...`)
|
|
533
|
+
if (!isPortInUse(p2p) && p2p !== rpc) break
|
|
534
|
+
api.logger?.info?.(`[clawnetwork] P2P port ${p2p} in use or conflicts with RPC, trying ${p2p + 1}...`)
|
|
533
535
|
p2p++
|
|
534
536
|
}
|
|
535
537
|
|
|
@@ -1980,7 +1982,7 @@ function startUiServer(cfg: PluginConfig, api: OpenClawApi): string | null {
|
|
|
1980
1982
|
fs.writeFileSync(scriptPath, fullScript)
|
|
1981
1983
|
|
|
1982
1984
|
try {
|
|
1983
|
-
const child = fork(scriptPath, [String(cfg.uiPort), String(cfg.rpcPort), LOG_PATH], {
|
|
1985
|
+
const child = fork(scriptPath, [String(cfg.uiPort), String(activeRpcPort ?? cfg.rpcPort), LOG_PATH], {
|
|
1984
1986
|
detached: true,
|
|
1985
1987
|
stdio: 'ignore',
|
|
1986
1988
|
})
|
package/openclaw.plugin.json
CHANGED