Add option to enable/disable client commands per-app

This commit is contained in:
Yukino Song
2025-01-23 01:51:17 +08:00
parent d5f81773a8
commit 5aaeb70722
6 changed files with 36 additions and 5 deletions

View File

@@ -1148,6 +1148,11 @@ namespace nvhttp {
return;
}
if (!app_iter->allow_client_commands) {
launch_session->client_do_cmds.clear();
launch_session->client_undo_cmds.clear();
}
auto err = proc::proc.execute(appid, *app_iter, launch_session);
if (err) {
tree.put("root.<xmlattr>.status_code", err);
@@ -1224,6 +1229,11 @@ namespace nvhttp {
}
auto launch_session = make_launch_session(host_audio, 0, args, named_cert_p);
if (!proc::proc.allow_client_commands) {
launch_session->client_do_cmds.clear();
launch_session->client_undo_cmds.clear();
}
if (no_active_sessions && !proc::proc.virtual_display) {
// We want to prepare display only if there are no active sessions
// and the current session isn't virtual display at the moment.

View File

@@ -166,6 +166,7 @@ namespace proc {
_app = app;
_app_id = app_id;
_launch_session = launch_session;
allow_client_commands = app.allow_client_commands;
uint32_t client_width = launch_session->width ? launch_session->width : 1920;
uint32_t client_height = launch_session->height ? launch_session->height : 1080;
@@ -409,7 +410,7 @@ namespace proc {
} else {
auto currentDisplayW = platf::from_utf8(currentDisplay).c_str();
this->initial_hdr = VDISPLAY::getDisplayHDRByName(currentDisplayW);
bool initial_hdr = VDISPLAY::getDisplayHDRByName(currentDisplayW);
if (config::video.dd.hdr_option == config::video_t::dd_t::hdr_option_e::automatic) {
if (!VDISPLAY::setDisplayHDRByName(currentDisplayW, false)) {
@@ -423,7 +424,7 @@ namespace proc {
BOOST_LOG(info) << "HDR enable failed for display " << currentDisplay;
}
}
} else if (this->initial_hdr) {
} else if (initial_hdr) {
if (VDISPLAY::setDisplayHDRByName(currentDisplayW, false) && VDISPLAY::setDisplayHDRByName(currentDisplayW, true)) {
BOOST_LOG(info) << "HDR toggled successfully for display " << currentDisplay;
} else {
@@ -566,10 +567,10 @@ namespace proc {
_app_id = -1;
display_name.clear();
initial_hdr = false;
initial_display.clear();
_launch_session.reset();
virtual_display = false;
allow_client_commands = false;
}
const std::vector<ctx_t> &
@@ -912,6 +913,7 @@ namespace proc {
auto virtual_display = app_node.get_optional<bool>("virtual-display"s);
auto resolution_scale_factor = app_node.get_optional<int>("scale-factor"s);
auto use_app_identity = app_node.get_optional<bool>("use-app-identity"s);
auto allow_client_commands = app_node.get_optional<bool>("allow-client-commands");
ctx.uuid = app_uuid.value();
@@ -986,6 +988,7 @@ namespace proc {
ctx.virtual_display = virtual_display.value_or(false);
ctx.scale_factor = resolution_scale_factor.value_or(100);
ctx.use_app_identity = use_app_identity.value_or(false);
ctx.allow_client_commands = allow_client_commands.value_or(true);
auto possible_ids = calculate_app_id(name, ctx.image_path, i++);
if (ids.count(std::get<0>(possible_ids)) == 0) {

View File

@@ -73,6 +73,7 @@ namespace proc {
bool virtual_display;
bool virtual_display_primary;
bool use_app_identity;
bool allow_client_commands;
int scale_factor;
std::chrono::seconds exit_timeout;
};
@@ -84,7 +85,7 @@ namespace proc {
std::string display_name;
std::string initial_display;
bool virtual_display;
bool initial_hdr;
bool allow_client_commands;
proc_t(

View File

@@ -150,6 +150,14 @@
v-model="editForm['image-path']" />
<div id="appImagePathHelp" class="form-text">{{ $t('apps.image_desc') }}</div>
</div>
<!-- allow client commands -->
<Checkbox class="mb-3"
id="clientCommands"
label="apps.allow_client_commands"
desc="apps.allow_client_commands_desc"
v-model="editForm['allow-client-commands']"
default="true"
></Checkbox>
<!-- prep-cmd -->
<Checkbox class="mb-3"
id="excludeGlobalPrep"
@@ -409,7 +417,8 @@
detached: [],
"image-path": "",
"scale-factor": "100",
"use-app-identity": false
"use-app-identity": false,
"allow-client-commands": true,
}
const app = createApp({

View File

@@ -32,6 +32,8 @@
"actions": "Actions",
"add_cmds": "Add Commands",
"add_new": "Add New",
"allow_client_commands": "Allow client prepare commands",
"allow_client_commands_desc": "Whether to execute client prepare commands when running this app.",
"app_name": "Application Name",
"app_name_desc": "Application Name, as shown on Moonlight",
"applications_desc": "Applications are refreshed only when Client is restarted",

View File

@@ -32,6 +32,8 @@
"actions": "操作",
"add_cmds": "添加命令",
"add_new": "添加新应用",
"allow_client_commands": "允许客户端准备命令",
"allow_client_commands_desc": "在此APP运行时是否允许执行客户端准备命令",
"app_name": "应用名称",
"app_name_desc": "在 Moonlight 显示的应用名称",
"applications_desc": "只有重启客户端时应用列表才会被刷新",
@@ -165,6 +167,10 @@
"channels": "最多同时连接客户端数",
"channels_desc_1": "Apollo 允许多个客户端同时共享一个串流会话。",
"channels_desc_2": "某些硬件编码器可能存在限制,在编码多条流时会降低性能。",
"client_do_cmd": "客户端连入命令",
"client_do_cmd_desc": "当此客户端连接时执行的命令。所有命令都以后台模式允许。",
"client_undo_cmd": "客户端断开命令",
"client_undo_cmd_desc": "当此客户端断开连接时执行的命令。所有命令都以后台模式允许。",
"coder_cabac": "cabac -- 上下文自适应二进制算术编码- 较高质量",
"coder_cavlc": "cavlc -- 上下文适应变量编码 - 更快解码",
"configuration": "配置",