feat: recognize CutOS agent runtime
This commit is contained in:
+19
-17
@@ -147,7 +147,7 @@ function downloadFile(url, dest) {
|
||||
});
|
||||
}
|
||||
|
||||
function writeFrpcConfig(clawId, frpConfig, sshSecretKey) {
|
||||
function writeFrpcConfig(clawId, frpConfig, sshSecretKey, dashboardEnabled = true) {
|
||||
const { auth_token, dashboard_local_port = 18789 } = frpConfig;
|
||||
const ttyRemotePort = 10000 + Number(clawId);
|
||||
const stcpBlock = sshSecretKey ? `
|
||||
@@ -156,6 +156,20 @@ name = "ssh-${clawId}-secret"
|
||||
type = "stcp"
|
||||
secretKey = "${sshSecretKey}"
|
||||
localPort = 22
|
||||
` : '';
|
||||
const ttyBlock = `
|
||||
[[proxies]]
|
||||
name = "tty-${clawId}"
|
||||
type = "tcp"
|
||||
localPort = ${TTYD_PORT}
|
||||
remotePort = ${ttyRemotePort}
|
||||
`;
|
||||
const dashboardBlock = dashboardEnabled ? `
|
||||
[[proxies]]
|
||||
name = "dashboard-${clawId}"
|
||||
type = "http"
|
||||
localPort = ${dashboard_local_port}
|
||||
subdomain = "${clawId}"
|
||||
` : '';
|
||||
const toml = `# 由 clawd 自动生成,请勿手动修改
|
||||
serverAddr = "frp.claw.cutos.ai"
|
||||
@@ -167,22 +181,10 @@ token = "${auth_token}"
|
||||
|
||||
[transport]
|
||||
tls.enable = true
|
||||
|
||||
[[proxies]]
|
||||
name = "dashboard-${clawId}"
|
||||
type = "http"
|
||||
localPort = ${dashboard_local_port}
|
||||
subdomain = "${clawId}"
|
||||
|
||||
[[proxies]]
|
||||
name = "tty-${clawId}"
|
||||
type = "tcp"
|
||||
localPort = ${TTYD_PORT}
|
||||
remotePort = ${ttyRemotePort}
|
||||
${stcpBlock}`;
|
||||
${dashboardBlock}${ttyBlock}${stcpBlock}`;
|
||||
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
||||
fs.writeFileSync(FRPC_CONFIG, toml, 'utf8');
|
||||
log.info('frpc', `frpc.toml 已写入: dashboard subdomain=${clawId}, tty tcp-port=${ttyRemotePort}${sshSecretKey ? ', ssh stcp=enabled' : ''}`);
|
||||
log.info('frpc', `frpc.toml 已写入: dashboard=${dashboardEnabled ? `subdomain ${clawId}` : 'disabled'}, tty tcp-port=${ttyRemotePort}${stcpBlock ? ', ssh stcp=enabled' : ''}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +196,7 @@ class FrpcManager {
|
||||
this._watchdog = null;
|
||||
}
|
||||
|
||||
async start(clawId, frpConfig, sshSecretKey) {
|
||||
async start(clawId, frpConfig, sshSecretKey, dashboardEnabled = true) {
|
||||
this.stop();
|
||||
|
||||
if (!fs.existsSync(FRPC_BIN)) {
|
||||
@@ -206,7 +208,7 @@ class FrpcManager {
|
||||
}
|
||||
}
|
||||
|
||||
writeFrpcConfig(clawId, frpConfig, sshSecretKey);
|
||||
writeFrpcConfig(clawId, frpConfig, sshSecretKey, dashboardEnabled);
|
||||
|
||||
this._watchdog = new Watchdog('frpc', FRPC_BIN, ['-c', FRPC_CONFIG], {
|
||||
maxRestarts: 10,
|
||||
|
||||
Reference in New Issue
Block a user