shell.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef NGS_SYSTEM_SHELL_H
  2. #define NGS_SYSTEM_SHELL_H
  3. #include <cstdint>
  4. #include <string>
  5. namespace ylib {
  6. namespace network {
  7. namespace http {
  8. class request;
  9. class response;
  10. struct websocket_message;
  11. } // namespace http
  12. } // namespace network
  13. } // namespace ylib
  14. namespace ngs {
  15. namespace system {
  16. // Issue a short-lived one-time ticket for WebSocket auth (Cookie 在 WS 升级异步阶段不可靠).
  17. std::string shell_issue_ticket(const std::string& username);
  18. // Consume ticket; returns username on success.
  19. bool shell_consume_ticket(const std::string& ticket, std::string* username);
  20. // Handle /api/shell/ws WebSocket lifecycle (upgrade / header / body).
  21. void shell_ws_handler(ylib::network::http::request* req,
  22. ylib::network::http::response* resp,
  23. ylib::network::http::websocket_message* ws);
  24. // Cleanup when TCP connection drops (router on_close).
  25. void shell_on_conn_close(uint64_t connid);
  26. // Tear down all sessions (server shutdown).
  27. void shell_shutdown();
  28. } // namespace system
  29. } // namespace ngs
  30. #endif