Merge pull request #473 from 21pages/disable-change-permanent-password

add options: disable-change-permanent-password, disable-change-id, disable-unlock-pin
This commit is contained in:
RustDesk
2026-01-05 22:19:50 +08:00
committed by GitHub

View File

@@ -1001,6 +1001,33 @@ impl Config {
.unwrap_or(false) .unwrap_or(false)
} }
pub fn is_disable_change_permanent_password() -> bool {
BUILTIN_SETTINGS
.read()
.unwrap()
.get(keys::OPTION_DISABLE_CHANGE_PERMANENT_PASSWORD)
.map(|v| v == "Y")
.unwrap_or(false)
}
pub fn is_disable_change_id() -> bool {
BUILTIN_SETTINGS
.read()
.unwrap()
.get(keys::OPTION_DISABLE_CHANGE_ID)
.map(|v| v == "Y")
.unwrap_or(false)
}
pub fn is_disable_unlock_pin() -> bool {
BUILTIN_SETTINGS
.read()
.unwrap()
.get(keys::OPTION_DISABLE_UNLOCK_PIN)
.map(|v| v == "Y")
.unwrap_or(false)
}
pub fn get_id() -> String { pub fn get_id() -> String {
let mut id = CONFIG.read().unwrap().id.clone(); let mut id = CONFIG.read().unwrap().id.clone();
if id.is_empty() { if id.is_empty() {
@@ -1087,6 +1114,9 @@ impl Config {
} }
pub fn set_permanent_password(password: &str) { pub fn set_permanent_password(password: &str) {
if Self::is_disable_change_permanent_password() {
return;
}
if HARD_SETTINGS if HARD_SETTINGS
.read() .read()
.unwrap() .unwrap()
@@ -1235,10 +1265,16 @@ impl Config {
} }
pub fn get_unlock_pin() -> String { pub fn get_unlock_pin() -> String {
if Self::is_disable_unlock_pin() {
return String::new();
}
CONFIG2.read().unwrap().unlock_pin.clone() CONFIG2.read().unwrap().unlock_pin.clone()
} }
pub fn set_unlock_pin(pin: &str) { pub fn set_unlock_pin(pin: &str) {
if Self::is_disable_unlock_pin() {
return;
}
let mut config = CONFIG2.write().unwrap(); let mut config = CONFIG2.write().unwrap();
if pin == config.unlock_pin { if pin == config.unlock_pin {
return; return;
@@ -2619,6 +2655,9 @@ pub mod keys {
pub const OPTION_ALLOW_HOSTNAME_AS_ID: &str = "allow-hostname-as-id"; pub const OPTION_ALLOW_HOSTNAME_AS_ID: &str = "allow-hostname-as-id";
pub const OPTION_HIDE_POWERED_BY_ME: &str = "hide-powered-by-me"; pub const OPTION_HIDE_POWERED_BY_ME: &str = "hide-powered-by-me";
pub const OPTION_MAIN_WINDOW_ALWAYS_ON_TOP: &str = "main-window-always-on-top"; pub const OPTION_MAIN_WINDOW_ALWAYS_ON_TOP: &str = "main-window-always-on-top";
pub const OPTION_DISABLE_CHANGE_PERMANENT_PASSWORD: &str = "disable-change-permanent-password";
pub const OPTION_DISABLE_CHANGE_ID: &str = "disable-change-id";
pub const OPTION_DISABLE_UNLOCK_PIN: &str = "disable-unlock-pin";
// flutter local options // flutter local options
pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState"; pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState";
@@ -2810,6 +2849,9 @@ pub mod keys {
OPTION_HIDE_POWERED_BY_ME, OPTION_HIDE_POWERED_BY_ME,
OPTION_MAIN_WINDOW_ALWAYS_ON_TOP, OPTION_MAIN_WINDOW_ALWAYS_ON_TOP,
OPTION_FILE_TRANSFER_MAX_FILES, OPTION_FILE_TRANSFER_MAX_FILES,
OPTION_DISABLE_CHANGE_PERMANENT_PASSWORD,
OPTION_DISABLE_CHANGE_ID,
OPTION_DISABLE_UNLOCK_PIN,
]; ];
} }