Add option to disable pairing

This commit is contained in:
Yukino Song
2024-09-14 04:25:36 +08:00
parent cec346003d
commit 2617b17aab
6 changed files with 30 additions and 1 deletions

View File

@@ -441,6 +441,7 @@ namespace config {
sunshine_t sunshine {
false, // hide_tray_controls
true, // enable_pairing
"en", // locale
2, // min_log_level
0, // flags
@@ -1135,6 +1136,7 @@ namespace config {
bool_f(vars, "native_pen_touch", input.native_pen_touch);
bool_f(vars, "hide_tray_controls", sunshine.hide_tray_controls);
bool_f(vars, "enable_pairing", sunshine.enable_pairing);
bool_f(vars, "notify_pre_releases", sunshine.notify_pre_releases);
int port = sunshine.port;

View File

@@ -171,8 +171,10 @@ namespace config {
std::string cmd_val;
bool elevated;
};
struct sunshine_t {
bool hide_tray_controls;
bool enable_pairing;
std::string locale;
int min_log_level;
std::bitset<flag::FLAG_SIZE> flags;

View File

@@ -570,6 +570,13 @@ namespace nvhttp {
response->close_connection_after_response = true;
});
if (!config::sunshine.enable_pairing) {
tree.put("root.<xmlattr>.status_code", 403);
tree.put("root.<xmlattr>.status_message", "Pairing is disabled for this instance");
return;
}
auto args = request->parse_query_string();
if (args.find("uniqueid"s) == std::end(args)) {
tree.put("root.<xmlattr>.status_code", 400);