|
Hermes 0.7.0
Linux game streaming host
|
Definitions for the Web UI Config HTTPS server. More...
#include <filesystem>#include <format>#include <fstream>#include <set>#include <sstream>#include <thread>#include <condition_variable>#include <mutex>#include <numeric>#include <algorithm>#include <atomic>#include <deque>#include <map>#include <limits>#include <optional>#include <iterator>#include <cctype>#include <sys/utsname.h>#include <unistd.h>#include <cerrno>#include <cstring>#include <fcntl.h>#include <sys/stat.h>#include <boost/algorithm/string.hpp>#include <boost/asio/ssl/context.hpp>#include <boost/filesystem.hpp>#include <boost/process/v1/search_path.hpp>#include <nlohmann/json.hpp>#include <Simple-Web-Server/crypto.hpp>#include <Simple-Web-Server/server_https.hpp>#include "audio.h"#include "config.h"#include "confighttp.h"#include "crypto.h"#include "display_device.h"#include "file_handler.h"#include "globals.h"#include "httpcommon.h"#include "logging.h"#include "network.h"#include "nvhttp.h"#include "platform/common.h"#include "process.h"#include "rtsp.h"#include "stream.h"#include "utility.h"#include "uuid.h"#include "video.h"#include "platform/linux/bounded_command.h"#include "platform/linux/game_library.h"#include "platform/linux/misc.h"#include "platform/linux/prelogin.h"Go to the source code of this file.
Classes | |
| class | confighttp::HestiaHTTPSServer |
| struct | confighttp::report_timeline::system_t |
| The machine around the stream. A value nobody may read here stays negative. More... | |
| struct | confighttp::report_timeline::sample_t |
| struct | confighttp::report_timeline::previous_t |
Namespaces | |
| namespace | confighttp::report_timeline |
Typedefs | |
| using | confighttp::https_server_t = HestiaHTTPSServer |
| using | confighttp::args_t = SimpleWeb::CaseInsensitiveMultimap |
| using | confighttp::resp_https_t = std::shared_ptr<typename SimpleWeb::ServerBase<SimpleWeb::HTTPS>::Response> |
| using | confighttp::req_https_t = std::shared_ptr<typename SimpleWeb::ServerBase<SimpleWeb::HTTPS>::Request> |
Enumerations | |
| enum class | confighttp::op_e { ADD , REMOVE } |
Functions | |
| nlohmann::json | confighttp::hestia_runtime_status_json () |
| bool | confighttp::local_api_token_origin_allowed (std::string_view address) |
| Whether an address may authenticate with the Game Mode local token. | |
| std::filesystem::path | confighttp::local_api_token_path () |
| bool | confighttp::token_matches (std::string_view presented, std::string_view expected) |
| void | confighttp::write_local_api_token () |
| void | confighttp::remove_local_api_token () |
| bool | confighttp::has_local_api_token (req_https_t request) |
| void | confighttp::print_req (const req_https_t &request) |
| Log the request details. | |
| void | confighttp::send_response (resp_https_t response, const nlohmann::json &output_tree) |
| Send a response. | |
| void | confighttp::send_unauthorized (resp_https_t response, req_https_t request) |
| Send a 401 Unauthorized response. | |
| void | confighttp::send_redirect (resp_https_t response, req_https_t request, const char *path) |
| Send a redirect response. | |
| std::string | confighttp::getCookieValue (const std::string &cookieString, const std::string &key) |
| Retrieve the value of a key from a cookie string. | |
| bool | confighttp::checkIPOrigin (resp_https_t response, req_https_t request) |
| Check if the IP origin is allowed. | |
| bool | confighttp::authenticate (resp_https_t response, req_https_t request, bool needsRedirect=false) |
| Authenticate the request. | |
| void | confighttp::not_found (resp_https_t response, req_https_t request) |
| Send a 404 Not Found response. | |
| void | confighttp::bad_request (resp_https_t response, req_https_t request, const std::string &error_message="Bad Request") |
| Send a 400 Bad Request response. | |
| bool | confighttp::validateContentType (resp_https_t response, req_https_t request, const std::string_view &contentType) |
| Validate the request content type and send bad request when mismatch. | |
| void | confighttp::send_web_page (resp_https_t response, req_https_t request, const std::string &page, const SimpleWeb::CaseInsensitiveMultimap &extra_headers={}) |
| Serve a page from the packaged web assets. | |
| void | confighttp::getIndexPage (resp_https_t response, req_https_t request) |
| Get the index page. | |
| void | confighttp::getPinPage (resp_https_t response, req_https_t request) |
| Get the PIN page. | |
| void | confighttp::getAppsPage (resp_https_t response, req_https_t request) |
| Get the apps page. | |
| void | confighttp::getClientsPage (resp_https_t response, req_https_t request) |
| Get the clients page. | |
| void | confighttp::getConfigPage (resp_https_t response, req_https_t request) |
| Get the configuration page. | |
| void | confighttp::getPasswordPage (resp_https_t response, req_https_t request) |
| Get the password page. | |
| void | confighttp::getLoginPage (resp_https_t response, req_https_t request) |
| Get the login page. | |
| void | confighttp::getWelcomePage (resp_https_t response, req_https_t request) |
| Get the welcome page. | |
| void | confighttp::getTroubleshootingPage (resp_https_t response, req_https_t request) |
| Get the troubleshooting page. | |
| void | confighttp::getFaviconImage (resp_https_t response, req_https_t request) |
| Get the favicon image. | |
| void | confighttp::getHermesLogoImage (resp_https_t response, req_https_t request) |
| Get the Hermes logo image. | |
| bool | confighttp::isChildPath (fs::path const &base, fs::path const &query) |
| Check if a path is a child of another path. | |
| void | confighttp::getNodeModules (resp_https_t response, req_https_t request) |
| Get an asset from the node_modules directory. | |
| void | confighttp::getMetrics (resp_https_t response, req_https_t request) |
| Get the live runtime status: encoder, session, and pipeline counters. The same view the Hestia diagnostics return, behind the normal Web UI session auth so the dashboard can poll it. | |
| void | confighttp::getApps (resp_https_t response, req_https_t request) |
| Get the list of available applications. | |
| void | confighttp::getLibrary (resp_https_t response, req_https_t request) |
| List the games installed in Steam and Lutris, to add as apps. | |
| void | confighttp::saveApp (resp_https_t response, req_https_t request) |
| Save an application. To save a new application the UUID must be empty. To update an existing application, you must provide the current UUID of the application. | |
| void | confighttp::closeApp (resp_https_t response, req_https_t request) |
| Close the currently running application. | |
| void | confighttp::reorderApps (resp_https_t response, req_https_t request) |
| Reorder applications. | |
| void | confighttp::deleteApp (resp_https_t response, req_https_t request) |
| Delete an application. | |
| void | confighttp::getClients (resp_https_t response, req_https_t request) |
| Get the list of paired clients. | |
| void | confighttp::updateClient (resp_https_t response, req_https_t request) |
| Update client information. | |
| void | confighttp::unpair (resp_https_t response, req_https_t request) |
| Unpair a client. | |
| void | confighttp::unpairAll (resp_https_t response, req_https_t request) |
| Unpair all clients. | |
| nlohmann::json | confighttp::computed_config_json () |
| Get the configuration settings. | |
| nlohmann::json & | confighttp::overlay_config_file (nlohmann::json &response, const std::unordered_map< std::string, std::string > &file_values) |
Overlay a parsed hermes.conf onto response, in place. | |
| void | confighttp::getConfig (resp_https_t response, req_https_t request) |
| Get the current configuration: the computed values Hermes is running with, overlaid with what the configuration file sets explicitly. | |
| void | confighttp::getHestiaCapabilities (resp_https_t response, req_https_t request) |
| Return the static Hestia extension capabilities. | |
| nlohmann::json | confighttp::hestia_capabilities_json () |
| The Hestia extension capabilities document. | |
| void | confighttp::send_hestia_error (resp_https_t response, SimpleWeb::StatusCode status, const char *code, const char *message) |
| bool | confighttp::authenticate_hestia_client (resp_https_t response, req_https_t request, crypto::PERM permission, const char *operation) |
| std::shared_ptr< crypto::named_cert_t > | confighttp::authenticate_hestia_paired_client (resp_https_t response, req_https_t request) |
| bool | confighttp::hestia_has_exact_keys (const nlohmann::json &object, const std::set< std::string > &keys) |
| bool | confighttp::hestia_is_positive_integer (const nlohmann::json &value) |
| bool | confighttp::hestia_is_one_of (const nlohmann::json &value, const std::set< std::string > &values) |
| bool | confighttp::validate_hestia_session_prepare (const nlohmann::json &request, std::string &error) |
| void | confighttp::prepare_hestia_session (resp_https_t response, req_https_t request) |
| Store settings for a paired Hestia client's next stream launch. | |
| void | confighttp::stop_hestia_session (resp_https_t response, req_https_t request) |
| nlohmann::json | confighttp::hestia_display_status_json () |
| void | confighttp::get_hestia_display_status (resp_https_t response, req_https_t request) |
| void | confighttp::recover_hestia_display (resp_https_t response, req_https_t request) |
| void | confighttp::get_hestia_commands (resp_https_t response, req_https_t request) |
| void | confighttp::get_hestia_client_permissions (resp_https_t response, req_https_t request) |
| void | confighttp::get_hestia_clipboard (resp_https_t response, req_https_t request) |
| nlohmann::json | confighttp::hestia_preflight_json () |
| Aggregate "is the host ready to stream?" checks. | |
| void | confighttp::get_hestia_diagnostics (resp_https_t response, req_https_t request) |
| void | confighttp::get_hestia_stream_info (resp_https_t response, req_https_t request) |
| std::optional< long long > | confighttp::report_timeline::read_number (const fs::path &path) |
| std::string | confighttp::report_timeline::read_word (const fs::path &path) |
| std::optional< fs::path > | confighttp::report_timeline::hwmon (std::initializer_list< std::string_view > names, const fs::path &root="/sys/class/hwmon") |
| double | confighttp::report_timeline::temperature (const fs::path &dir, std::string_view label) |
| double | confighttp::report_timeline::current_amdgpu_clock (const fs::path &path) |
| void | confighttp::report_timeline::read_nvidia (const std::string &pci_address, system_t &s) |
| system_t | confighttp::report_timeline::read_system (bool gpu) |
| void | confighttp::report_timeline::record () |
| std::vector< sample_t > | confighttp::report_timeline::snapshot () |
| void | confighttp::machine_snapshot (std::ostream &out) |
| std::string | confighttp::diagnostic_report () |
| void | confighttp::send_diagnostic_report (resp_https_t response) |
| void | confighttp::getDiagnosticReport (resp_https_t response, req_https_t request) |
| Download a diagnostic report of this host. | |
| void | confighttp::get_hestia_diagnostic_report (resp_https_t response, req_https_t request) |
| void | confighttp::set_hestia_clipboard (resp_https_t response, req_https_t request) |
| void | confighttp::run_hestia_command (resp_https_t response, req_https_t request) |
| void | confighttp::getLocale (resp_https_t response, req_https_t request) |
| Get the locale setting. | |
| void | confighttp::saveConfig (resp_https_t response, req_https_t request) |
| Save the configuration settings. | |
| bool | confighttp::running_in_container () |
| Whether Hermes is running inside a container. | |
| void | confighttp::installEvdi (resp_https_t response, req_https_t request) |
| void | confighttp::getEvdiInstallStatus (resp_https_t response, req_https_t request) |
| void | confighttp::getEvdiStatus (resp_https_t response, req_https_t request) |
| void | confighttp::getHermesKmsStatus (resp_https_t response, req_https_t request) |
| void | confighttp::getSessions (resp_https_t response, req_https_t request) |
| List the isolated sessions this server is holding. | |
| void | confighttp::getGameModeStatus (resp_https_t response, req_https_t request) |
| Everything the Game Mode console shows on one screen, in one call. | |
| void | confighttp::terminateSession (resp_https_t response, req_https_t request) |
| End one isolated session. | |
| void | confighttp::getClipboardStatus (resp_https_t response, req_https_t request) |
| void | confighttp::installClipboard (resp_https_t response, req_https_t request) |
| void | confighttp::uploadCover (resp_https_t response, req_https_t request) |
| Upload a cover image. | |
| void | confighttp::getLogs (resp_https_t response, req_https_t request) |
| Get the logs from the log file. | |
| void | confighttp::savePassword (resp_https_t response, req_https_t request) |
| Update existing credentials. | |
| void | confighttp::getOTP (resp_https_t response, req_https_t request) |
| Get a one-time password (OTP). | |
| void | confighttp::savePin (resp_https_t response, req_https_t request) |
| Send a PIN code to the host. | |
| void | confighttp::resetDisplayDevicePersistence (resp_https_t response, req_https_t request) |
| Reset the display device persistence. | |
| void | confighttp::restart (resp_https_t response, req_https_t request) |
| Restart Hermes. | |
| void | confighttp::quit (resp_https_t response, req_https_t request) |
| Quit Hermes. | |
| void | confighttp::launchApp (resp_https_t response, req_https_t request) |
| Launch an application. | |
| void | confighttp::disconnect (resp_https_t response, req_https_t request) |
| Disconnect a client. | |
| void | confighttp::login (resp_https_t response, req_https_t request) |
| Login the user. | |
| void | confighttp::start () |
| Start the HTTPS server. | |
Variables | |
| std::string | confighttp::sessionCookie |
| std::string | confighttp::localApiToken |
| A bearer token any local process of this user may present. | |
| std::filesystem::path | confighttp::localApiTokenPath |
| struct confighttp::report_timeline::previous_t | confighttp::report_timeline::previous |
| std::string | confighttp::report_timeline::encode_card |
| The encoding GPU's sysfs device directory. | |
| std::mutex | confighttp::report_timeline::mutex |
| std::deque< sample_t > | confighttp::report_timeline::samples |
| constexpr std::size_t | confighttp::report_timeline::max_samples = 720 |
Definitions for the Web UI Config HTTPS server.
Definition in file confighttp.cpp.
| #define BOOST_BIND_GLOBAL_PLACEHOLDERS |
Definition at line 7 of file confighttp.cpp.
| using confighttp::args_t = SimpleWeb::CaseInsensitiveMultimap |
Definition at line 189 of file confighttp.cpp.
| using confighttp::https_server_t = HestiaHTTPSServer |
Definition at line 188 of file confighttp.cpp.
| using confighttp::req_https_t = std::shared_ptr<typename SimpleWeb::ServerBase<SimpleWeb::HTTPS>::Request> |
Definition at line 191 of file confighttp.cpp.
| using confighttp::resp_https_t = std::shared_ptr<typename SimpleWeb::ServerBase<SimpleWeb::HTTPS>::Response> |
Definition at line 190 of file confighttp.cpp.
|
strong |
| Enumerator | |
|---|---|
| ADD | Add client. |
| REMOVE | Remove client. |
Definition at line 194 of file confighttp.cpp.
| bool confighttp::authenticate | ( | resp_https_t | response, |
| req_https_t | request, | ||
| bool | needsRedirect = false ) |
Authenticate the request.
| response | The HTTP response object. |
| request | The HTTP request object. |
| needsRedirect | Whether to redirect on failure. |
This function uses session cookies (if set) and ensures they have not expired.
Definition at line 720 of file confighttp.cpp.
| bool confighttp::authenticate_hestia_client | ( | resp_https_t | response, |
| req_https_t | request, | ||
| crypto::PERM | permission, | ||
| const char * | operation ) |
Definition at line 1762 of file confighttp.cpp.
| std::shared_ptr< crypto::named_cert_t > confighttp::authenticate_hestia_paired_client | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 1778 of file confighttp.cpp.
| void confighttp::bad_request | ( | resp_https_t | response, |
| req_https_t | request, | ||
| const std::string & | error_message = "Bad Request" ) |
Send a 400 Bad Request response.
| response | The HTTP response object. |
| request | The HTTP request object. |
| error_message | The error message. |
Definition at line 787 of file confighttp.cpp.
| bool confighttp::checkIPOrigin | ( | resp_https_t | response, |
| req_https_t | request ) |
Check if the IP origin is allowed.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 700 of file confighttp.cpp.
| void confighttp::closeApp | ( | resp_https_t | response, |
| req_https_t | request ) |
Close the currently running application.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1298 of file confighttp.cpp.
| nlohmann::json confighttp::computed_config_json | ( | ) |
Get the configuration settings.
The fields the Web UI's config response computes for itself: host status, platform and version. Never configuration.
| response | The HTTP response object. |
| request | The HTTP request object. |
Every key here must also be in config::server_computed_keys(), which is what keeps a hermes.conf from overwriting one of them; a test asserts it.
Definition at line 1619 of file confighttp.cpp.
| void confighttp::deleteApp | ( | resp_https_t | response, |
| req_https_t | request ) |
Delete an application.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1432 of file confighttp.cpp.
| std::string confighttp::diagnostic_report | ( | ) |
One plain-text file that explains a host to someone who cannot see it: the machine and its GPUs, the last capture-path check, the warnings and errors in the log, the stream timeline, the runtime state, the settings without secrets, and the recent log. Made to attach to an issue.
Definition at line 2976 of file confighttp.cpp.
| void confighttp::disconnect | ( | resp_https_t | response, |
| req_https_t | request ) |
Disconnect a client.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 4065 of file confighttp.cpp.
| void confighttp::get_hestia_client_permissions | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2087 of file confighttp.cpp.
| void confighttp::get_hestia_clipboard | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2114 of file confighttp.cpp.
| void confighttp::get_hestia_commands | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2070 of file confighttp.cpp.
| void confighttp::get_hestia_diagnostic_report | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 3179 of file confighttp.cpp.
| void confighttp::get_hestia_diagnostics | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2396 of file confighttp.cpp.
| void confighttp::get_hestia_display_status | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2018 of file confighttp.cpp.
| void confighttp::get_hestia_stream_info | ( | resp_https_t | response, |
| req_https_t | request ) |
What the stream about to start, or running, goes through: the capture, its size and rate, the encoder and its GPU, as the last capture-path check found them. A client shows it so its user knows the stream is served the way they expect. readiness is null before any check, and when the last check was not for this client's launch: with several clients, another's stream says nothing about the one asking.
Definition at line 2412 of file confighttp.cpp.
| void confighttp::getApps | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the list of available applications.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1131 of file confighttp.cpp.
| void confighttp::getAppsPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the apps page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 912 of file confighttp.cpp.
| void confighttp::getClients | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the list of paired clients.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1488 of file confighttp.cpp.
| void confighttp::getClientsPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the clients page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 927 of file confighttp.cpp.
| void confighttp::getClipboardStatus | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 3634 of file confighttp.cpp.
| void confighttp::getConfig | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the current configuration: the computed values Hermes is running with, overlaid with what the configuration file sets explicitly.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1659 of file confighttp.cpp.
| void confighttp::getConfigPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the configuration page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 942 of file confighttp.cpp.
| std::string confighttp::getCookieValue | ( | const std::string & | cookieString, |
| const std::string & | key ) |
Retrieve the value of a key from a cookie string.
| cookieString | The cookie header string. |
| key | The key to search. |
Definition at line 682 of file confighttp.cpp.
| void confighttp::getDiagnosticReport | ( | resp_https_t | response, |
| req_https_t | request ) |
Download a diagnostic report of this host.
Definition at line 3171 of file confighttp.cpp.
| void confighttp::getEvdiInstallStatus | ( | resp_https_t | response, |
| req_https_t | request ) |
Return the state of the EVDI installation started by this Web UI.
Definition at line 3425 of file confighttp.cpp.
| void confighttp::getEvdiStatus | ( | resp_https_t | response, |
| req_https_t | request ) |
Return the current EVDI runtime and DKMS status for the Audio/Video UI.
Definition at line 3442 of file confighttp.cpp.
| void confighttp::getFaviconImage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the favicon image.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1023 of file confighttp.cpp.
| void confighttp::getGameModeStatus | ( | resp_https_t | response, |
| req_https_t | request ) |
Everything the Game Mode console shows on one screen, in one call.
| response | The HTTP response object. |
| request | The HTTP request object. |
A console driven with a thumbstick polls; three round trips per poll to assemble one screen is three times the work and three chances to render a half-updated view. What it needs is small and fits in one object: is Hermes up, does anybody need a PIN typed right now, how many devices are paired, and is anything streaming.
pending_pair is the field the console exists for. It is true only while a client's request is parked waiting for four digits, so the console can put the pairing screen in front of the user at the moment it is useful instead of asking them to go looking for it.
Definition at line 3545 of file confighttp.cpp.
| void confighttp::getHermesKmsStatus | ( | resp_https_t | response, |
| req_https_t | request ) |
Return the current Hermes-KMS driver and DKMS status for the Audio/Video UI.
Definition at line 3454 of file confighttp.cpp.
| void confighttp::getHermesLogoImage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the Hermes logo image.
| response | The HTTP response object. |
| request | The HTTP request object. |
combine function with getFaviconImage and possibly getNodeModules
use mime_types map
Definition at line 1042 of file confighttp.cpp.
| void confighttp::getHestiaCapabilities | ( | resp_https_t | response, |
| req_https_t | request ) |
Return the static Hestia extension capabilities.
This endpoint is deliberately read-only and unauthenticated so clients can detect Hermes before an extension authentication flow is available. It does not expose host state or permit any host-control operation.
Definition at line 1678 of file confighttp.cpp.
| void confighttp::getIndexPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the index page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 882 of file confighttp.cpp.
| void confighttp::getLibrary | ( | resp_https_t | response, |
| req_https_t | request ) |
List the games installed in Steam and Lutris, to add as apps.
Reads native Steam (~/.local/share/Steam, ~/.steam/steam) and Flatpak Steam, and asks Lutris (native or Flatpak) for its installed games. Each game comes with the command that starts it; nothing is added here.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1165 of file confighttp.cpp.
| void confighttp::getLocale | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the locale setting.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 3271 of file confighttp.cpp.
| void confighttp::getLoginPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the login page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 974 of file confighttp.cpp.
| void confighttp::getLogs | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the logs from the log file.
| response | The HTTP response object. |
| request | The HTTP request object. |
@api_examples{/api/logs| GET| null}
Definition at line 3749 of file confighttp.cpp.
| void confighttp::getMetrics | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the live runtime status: encoder, session, and pipeline counters. The same view the Hestia diagnostics return, behind the normal Web UI session auth so the dashboard can poll it.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1115 of file confighttp.cpp.
| void confighttp::getNodeModules | ( | resp_https_t | response, |
| req_https_t | request ) |
Get an asset from the node_modules directory.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1069 of file confighttp.cpp.
| void confighttp::getOTP | ( | resp_https_t | response, |
| req_https_t | request ) |
Get a one-time password (OTP).
| response | The HTTP response object. |
| request | The HTTP request object. |
@api_examples{/api/otp| GET| null}
Definition at line 3839 of file confighttp.cpp.
| void confighttp::getPasswordPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the password page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 957 of file confighttp.cpp.
| void confighttp::getPinPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the PIN page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 897 of file confighttp.cpp.
| void confighttp::getSessions | ( | resp_https_t | response, |
| req_https_t | request ) |
List the isolated sessions this server is holding.
| response | The HTTP response object. |
| request | The HTTP request object. |
Not the same list as /api/clients/list, which is who may connect, nor the same as who is streaming: an isolated session outlives the stream that started it, so that a client can come back to the desktop it left. That is also how one can be left running with nobody attached, which is the case this list exists to make visible.
Definition at line 3479 of file confighttp.cpp.
| void confighttp::getTroubleshootingPage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the troubleshooting page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1008 of file confighttp.cpp.
| void confighttp::getWelcomePage | ( | resp_https_t | response, |
| req_https_t | request ) |
Get the welcome page.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 992 of file confighttp.cpp.
| bool confighttp::has_local_api_token | ( | req_https_t | request | ) |
Whether the request carries the local token in an Authorization header.
Definition at line 296 of file confighttp.cpp.
| nlohmann::json confighttp::hestia_capabilities_json | ( | ) |
The Hestia extension capabilities document.
Exposed so the served document can be checked against the capabilities.schema.json this repository ships. The two had drifted - the document advertised a virtual display backend the schema does not allow - and every shipped Hestia rejected the whole document for it.
Definition at line 1684 of file confighttp.cpp.
| nlohmann::json confighttp::hestia_display_status_json | ( | ) |
Definition at line 1987 of file confighttp.cpp.
| bool confighttp::hestia_has_exact_keys | ( | const nlohmann::json & | object, |
| const std::set< std::string > & | keys ) |
Definition at line 1786 of file confighttp.cpp.
| bool confighttp::hestia_is_one_of | ( | const nlohmann::json & | value, |
| const std::set< std::string > & | values ) |
Definition at line 1804 of file confighttp.cpp.
| bool confighttp::hestia_is_positive_integer | ( | const nlohmann::json & | value | ) |
Definition at line 1800 of file confighttp.cpp.
| nlohmann::json confighttp::hestia_preflight_json | ( | ) |
Aggregate "is the host ready to stream?" checks.
Definition at line 2283 of file confighttp.cpp.
| nlohmann::json confighttp::hestia_runtime_status_json | ( | ) |
Definition at line 2129 of file confighttp.cpp.
| void confighttp::installClipboard | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 3646 of file confighttp.cpp.
| void confighttp::installEvdi | ( | resp_https_t | response, |
| req_https_t | request ) |
Start EVDI installation only after the user explicitly confirms it in the UI. pkexec owns the privilege prompt, so Hermes never handles an admin password.
Definition at line 3346 of file confighttp.cpp.
| bool confighttp::isChildPath | ( | fs::path const & | base, |
| fs::path const & | query ) |
Check if a path is a child of another path.
| base | The base path. |
| query | The path to check. |
Definition at line 1059 of file confighttp.cpp.
| void confighttp::launchApp | ( | resp_https_t | response, |
| req_https_t | request ) |
Launch an application.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 4003 of file confighttp.cpp.
| bool confighttp::local_api_token_origin_allowed | ( | std::string_view | address | ) |
Whether an address may authenticate with the Game Mode local token.
The token is capped at this machine and private/local networks even when normal Web UI logins are configured to accept WAN clients.
Definition at line 78 of file confighttp.cpp.
| std::filesystem::path confighttp::local_api_token_path | ( | ) |
Definition at line 224 of file confighttp.cpp.
| void confighttp::login | ( | resp_https_t | response, |
| req_https_t | request ) |
Login the user.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
Definition at line 4099 of file confighttp.cpp.
| void confighttp::machine_snapshot | ( | std::ostream & | out | ) |
What is attached to and running on the machine, as an unprivileged user can read it: USB devices, input devices, display outputs with their state, Hermes' own sessions, network links with their speed, sound cards, and the programs using the most memory and CPU time.
Definition at line 2807 of file confighttp.cpp.
| void confighttp::not_found | ( | resp_https_t | response, |
| req_https_t | request ) |
Send a 404 Not Found response.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 768 of file confighttp.cpp.
| nlohmann::json & confighttp::overlay_config_file | ( | nlohmann::json & | response, |
| const std::unordered_map< std::string, std::string > & | file_values ) |
Overlay a parsed hermes.conf onto response, in place.
A key the response already carries is left alone. The Web UI posts the whole config response back and saveConfig() persists it, so a read-only field really does end up in the file - and a parsed value is always a string, which replaced a JSON array with "[]" and took the home page down with it.
response, for chaining. Definition at line 1637 of file confighttp.cpp.
| void confighttp::prepare_hestia_session | ( | resp_https_t | response, |
| req_https_t | request ) |
Store settings for a paired Hestia client's next stream launch.
The normal GameStream launch path consumes the short-lived settings and creates a virtual display only when the stream actually begins.
The response's settings says what that launch will apply for the requested app, so the client can show where a host setting overrides its own: for virtual_display and scale_factor, the requested and effective values and the source that decided (client, app_forced for an app that forces its setting, app or host_default when the client's value is not used, headless, or isolated_session for an app that always runs on a display of its own). It is null when no app has the requested id.
Definition at line 1892 of file confighttp.cpp.
| void confighttp::print_req | ( | const req_https_t & | request | ) |
Log the request details.
| request | The HTTP request object. |
Definition at line 612 of file confighttp.cpp.
| void confighttp::quit | ( | resp_https_t | response, |
| req_https_t | request ) |
Quit Hermes.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 3964 of file confighttp.cpp.
| void confighttp::recover_hestia_display | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 2026 of file confighttp.cpp.
| void confighttp::remove_local_api_token | ( | ) |
Definition at line 285 of file confighttp.cpp.
| void confighttp::reorderApps | ( | resp_https_t | response, |
| req_https_t | request ) |
Reorder applications.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1318 of file confighttp.cpp.
| void confighttp::resetDisplayDevicePersistence | ( | resp_https_t | response, |
| req_https_t | request ) |
Reset the display device persistence.
| response | The HTTP response object. |
| request | The HTTP request object. |
@api_examples{/api/reset-display-device-persistence| POST| null}
Definition at line 3915 of file confighttp.cpp.
| void confighttp::restart | ( | resp_https_t | response, |
| req_https_t | request ) |
Restart Hermes.
| response | The HTTP response object. |
| request | The HTTP request object. |
@api_examples{/api/restart| POST| null}
Definition at line 3934 of file confighttp.cpp.
| void confighttp::run_hestia_command | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 3218 of file confighttp.cpp.
| bool confighttp::running_in_container | ( | ) |
Whether Hermes is running inside a container.
Both runtimes leave a marker in the image and systemd sets $container for anything it starts inside one. This is not a security boundary: it only decides whether offering to install a kernel module can possibly help.
Definition at line 3334 of file confighttp.cpp.
| void confighttp::saveApp | ( | resp_https_t | response, |
| req_https_t | request ) |
Save an application. To save a new application the UUID must be empty. To update an existing application, you must provide the current UUID of the application.
| response | The HTTP response object. |
| request | The HTTP request object. The body for the post request should be JSON serialized in the following format: {
"name": "Application Name",
"output": "Log Output Path",
"cmd": "Command to run the application",
"exclude-global-prep-cmd": false,
"elevated": false,
"auto-detach": true,
"wait-all": true,
"exit-timeout": 5,
"prep-cmd": [
{
"do": "Command to prepare",
"undo": "Command to undo preparation",
"elevated": false
}
],
"detached": [
"Detached command"
],
"image-path": "Full path to the application image. Must be a png file.",
"uuid": "aaaa-bbbb"
}
|
Definition at line 1252 of file confighttp.cpp.
| void confighttp::saveConfig | ( | resp_https_t | response, |
| req_https_t | request ) |
Save the configuration settings.
| response | The HTTP response object. |
| request | The HTTP request object. The body for the post request should be JSON serialized in the following format: {
"key": "value"
}
|
Definition at line 3295 of file confighttp.cpp.
| void confighttp::savePassword | ( | resp_https_t | response, |
| req_https_t | request ) |
Update existing credentials.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
@api_examples{/api/password| POST| {"currentUsername":"admin","currentPassword":"admin","newUsername":"admin","newPassword":"admin","confirmNewPassword":"admin"}}
Definition at line 3782 of file confighttp.cpp.
| void confighttp::savePin | ( | resp_https_t | response, |
| req_https_t | request ) |
Send a PIN code to the host.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
@api_examples{/api/pin| POST| {"pin":"1234","name":"My PC"}}
Definition at line 3886 of file confighttp.cpp.
| void confighttp::send_diagnostic_report | ( | resp_https_t | response | ) |
Definition at line 3158 of file confighttp.cpp.
| void confighttp::send_hestia_error | ( | resp_https_t | response, |
| SimpleWeb::StatusCode | status, | ||
| const char * | code, | ||
| const char * | message ) |
Definition at line 1746 of file confighttp.cpp.
| void confighttp::send_redirect | ( | resp_https_t | response, |
| req_https_t | request, | ||
| const char * | path ) |
Send a redirect response.
| response | The HTTP response object. |
| request | The HTTP request object. |
| path | The path to redirect to. |
Definition at line 665 of file confighttp.cpp.
| void confighttp::send_response | ( | resp_https_t | response, |
| const nlohmann::json & | output_tree ) |
Send a response.
| response | The HTTP response object. |
| output_tree | The JSON tree to send. |
Definition at line 630 of file confighttp.cpp.
| void confighttp::send_unauthorized | ( | resp_https_t | response, |
| req_https_t | request ) |
Send a 401 Unauthorized response.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 643 of file confighttp.cpp.
| void confighttp::send_web_page | ( | resp_https_t | response, |
| req_https_t | request, | ||
| const std::string & | page, | ||
| const SimpleWeb::CaseInsensitiveMultimap & | extra_headers = {} ) |
Serve a page from the packaged web assets.
| response | The HTTP response object. |
| request | The HTTP request object. |
| page | The file name under the web asset directory. |
| extra_headers | Response headers to add on top of the common set. |
A missing asset used to be served as an empty 200: read_file() returns an empty string and only says so at debug level, so the browser rendered a blank page and the log held nothing to explain it. That is what a build or package with the wrong HERMES_ASSETS_DIR looks like from the outside, and it is indistinguishable from the UI itself being broken. Fail loudly with the path we actually looked at instead.
Definition at line 850 of file confighttp.cpp.
| void confighttp::set_hestia_clipboard | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 3186 of file confighttp.cpp.
| void confighttp::start | ( | ) |
Start the HTTPS server.
Definition at line 4137 of file confighttp.cpp.
| void confighttp::stop_hestia_session | ( | resp_https_t | response, |
| req_https_t | request ) |
Definition at line 1974 of file confighttp.cpp.
| void confighttp::terminateSession | ( | resp_https_t | response, |
| req_https_t | request ) |
End one isolated session.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
The stream is stopped first where there is one, so the client is told the session ended rather than being left holding a stream into a desktop that is being torn down underneath it. Ending a session does not unpair the client and does not remove its account or its files: it may connect again and get the same session back.
Definition at line 3592 of file confighttp.cpp.
| bool confighttp::token_matches | ( | std::string_view | presented, |
| std::string_view | expected ) |
Compare in constant time, so a wrong token cannot be found byte by byte.
Definition at line 233 of file confighttp.cpp.
| void confighttp::unpair | ( | resp_https_t | response, |
| req_https_t | request ) |
Unpair a client.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
Definition at line 1572 of file confighttp.cpp.
| void confighttp::unpairAll | ( | resp_https_t | response, |
| req_https_t | request ) |
Unpair all clients.
| response | The HTTP response object. |
| request | The HTTP request object. |
Definition at line 1600 of file confighttp.cpp.
| void confighttp::updateClient | ( | resp_https_t | response, |
| req_https_t | request ) |
Update client information.
| response | The HTTP response object. |
| request | The HTTP request object. |
The body for the POST request should be JSON serialized in the following format:
Definition at line 1519 of file confighttp.cpp.
| void confighttp::uploadCover | ( | resp_https_t | response, |
| req_https_t | request ) |
Upload a cover image.
| response | The HTTP response object. |
| request | The HTTP request object. |
@api_examples{/api/covers/upload| POST| {"key":"igdb_1234","url":"https://images.igdb.com/igdb/image/upload/t_cover_big_2x/abc123.png"}}
Definition at line 3699 of file confighttp.cpp.
| bool confighttp::validate_hestia_session_prepare | ( | const nlohmann::json & | request, |
| std::string & | error ) |
Definition at line 1808 of file confighttp.cpp.
| bool confighttp::validateContentType | ( | resp_https_t | response, |
| req_https_t | request, | ||
| const std::string_view & | contentType ) |
Validate the request content type and send bad request when mismatch.
| response | The HTTP response object. |
| request | The HTTP request object. |
| contentType | The required content type. |
Definition at line 808 of file confighttp.cpp.
| void confighttp::write_local_api_token | ( | ) |
Definition at line 244 of file confighttp.cpp.
| std::string confighttp::localApiToken |
A bearer token any local process of this user may present.
The Game Mode console has no keyboard to log in with, and a controller is the wrong instrument for a password. It does not need one: it runs as the same user as Hermes, on the same machine, and that user can already read Hermes' credentials file, write its config and ptrace the process. A token readable only by that uid therefore grants nothing that was not already available - it is a convenience over a boundary that does not exist, not a hole in one that does.
It lives in the runtime directory, which is tmpfs and mode 0700, so it is gone at reboot and unreadable by other users. It is not a substitute for logging in from a browser: a request carrying it still has to come from this machine or a private/local network, and it is never handed out over HTTP. WAN token authentication stays disabled even when password/cookie login is explicitly enabled from WAN.
Definition at line 221 of file confighttp.cpp.
| std::filesystem::path confighttp::localApiTokenPath |
Definition at line 222 of file confighttp.cpp.
| std::string confighttp::sessionCookie |
Definition at line 200 of file confighttp.cpp.