Skip to content

Commit

Permalink
Add option to disable pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Sep 13, 2024
1 parent cec3460 commit 2617b17
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ namespace config {

sunshine_t sunshine {
false, // hide_tray_controls
true, // enable_pairing
"en", // locale
2, // min_log_level
0, // flags
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/nvhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 15 additions & 1 deletion src_assets/common/assets/web/configs/tabs/General.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
const props = defineProps({
platform: String,
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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"/>
Expand Down
2 changes: 2 additions & 0 deletions src_assets/common/assets/web/public/assets/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src_assets/common/assets/web/public/assets/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "软件",
Expand Down

0 comments on commit 2617b17

Please sign in to comment.