mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-30 16:41:00 +03:00
unlock with PIN (#8977)
* add custom password to unlock settings * If not set, use admin password; if set, use custom settings password. * At least 4 characters. * Set with gui or command line. Signed-off-by: 21pages <sunboeasy@gmail.com> * Update cn.rs --------- Signed-off-by: 21pages <sunboeasy@gmail.com> Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
35
src/ipc.rs
35
src/ipc.rs
@@ -484,6 +484,8 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
};
|
||||
} else if name == "voice-call-input" {
|
||||
value = crate::audio_service::get_voice_call_input_device();
|
||||
} else if name == "unlock-pin" {
|
||||
value = Some(Config::get_unlock_pin());
|
||||
} else {
|
||||
value = None;
|
||||
}
|
||||
@@ -501,6 +503,8 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
Config::set_salt(&value);
|
||||
} else if name == "voice-call-input" {
|
||||
crate::audio_service::set_voice_call_input_device(Some(value), true);
|
||||
} else if name == "unlock-pin" {
|
||||
Config::set_unlock_pin(&value);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -891,6 +895,37 @@ pub fn set_permanent_password(v: String) -> ResultType<()> {
|
||||
set_config("permanent-password", v)
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn set_unlock_pin(v: String, translate: bool) -> ResultType<()> {
|
||||
let v = v.trim().to_owned();
|
||||
let min_len = 4;
|
||||
if !v.is_empty() && v.len() < min_len {
|
||||
let err = if translate {
|
||||
crate::lang::translate(
|
||||
"Requires at least {".to_string() + &format!("{min_len}") + "} characters",
|
||||
)
|
||||
} else {
|
||||
// Sometimes, translated can't show normally in command line
|
||||
format!("Requires at least {} characters", min_len)
|
||||
};
|
||||
bail!(err);
|
||||
}
|
||||
Config::set_unlock_pin(&v);
|
||||
set_config("unlock-pin", v)
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn get_unlock_pin() -> String {
|
||||
if let Ok(Some(v)) = get_config("unlock-pin") {
|
||||
Config::set_unlock_pin(&v);
|
||||
v
|
||||
} else {
|
||||
Config::get_unlock_pin()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_id() -> String {
|
||||
if let Ok(Some(v)) = get_config("id") {
|
||||
// update salt also, so that next time reinstallation not causing first-time auto-login failure
|
||||
|
||||
Reference in New Issue
Block a user