diff --git a/frontend/src/terminal.ts b/frontend/src/terminal.ts index e48a8c3..f91f51d 100644 --- a/frontend/src/terminal.ts +++ b/frontend/src/terminal.ts @@ -131,7 +131,6 @@ export class SSHTerminal { privateKey: config.privateKey, })); - this.reconnectAttempts = 0; this.startHeartbeat(); resolve(); }; @@ -160,7 +159,6 @@ export class SSHTerminal { ws.onopen = () => { this.terminal.writeln('\x1b[32m[+] WebSocket connected, authenticating...\x1b[0m'); - this.reconnectAttempts = 0; this.startHeartbeat(); }; @@ -188,6 +186,7 @@ export class SSHTerminal { case 'status': this.terminal.writeln(`\x1b[32m[*] ${msg.message}\x1b[0m`); if (msg.message === '认证成功') { + this.reconnectAttempts = 0; const statusText = document.getElementById('status-text'); if (statusText) statusText.innerHTML = ' STATUS: ONLINE'; } diff --git a/src/worker/durable-object.ts b/src/worker/durable-object.ts index 0579e90..9bbeaa6 100644 --- a/src/worker/durable-object.ts +++ b/src/worker/durable-object.ts @@ -169,7 +169,8 @@ export class SSHSessionDO { } const { connect } = await import('cloudflare:sockets'); - const socket = connect({ hostname: config.host, port: config.port }); + const hostname = config.host.includes(':') ? `[${config.host}]` : config.host; + const socket = connect({ hostname, port: config.port }); await socket.opened; diff --git a/src/worker/html.ts b/src/worker/html.ts index 28a3061..7dba2ac 100644 --- a/src/worker/html.ts +++ b/src/worker/html.ts @@ -1,46 +1,46 @@ // Automatically generated by scripts/build-html.js. Do not edit directly. -export const HTML = ` - -
- - - -