Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
confighttp.h File Reference

Declarations for the Web UI Config HTTP server. More...

#include <functional>
#include <chrono>
#include <string>
#include <unordered_map>
#include <string_view>
#include <nlohmann/json.hpp>
#include "thread_safe.h"
Include dependency graph for confighttp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WEB_DIR   HERMES_ASSETS_DIR "/web/"

Functions

void confighttp::start ()
 Start the HTTPS server.
nlohmann::json confighttp::hestia_preflight_json ()
 Aggregate "is the host ready to stream?" checks.
nlohmann::json confighttp::hestia_capabilities_json ()
 The Hestia extension capabilities document.
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.
bool confighttp::local_api_token_origin_allowed (std::string_view address)
 Whether an address may authenticate with the Game Mode local token.

Variables

constexpr auto confighttp::PORT_HTTPS = 1
constexpr auto confighttp::SESSION_EXPIRE_DURATION = 24h * 15
const std::map< std::string, std::string > mime_types

Detailed Description

Declarations for the Web UI Config HTTP server.

Definition in file confighttp.h.

Macro Definition Documentation

◆ WEB_DIR

#define WEB_DIR   HERMES_ASSETS_DIR "/web/"

Definition at line 20 of file confighttp.h.

Function Documentation

◆ computed_config_json()

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.

Parameters
responseThe HTTP response object.
requestThe 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.

◆ hestia_capabilities_json()

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.

◆ hestia_preflight_json()

nlohmann::json confighttp::hestia_preflight_json ( )

Aggregate "is the host ready to stream?" checks.

Returns
{ready: bool, checks: [{id, status: ok|warn|fail, message}]}. ready is false only when at least one check fails (warnings, such as a software-encoding fallback, do not block).

Definition at line 2283 of file confighttp.cpp.

◆ local_api_token_origin_allowed()

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.

◆ overlay_config_file()

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.

Returns
response, for chaining.

Definition at line 1637 of file confighttp.cpp.

◆ start()

void confighttp::start ( )

Start the HTTPS server.

Definition at line 4137 of file confighttp.cpp.

Variable Documentation

◆ mime_types

const std::map<std::string, std::string> mime_types
Initial value:
= {
{"css", "text/css"},
{"gif", "image/gif"},
{"htm", "text/html"},
{"html", "text/html"},
{"ico", "image/x-icon"},
{"jpeg", "image/jpeg"},
{"jpg", "image/jpeg"},
{"js", "application/javascript"},
{"json", "application/json"},
{"png", "image/png"},
{"svg", "image/svg+xml"},
{"ttf", "font/ttf"},
{"txt", "text/plain"},
{"woff2", "font/woff2"},
{"xml", "text/xml"},
}

Definition at line 77 of file confighttp.h.

◆ PORT_HTTPS

auto confighttp::PORT_HTTPS = 1
constexpr

Definition at line 25 of file confighttp.h.

◆ SESSION_EXPIRE_DURATION

auto confighttp::SESSION_EXPIRE_DURATION = 24h * 15
constexpr

Definition at line 26 of file confighttp.h.