server IPC key

This commit is contained in:
Vladimir Borisov 2026-02-02 14:54:41 +02:00
parent f1aeb06c0f
commit 07d821012d
No known key found for this signature in database
GPG key ID: F9A584BE4FCB6603
4 changed files with 27 additions and 3 deletions

View file

@ -39,7 +39,7 @@ sha2 = "0.10"
reqwest = { version = "0.12", features = ["stream", "json", "blocking"] }
rand = "0.8"
url = { version = "2", features = ["serde"] }
uuid = { version = "1.19", features = ["v4"]}
[build-dependencies]
winres = "0.1"

View file

@ -9,7 +9,9 @@ use clap::Parser;
use native_windows_gui::{self as nwg, NativeUi};
mod stremio_app;
use crate::stremio_app::{
constants::{DEV_ENDPOINT, IPC_PATH, STA_ENDPOINT, STREMIO_SERVER_DEV_MODE, WEB_ENDPOINT},
constants::{
DEV_ENDPOINT, IPC_PATH, SERVER_IPC_KEY, STA_ENDPOINT, STREMIO_SERVER_DEV_MODE, WEB_ENDPOINT,
},
MainWindow, PipeClient,
};
@ -38,6 +40,12 @@ struct Opt {
force_update: bool,
#[clap(long, help = "Check for RC updates")]
release_candidate: bool,
#[clap(
long,
default_value = "",
help = "Secret key for communication with the server. By default it is randomly generrated on startup"
)]
server_ipc_key: String,
}
fn main() {
@ -54,6 +62,15 @@ fn main() {
let opt = Opt::parse();
std::env::set_var(
SERVER_IPC_KEY,
if opt.server_ipc_key.is_empty() {
uuid::Uuid::new_v4().to_string()
} else {
opt.server_ipc_key.clone()
},
);
let command = match opt.command {
Some(file) => {
if Path::new(&file).exists() {

View file

@ -13,4 +13,5 @@ pub const UPDATE_ENDPOINT: [&str; 3] = [
];
pub const STREMIO_SERVER_DEV_MODE: &str = "STREMIO_SERVER_DEV_MODE";
pub const SRV_BUFFER_SIZE: usize = 1024;
pub const SERVER_IPC_KEY: &str = "SERVER_IPC_KEY";
pub const SRV_LOG_SIZE: usize = 20;

View file

@ -15,7 +15,7 @@ use webview2::Controller;
use winapi::shared::windef::HWND;
use winapi::um::winuser::{GetClientRect, VK_F7, WM_SETFOCUS};
use super::constants::{WARNING_URL, WHITELISTED_HOSTS};
use super::constants::{SERVER_IPC_KEY, WARNING_URL, WHITELISTED_HOSTS};
#[derive(Default)]
pub struct WebView {
@ -153,6 +153,12 @@ impl PartialUi for WebView {
}).expect("Cannot add full screen element changed");
webview.add_content_loading(move |wv, _| {
wv.execute_script(format!(
"window.stremio_server_ipc_key='{}'",
std::env::var(SERVER_IPC_KEY).unwrap_or_default()
), |_| Ok(())
).expect("Cannot add SERVER_IPC_KEY to webview");
wv.execute_script(r##"
try{
/* Disable context menus */