Fully prevent client commands on input only sessions

This commit is contained in:
Yukino Song
2025-02-05 11:16:27 +08:00
parent 5c36b89103
commit 9c5c90e64b
3 changed files with 14 additions and 2 deletions

View File

@@ -1053,7 +1053,7 @@ namespace nvhttp {
if (!!(named_cert_p->perm & PERM::_all_actions)) { if (!!(named_cert_p->perm & PERM::_all_actions)) {
auto current_appid = proc::proc.running(); auto current_appid = proc::proc.running();
auto input_only_id_int = util::from_view(proc::input_only_app_id); auto input_only_id_int = util::from_view(proc::input_only_app_id);
auto should_hide_inactive_apps = config::input.enable_input_only_mode && rtsp_stream::session_count() != 0 && current_appid != input_only_id_int; auto should_hide_inactive_apps = config::input.enable_input_only_mode && current_appid > 0 && current_appid != input_only_id_int;
for (auto &app : proc::proc.get_apps()) { for (auto &app : proc::proc.get_apps()) {
auto appid = util::from_view(app.id); auto appid = util::from_view(app.id);
if (should_hide_inactive_apps && appid != current_appid && appid != input_only_id_int) { if (should_hide_inactive_apps && appid != current_appid && appid != input_only_id_int) {
@@ -1161,6 +1161,9 @@ namespace nvhttp {
if (is_input_only) { if (is_input_only) {
BOOST_LOG(info) << "Launching input only session..."sv; BOOST_LOG(info) << "Launching input only session..."sv;
launch_session->client_do_cmds.clear();
launch_session->client_undo_cmds.clear();
// Still probe encoders once, if input only session is launched first // Still probe encoders once, if input only session is launched first
// But we're ignoring if it's successful or not // But we're ignoring if it's successful or not
if (rtsp_stream::session_count() == 0 && !proc::proc.virtual_display) { if (rtsp_stream::session_count() == 0 && !proc::proc.virtual_display) {

View File

@@ -163,7 +163,13 @@ namespace proc {
void void
proc_t::launch_input_only() { proc_t::launch_input_only() {
_app_id = util::from_view(input_only_app_id); _app_id = util::from_view(input_only_app_id);
_app_name = "Input Only";
allow_client_commands = false;
placebo = true; placebo = true;
#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1
system_tray::update_tray_playing(_app_name);
#endif
} }
int int
@@ -178,6 +184,7 @@ namespace proc {
_app = app; _app = app;
_app_id = app_id; _app_id = app_id;
_app_name = app.name;
_launch_session = launch_session; _launch_session = launch_session;
allow_client_commands = app.allow_client_commands; allow_client_commands = app.allow_client_commands;
@@ -607,6 +614,7 @@ namespace proc {
} }
_app_id = -1; _app_id = -1;
_app_name.clear();
display_name.clear(); display_name.clear();
initial_display.clear(); initial_display.clear();
_launch_session.reset(); _launch_session.reset();
@@ -639,7 +647,7 @@ namespace proc {
std::string std::string
proc_t::get_last_run_app_name() { proc_t::get_last_run_app_name() {
return _app.name; return _app_name;
} }
boost::process::environment boost::process::environment

View File

@@ -125,6 +125,7 @@ namespace proc {
private: private:
int _app_id; int _app_id;
std::string _app_name;
boost::process::v1::environment _env; boost::process::v1::environment _env;