classifyAgentError maps the agent's free-text error into a stable code the frontend can switch on to render specific guidance. The message itself is still shown verbatim; the code just tells the UI which help block to pick.
(msg string)
| 389 | // frontend can switch on to render specific guidance. The message itself is |
| 390 | // still shown verbatim; the code just tells the UI which help block to pick. |
| 391 | func classifyAgentError(msg string) string { |
| 392 | lower := strings.ToLower(msg) |
| 393 | switch { |
| 394 | case strings.Contains(lower, "rdp-proxy-enabled"), strings.Contains(lower, "rdp proxy is not enabled"): |
| 395 | return "agent_rdp_disabled" |
| 396 | case strings.Contains(lower, "invalid host"): |
| 397 | return "agent_invalid_host" |
| 398 | case strings.Contains(lower, "connection refused"), |
| 399 | strings.Contains(lower, "failed to connect"), |
| 400 | strings.Contains(lower, "i/o timeout"), |
| 401 | strings.Contains(lower, "no route to host"): |
| 402 | return "rdp_port_unreachable" |
| 403 | default: |
| 404 | return "agent_error" |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // WebsocketTunnelHandler returns an http.Handler for the Guacamole WebSocket tunnel. |
| 409 | // It wraps the guac WebSocket server with origin validation to prevent cross-origin hijacking. |