Skip to content

Commit 5fc9bc2

Browse files
Attempt skipping passwords in mqtt config
1 parent 7158943 commit 5fc9bc2

File tree

9 files changed

+55
-56
lines changed

9 files changed

+55
-56
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "neolink"
33
description = "A standards-compliant bridge to Reolink IP cameras"
4-
version = "0.6.3-rc.2"
4+
version = "0.6.3-rc.3"
55
authors = ["George Hilliard <[email protected]>", "Andrew King <[email protected]>"]
66
edition = "2018"
77
license = "AGPL-3.0-or-later"
@@ -30,7 +30,7 @@ gstreamer-rtsp-server = { version = "0.23.0", features = ["v1_20"], optional = t
3030
heck = "0.5.0"
3131
log = { version = "0.4.17", features = [ "release_max_level_debug" ] }
3232
md5 = {version = "0.7.0", optional = true}
33-
neolink_core = { path = "crates/core", version = "0.6.3-rc.2" }
33+
neolink_core = { path = "crates/core", version = "0.6.3-rc.3" }
3434
once_cell = "1.19.0"
3535
quick-xml = { version = "0.36.1", features = ["serialize"] }
3636
regex = "1.7.3"
@@ -62,4 +62,4 @@ pushnoti = [
6262
"dep:fcm-push-listener",
6363
"dep:dirs",
6464
"dep:md5"
65-
]
65+
]

crates/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "neolink_core"
33
description = "Core services and structure for Reolink IP cameras"
4-
version = "0.6.3-rc.2"
4+
version = "0.6.3-rc.3"
55
authors = ["George Hilliard <[email protected]>", "Andrew King <[email protected]>"]
66
edition = "2018"
77
license = "AGPL-3.0-or-later"

crates/decoder/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "neolink_decoder"
33
description = "A cli decoder for the AES encrypted packets"
4-
version = "0.6.3-rc.2"
4+
version = "0.6.3-rc.3"
55
authors = ["Andrew King <[email protected]>"]
66
edition = "2018"
77
license = "AGPL-3.0-or-later"

crates/pushnoti/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pushnoti"
3-
version = "0.6.3-rc.2"
3+
version = "0.6.3-rc.3"
44
edition = "2021"
55

66
# 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"
1212
fcm-push-listener = "2.0.1"
1313
lazy_static = "1.4.0"
1414
log = { version = "0.4.17", features = [ "release_max_level_debug" ] }
15-
neolink_core = { path = "../core", version = "0.6.3-rc.2" }
15+
neolink_core = { path = "../core", version = "0.6.3-rc.3" }
1616
regex = "1.8.1"
1717
serde = "1.0.163"
1818
tokio = { version = "1.28.1", features = ["full"] }

src/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ pub(crate) struct MqttServerConfig {
5959

6060
pub(crate) port: u16,
6161

62-
#[serde(default)]
62+
#[serde(default, skip_serializing)]
6363
pub(crate) credentials: Option<(String, String)>,
6464

65-
#[serde(default)]
65+
#[serde(default, skip_serializing)]
6666
pub(crate) ca: Option<std::path::PathBuf>,
6767

68-
#[serde(default)]
68+
#[serde(default, skip_serializing)]
6969
pub(crate) client_auth: Option<(std::path::PathBuf, std::path::PathBuf)>,
7070
}
7171

@@ -139,7 +139,7 @@ pub(crate) struct CameraConfig {
139139

140140
pub(crate) username: String,
141141

142-
#[serde(alias = "pass")]
142+
#[serde(alias = "pass", skip_serializing, default)]
143143
pub(crate) password: Option<String>,
144144

145145
#[serde(default = "default_stream")]
@@ -226,8 +226,8 @@ pub(crate) struct UserConfig {
226226
#[serde(alias = "username")]
227227
pub(crate) name: String,
228228

229-
#[serde(alias = "password")]
230-
pub(crate) pass: String,
229+
#[serde(alias = "password", skip_serializing, default)]
230+
pub(crate) pass: Option<String>,
231231
}
232232

233233
#[derive(Debug, Deserialize, Serialize, Clone, Validate, PartialEq, Eq)]

src/mqtt/app.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/mqtt/mod.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,40 @@ pub(crate) async fn main(_: Opt, reactor: NeoReactor) -> Result<()> {
211211
.await?;
212212
continue;
213213
}
214-
let config = config?;
214+
let curr_config = thread_config.borrow().clone();
215+
let mut config = config?;
216+
217+
// Fill in skipped passwords
218+
if let (Some(mqtt), Some(curr_mqtt)) = (config.mqtt.as_mut(), curr_config.mqtt.as_ref()) {
219+
if mqtt.credentials.is_none() {
220+
mqtt.credentials = curr_mqtt.credentials.clone();
221+
}
222+
if mqtt.ca.is_none() {
223+
mqtt.ca = curr_mqtt.ca.clone();
224+
}
225+
if mqtt.client_auth.is_none() {
226+
mqtt.client_auth = curr_mqtt.client_auth.clone();
227+
}
228+
}
229+
for cam in config.cameras.iter_mut() {
230+
let name = cam.name.clone();
231+
let cur_cam = curr_config.cameras.iter().find(|c| c.name == name);
232+
if let Some(cur_cam) = cur_cam.as_ref() {
233+
if cam.password.is_none() {
234+
cam.password = cur_cam.password.clone();
235+
}
236+
}
237+
}
238+
for user in config.users.iter_mut() {
239+
let name = user.name.clone();
240+
let cur_user = curr_config.users.iter().find(|c| c.name == name);
241+
if let Some(cur_user) = cur_user.as_ref() {
242+
if user.pass.is_none() {
243+
user.pass = cur_user.pass.clone();
244+
}
245+
}
246+
}
247+
// Passwords should now be restored if they were not set
215248

216249
let validate = config.validate().with_context(|| {
217250
format!("Failed to validate the MQTT {:?} config file", msg.topic)

src/rtsp/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ async fn apply_users(rtsp: &NeoRtspServer, curr_users: &HashSet<UserConfig>) ->
233233
// Add those missing
234234
for user in curr_users.iter() {
235235
log::debug!("Adding user {} to rtsp server", user.name);
236-
rtsp.add_user(&user.name, &user.pass).await?;
236+
rtsp.add_user(&user.name, &user.pass.clone().unwrap_or_default())
237+
.await?;
237238
}
238239
// Remove unused
239240
let rtsp_users = rtsp.get_users().await?;

0 commit comments

Comments
 (0)