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);

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
const props = defineProps({
platform: String,
@@ -34,6 +34,13 @@ function addCmd(cmdArr, template) {
function removeCmd(cmdArr, index) {
cmdArr.splice(index,1)
}
onMounted(() => {
// Set default value for enable_pairing if not present
if (config.value.enable_pairing === undefined) {
config.value.enable_pairing = "enabled"
}
})
</script>
<template>
@@ -187,6 +194,13 @@ function removeCmd(cmdArr, index) {
</button>
</div>
<!-- Enable Pairing -->
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="enable_pairing" v-model="config.enable_pairing" true-value="enabled" false-value="disabled"/>
<label for="enable_pairing" class="form-check-label">{{ $t('config.enable_pairing') }}</label>
<div class="form-text">{{ $t('config.enable_pairing_desc') }}</div>
</div>
<!-- Hide Tray Controls -->
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="hide_tray_controls" v-model="config.hide_tray_controls" true-value="enabled" false-value="disabled"/>

View File

@@ -170,6 +170,8 @@
"credentials_file_desc": "Store Username/Password separately from Apollo's state file.",
"ds4_back_as_touchpad_click": "Map Back/Select to Touchpad Click",
"ds4_back_as_touchpad_click_desc": "When forcing DS4 emulation, map Back/Select to Touchpad Click",
"enable_pairing": "Enable Pairing",
"enable_pairing_desc": "Enable pairing for the Moonlight client. This allows the client to authenticate with the host and establish a secure connection.",
"encoder": "Force a Specific Encoder",
"encoder_desc": "Force a specific encoder, otherwise Apollo will select the best available option. Note: If you specify a hardware encoder on Windows, it must match the GPU where the display is connected.",
"encoder_software": "Software",

View File

@@ -168,6 +168,8 @@
"credentials_file_desc": "将用户名/密码与 Apollo 的状态文件分开保存。",
"ds4_back_as_touchpad_click": "映射回/选择触摸板点击",
"ds4_back_as_touchpad_click_desc": "强制使用 DS4 模拟时,将“返回”/“选择”映射到触摸板点击",
"enable_pairing": "启用配对",
"enable_pairing_desc": "启用 Moonlight 客户端的配对。这允许客户端与主机进行身份验证并建立安全连接。",
"encoder": "强制指定编码器",
"encoder_desc": "强制指定一个特定编码器,否则 Apollo 将选择最佳可用选项。注意:如果您在 Windows 上指定了硬件编码器,它必须匹配连接显示器的 GPU。",
"encoder_software": "软件",