add /y/shell-exec in HTTP server

This commit is contained in:
Martin Michelsen
2025-01-11 22:16:26 -08:00
parent 80dda2e1f9
commit b028532db3
15 changed files with 1385 additions and 1248 deletions
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#include <deque>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "ProxyServer.hh"
#include "ServerState.hh"
class exit_shell : public std::runtime_error {
public:
exit_shell();
~exit_shell() = default;
};
struct ShellCommand {
struct Args {
std::shared_ptr<ServerState> s;
std::string command;
std::string args;
std::string session_name;
};
const char* name;
const char* help_text;
bool run_on_event_thread;
std::deque<std::string> (*run)(Args&);
static std::vector<const ShellCommand*> commands_by_order;
static std::unordered_map<std::string, const ShellCommand*> commands_by_name;
ShellCommand(const char* name, const char* help_text, bool run_on_event_thread, std::deque<std::string> (*run)(Args&));
static std::deque<std::string> dispatch_str(std::shared_ptr<ServerState> s, const std::string& command);
static std::deque<std::string> dispatch(Args& args);
};