Attempt skipping passwords in mqtt config
This commit is contained in:
9 files changed
+55
-56
No files matched your search
Generated
+6
-6
@@ -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",
|
||||
|
||||
+3
-3
@@ -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 <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
|
||||
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"
|
||||
]
|
||||
]
|
||||
@@ -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 <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -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 <sheepchaan@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -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"] }
|
||||
|
||||
+6
-6
@@ -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<std::path::PathBuf>,
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, Validate, PartialEq, Eq)]
|
||||
|
||||
@@ -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<Mutex<HashSet<String>>>,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
+34
-1
@@ -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)
|
||||
|
||||
+2
-1
@@ -233,7 +233,8 @@ async fn apply_users(rtsp: &NeoRtspServer, curr_users: &HashSet<UserConfig>) ->
|
||||
// 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?;
|
||||
|
||||
Reference in new issue
Block a user