diff --git a/Cargo.lock b/Cargo.lock index 0e1f51c..c02fb57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1550,7 +1550,7 @@ dependencies = [ [[package]] name = "neolink" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" dependencies = [ "anyhow", "async-stream", @@ -1588,7 +1588,7 @@ dependencies = [ [[package]] name = "neolink_core" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" dependencies = [ "aes", "assert_matches", @@ -1598,7 +1598,7 @@ dependencies = [ "crc32fast", "crossbeam-channel", "delegate", - "env_logger 0.11.3", + "env_logger 0.10.2", "futures", "get_if_addrs", "indoc", @@ -1619,12 +1619,12 @@ dependencies = [ [[package]] name = "neolink_decoder" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" dependencies = [ "aes", "anyhow", "cfb-mode", - "env_logger 0.11.3", + "env_logger 0.10.2", "hex-string", "log", "md5", @@ -1952,7 +1952,7 @@ dependencies = [ [[package]] name = "pushnoti" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 04a68c6..58befcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "neolink" description = "A standards-compliant bridge to Reolink IP cameras" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" authors = ["George Hilliard ", "Andrew King "] edition = "2018" license = "AGPL-3.0-or-later" @@ -30,7 +30,7 @@ gstreamer-rtsp-server = { version = "0.23.0", features = ["v1_20"], optional = t heck = "0.5.0" log = { version = "0.4.17", features = [ "release_max_level_debug" ] } md5 = {version = "0.7.0", optional = true} -neolink_core = { path = "crates/core", version = "0.6.3-rc.2" } +neolink_core = { path = "crates/core", version = "0.6.3-rc.3" } once_cell = "1.19.0" quick-xml = { version = "0.36.1", features = ["serialize"] } regex = "1.7.3" @@ -62,4 +62,4 @@ pushnoti = [ "dep:fcm-push-listener", "dep:dirs", "dep:md5" -] \ No newline at end of file +] diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 48fe57f..157584a 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "neolink_core" description = "Core services and structure for Reolink IP cameras" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" authors = ["George Hilliard ", "Andrew King "] edition = "2018" license = "AGPL-3.0-or-later" diff --git a/crates/decoder/Cargo.toml b/crates/decoder/Cargo.toml index 1b8e58e..e36782d 100644 --- a/crates/decoder/Cargo.toml +++ b/crates/decoder/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "neolink_decoder" description = "A cli decoder for the AES encrypted packets" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" authors = ["Andrew King "] edition = "2018" license = "AGPL-3.0-or-later" diff --git a/crates/pushnoti/Cargo.toml b/crates/pushnoti/Cargo.toml index 3b60d26..7d0d128 100644 --- a/crates/pushnoti/Cargo.toml +++ b/crates/pushnoti/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pushnoti" -version = "0.6.3-rc.2" +version = "0.6.3-rc.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -12,7 +12,7 @@ env_logger = "0.10.0" fcm-push-listener = "2.0.1" lazy_static = "1.4.0" log = { version = "0.4.17", features = [ "release_max_level_debug" ] } -neolink_core = { path = "../core", version = "0.6.3-rc.2" } +neolink_core = { path = "../core", version = "0.6.3-rc.3" } regex = "1.8.1" serde = "1.0.163" tokio = { version = "1.28.1", features = ["full"] } diff --git a/src/config.rs b/src/config.rs index d50559b..6ca22ad 100644 --- a/src/config.rs +++ b/src/config.rs @@ -59,13 +59,13 @@ pub(crate) struct MqttServerConfig { pub(crate) port: u16, - #[serde(default)] + #[serde(default, skip_serializing)] pub(crate) credentials: Option<(String, String)>, - #[serde(default)] + #[serde(default, skip_serializing)] pub(crate) ca: Option, - #[serde(default)] + #[serde(default, skip_serializing)] pub(crate) client_auth: Option<(std::path::PathBuf, std::path::PathBuf)>, } @@ -139,7 +139,7 @@ pub(crate) struct CameraConfig { pub(crate) username: String, - #[serde(alias = "pass")] + #[serde(alias = "pass", skip_serializing, default)] pub(crate) password: Option, #[serde(default = "default_stream")] @@ -226,8 +226,8 @@ pub(crate) struct UserConfig { #[serde(alias = "username")] pub(crate) name: String, - #[serde(alias = "password")] - pub(crate) pass: String, + #[serde(alias = "password", skip_serializing, default)] + pub(crate) pass: Option, } #[derive(Debug, Deserialize, Serialize, Clone, Validate, PartialEq, Eq)] diff --git a/src/mqtt/app.rs b/src/mqtt/app.rs deleted file mode 100644 index 18042df..0000000 --- a/src/mqtt/app.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::collections::HashSet; -use std::sync::{Arc, Mutex}; - -// Handles app wide things like aborting all connections -pub(crate) struct App { - aborters: Arc>>, -} - -impl App { - pub(crate) fn new() -> Self { - Self { - aborters: Default::default(), - } - } - - // Abort at a level - // e.g. about camera_event_loop - pub(crate) fn abort(&self, level: &str) { - let mut aborters = self.aborters.lock().unwrap(); - aborters.insert(level.to_string()); - } - - // Checks if any level has aborted - // e.g. app:camera_a::camera_event_loop - // will check if app, camera_a or camera_event_loop has been aborted - pub(crate) fn running(&self, levels: &str) -> bool { - let aborters = self.aborters.lock().unwrap(); - for level in levels.split(':') { - if aborters.contains(&level.to_string()) { - return false; - } - } - true - } -} diff --git a/src/mqtt/mod.rs b/src/mqtt/mod.rs index 014972f..36bf009 100644 --- a/src/mqtt/mod.rs +++ b/src/mqtt/mod.rs @@ -211,7 +211,40 @@ pub(crate) async fn main(_: Opt, reactor: NeoReactor) -> Result<()> { .await?; continue; } - let config = config?; + let curr_config = thread_config.borrow().clone(); + let mut config = config?; + + // Fill in skipped passwords + if let (Some(mqtt), Some(curr_mqtt)) = (config.mqtt.as_mut(), curr_config.mqtt.as_ref()) { + if mqtt.credentials.is_none() { + mqtt.credentials = curr_mqtt.credentials.clone(); + } + if mqtt.ca.is_none() { + mqtt.ca = curr_mqtt.ca.clone(); + } + if mqtt.client_auth.is_none() { + mqtt.client_auth = curr_mqtt.client_auth.clone(); + } + } + for cam in config.cameras.iter_mut() { + let name = cam.name.clone(); + let cur_cam = curr_config.cameras.iter().find(|c| c.name == name); + if let Some(cur_cam) = cur_cam.as_ref() { + if cam.password.is_none() { + cam.password = cur_cam.password.clone(); + } + } + } + for user in config.users.iter_mut() { + let name = user.name.clone(); + let cur_user = curr_config.users.iter().find(|c| c.name == name); + if let Some(cur_user) = cur_user.as_ref() { + if user.pass.is_none() { + user.pass = cur_user.pass.clone(); + } + } + } + // Passwords should now be restored if they were not set let validate = config.validate().with_context(|| { format!("Failed to validate the MQTT {:?} config file", msg.topic) diff --git a/src/rtsp/mod.rs b/src/rtsp/mod.rs index 88d1702..3e262ec 100644 --- a/src/rtsp/mod.rs +++ b/src/rtsp/mod.rs @@ -233,7 +233,8 @@ async fn apply_users(rtsp: &NeoRtspServer, curr_users: &HashSet) -> // Add those missing for user in curr_users.iter() { log::debug!("Adding user {} to rtsp server", user.name); - rtsp.add_user(&user.name, &user.pass).await?; + rtsp.add_user(&user.name, &user.pass.clone().unwrap_or_default()) + .await?; } // Remove unused let rtsp_users = rtsp.get_users().await?;