Fix operator terminal websocket input
This commit is contained in:
@@ -4,6 +4,7 @@ import { resolveRuntimeAuthority } from '@/app/lib/runtimeAuthority'
|
||||
|
||||
const TERMINAL_SERVER_URL = process.env.TERMINAL_SERVER_URL || 'http://127.0.0.1:3011'
|
||||
const TERMINAL_WS_PROXY_PATH = '/api/openshell/terminal/live/ws'
|
||||
const TERMINAL_WS_PROXY_PORT = process.env.TERMINAL_WS_PROXY_PORT || process.env.OPENCLAW_DASHBOARD_WS_PROXY_PORT || '3001'
|
||||
const PUBLIC_BROWSER_HOST = process.env.PUBLIC_BROWSER_HOST || process.env.PUBLIC_WS_HOST || null
|
||||
const PUBLIC_BASE_URL = process.env.PUBLIC_BASE_URL || null
|
||||
|
||||
@@ -16,19 +17,12 @@ function isNonRoutableHost(candidate: string, protocol = 'http:') {
|
||||
return (
|
||||
parsed.hostname === '0.0.0.0' ||
|
||||
parsed.hostname === '::' ||
|
||||
parsed.hostname === '127.0.0.1' ||
|
||||
parsed.hostname === 'localhost' ||
|
||||
parsed.hostname === '[::1]' ||
|
||||
parsed.hostname === '::1'
|
||||
parsed.hostname === '[::]'
|
||||
)
|
||||
} catch {
|
||||
return (
|
||||
normalized.startsWith('0.0.0.0') ||
|
||||
normalized.startsWith('[::]') ||
|
||||
normalized.startsWith('127.0.0.1') ||
|
||||
normalized.startsWith('localhost') ||
|
||||
normalized.startsWith('[::1]') ||
|
||||
normalized.startsWith('::1')
|
||||
normalized.startsWith('[::]')
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -82,7 +76,9 @@ function getBrowserWebSocketUrl(request: Request, params: {
|
||||
}
|
||||
const baseProtocol = (forwardedProto && forwardedProto.trim()) || requestUrl.protocol.replace(/:$/, '')
|
||||
const protocol = baseProtocol === 'https' ? 'wss:' : 'ws:'
|
||||
const websocketUrl = new URL(TERMINAL_WS_PROXY_PATH, `${protocol}//${host}`)
|
||||
const websocketHost = new URL(`${protocol}//${host}`)
|
||||
websocketHost.port = TERMINAL_WS_PROXY_PORT
|
||||
const websocketUrl = new URL(TERMINAL_WS_PROXY_PATH, websocketHost)
|
||||
websocketUrl.searchParams.set('sessionId', params.sessionId)
|
||||
websocketUrl.searchParams.set('sandboxId', params.sandboxId)
|
||||
websocketUrl.searchParams.set('dashboardSessionId', params.dashboardSessionId)
|
||||
|
||||
Reference in New Issue
Block a user