buildin options and add to mobile (#8759)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-07-19 23:55:52 +08:00 committed by GitHub
parent 85ded0a3e5
commit 2b54a553c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 114 additions and 38 deletions

View File

@ -3319,7 +3319,8 @@ Widget buildPresetPasswordWarning() {
return Text( return Text(
'Error: ${snapshot.error}'); // Show an error message if the Future completed with an error 'Error: ${snapshot.error}'); // Show an error message if the Future completed with an error
} else if (snapshot.hasData && snapshot.data == true) { } else if (snapshot.hasData && snapshot.data == true) {
if (bind.mainGetLocalOption(key: "remove-preset-password-warning") != if (bind.mainGetBuildinOption(
key: kOptionRemovePresetPasswordWarning) !=
'N') { 'N') {
return SizedBox.shrink(); return SizedBox.shrink();
} }

View File

@ -133,7 +133,7 @@ class _PeerCardState extends State<_PeerCard>
Widget _buildPeerTile( Widget _buildPeerTile(
BuildContext context, Peer peer, Rx<BoxDecoration?>? deco) { BuildContext context, Peer peer, Rx<BoxDecoration?>? deco) {
hideUsernameOnCard ??= hideUsernameOnCard ??=
bind.mainGetLocalOption(key: kHideUsernameOnCard) == 'Y'; bind.mainGetBuildinOption(key: kHideUsernameOnCard) == 'Y';
final name = hideUsernameOnCard == true final name = hideUsernameOnCard == true
? peer.hostname ? peer.hostname
: '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}'; : '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}';
@ -245,7 +245,7 @@ class _PeerCardState extends State<_PeerCard>
Widget _buildPeerCard( Widget _buildPeerCard(
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) { BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
hideUsernameOnCard ??= hideUsernameOnCard ??=
bind.mainGetLocalOption(key: kHideUsernameOnCard) == 'Y'; bind.mainGetBuildinOption(key: kHideUsernameOnCard) == 'Y';
final name = hideUsernameOnCard == true final name = hideUsernameOnCard == true
? peer.hostname ? peer.hostname
: '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}'; : '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}';

View File

@ -136,8 +136,16 @@ const String kOptionAllowRemoveWallpaper = "allow-remove-wallpaper";
const String kOptionStopService = "stop-service"; const String kOptionStopService = "stop-service";
const String kOptionDirectxCapture = "enable-directx-capture"; const String kOptionDirectxCapture = "enable-directx-capture";
const String kOptionAllowRemoteCmModification = "allow-remote-cm-modification"; const String kOptionAllowRemoteCmModification = "allow-remote-cm-modification";
// buildin opitons
const String kOptionHideServerSetting = "hide-server-settings"; const String kOptionHideServerSetting = "hide-server-settings";
const String kOptionHideProxySetting = "hide-proxy-settings"; const String kOptionHideProxySetting = "hide-proxy-settings";
const String kOptionHideSecuritySetting = "hide-security-settings";
const String kOptionHideNetworkSetting = "hide-network-settings";
const String kOptionRemovePresetPasswordWarning =
"remove-preset-password-warning";
const kHideUsernameOnCard = "hide-username-on-card";
const String kOptionHideHelpCards = "hide-help-cards";
const String kOptionToggleViewOnly = "view-only"; const String kOptionToggleViewOnly = "view-only";
@ -306,8 +314,6 @@ const kRequestIgnoreBatteryOptimizations =
const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW"; const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW";
const kAndroid13Notification = "android.permission.POST_NOTIFICATIONS"; const kAndroid13Notification = "android.permission.POST_NOTIFICATIONS";
const kHideUsernameOnCard = "hide-username-on-card";
/// Android channel invoke type key /// Android channel invoke type key
class AndroidChannel { class AndroidChannel {
static final kStartAction = "start_action"; static final kStartAction = "start_action";

View File

@ -546,7 +546,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
String? link, String? link,
bool? closeButton, bool? closeButton,
String? closeOption}) { String? closeOption}) {
if (bind.mainGetLocalOption(key: 'hide-help-cards') == 'Y' && if (bind.mainGetBuildinOption(key: kOptionHideHelpCards) == 'Y' &&
content != 'install_daemon_tip') { content != 'install_daemon_tip') {
return const SizedBox(); return const SizedBox();
} }

View File

@ -63,10 +63,10 @@ class DesktopSettingPage extends StatefulWidget {
SettingsTabKey.general, SettingsTabKey.general,
if (!bind.isOutgoingOnly() && if (!bind.isOutgoingOnly() &&
!bind.isDisableSettings() && !bind.isDisableSettings() &&
bind.mainGetLocalOption(key: "hide-security-settings") != 'Y') bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) != 'Y')
SettingsTabKey.safety, SettingsTabKey.safety,
if (!bind.isDisableSettings() && if (!bind.isDisableSettings() &&
bind.mainGetLocalOption(key: "hide-network-settings") != 'Y') bind.mainGetBuildinOption(key: kOptionHideNetworkSetting) != 'Y')
SettingsTabKey.network, SettingsTabKey.network,
if (!bind.isIncomingOnly()) SettingsTabKey.display, if (!bind.isIncomingOnly()) SettingsTabKey.display,
if (!isWeb && !bind.isIncomingOnly() && bind.pluginFeatureIsEnabled()) if (!isWeb && !bind.isIncomingOnly() && bind.pluginFeatureIsEnabled())
@ -1289,9 +1289,9 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
bool enabled = !locked; bool enabled = !locked;
final scrollController = ScrollController(); final scrollController = ScrollController();
final hideServer = final hideServer =
bind.mainGetLocalOption(key: kOptionHideServerSetting) == 'Y'; bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y';
final hideProxy = final hideProxy =
bind.mainGetLocalOption(key: kOptionHideProxySetting) == 'Y'; bind.mainGetBuildinOption(key: kOptionHideProxySetting) == 'Y';
return DesktopScrollWrapper( return DesktopScrollWrapper(
scrollController: scrollController, scrollController: scrollController,
child: ListView( child: ListView(

View File

@ -23,7 +23,22 @@ class ServerPage extends StatefulWidget implements PageShape {
final icon = const Icon(Icons.mobile_screen_share); final icon = const Icon(Icons.mobile_screen_share);
@override @override
final appBarActions = [ final appBarActions = (!bind.isDisableSettings() &&
bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) != 'Y')
? [_DropDownAction()]
: [];
ServerPage({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _ServerPageState();
}
class _DropDownAction extends StatelessWidget {
_DropDownAction();
// should only have one action
final actions = [
PopupMenuButton<String>( PopupMenuButton<String>(
tooltip: "", tooltip: "",
icon: const Icon(Icons.more_vert), icon: const Icon(Icons.more_vert),
@ -136,10 +151,10 @@ class ServerPage extends StatefulWidget implements PageShape {
}) })
]; ];
ServerPage({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _ServerPageState(); Widget build(BuildContext context) {
return actions[0];
}
} }
class _ServerPageState extends State<ServerPage> { class _ServerPageState extends State<ServerPage> {

View File

@ -86,6 +86,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
var _autoDisconnectTimeout = ""; var _autoDisconnectTimeout = "";
var _hideServer = false; var _hideServer = false;
var _hideProxy = false; var _hideProxy = false;
var _hideNetwork = false;
@override @override
void initState() { void initState() {
@ -112,8 +113,11 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
bind.mainGetOptionSync(key: kOptionAllowAutoDisconnect)); bind.mainGetOptionSync(key: kOptionAllowAutoDisconnect));
_autoDisconnectTimeout = _autoDisconnectTimeout =
bind.mainGetOptionSync(key: kOptionAutoDisconnectTimeout); bind.mainGetOptionSync(key: kOptionAutoDisconnectTimeout);
_hideServer = bind.mainGetLocalOption(key: kOptionHideServerSetting) == 'Y'; _hideServer =
_hideProxy = bind.mainGetLocalOption(key: kOptionHideProxySetting) == 'Y'; bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y';
_hideProxy = bind.mainGetBuildinOption(key: kOptionHideProxySetting) == 'Y';
_hideNetwork =
bind.mainGetBuildinOption(key: kOptionHideNetworkSetting) == 'Y';
() async { () async {
var update = false; var update = false;
@ -535,6 +539,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
)); ));
final disabledSettings = bind.isDisableSettings(); final disabledSettings = bind.isDisableSettings();
final hideSecuritySettings =
bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) == 'Y';
final settings = SettingsList( final settings = SettingsList(
sections: [ sections: [
customClientSection, customClientSection,
@ -558,14 +564,14 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
], ],
), ),
SettingsSection(title: Text(translate("Settings")), tiles: [ SettingsSection(title: Text(translate("Settings")), tiles: [
if (!disabledSettings && !_hideServer) if (!disabledSettings && !_hideNetwork && !_hideServer)
SettingsTile( SettingsTile(
title: Text(translate('ID/Relay Server')), title: Text(translate('ID/Relay Server')),
leading: Icon(Icons.cloud), leading: Icon(Icons.cloud),
onPressed: (context) { onPressed: (context) {
showServerSettings(gFFI.dialogManager); showServerSettings(gFFI.dialogManager);
}), }),
if (!isIOS && !_hideProxy) if (!isIOS && !_hideNetwork && !_hideProxy)
SettingsTile( SettingsTile(
title: Text(translate('Socks5/Http(s) Proxy')), title: Text(translate('Socks5/Http(s) Proxy')),
leading: Icon(Icons.network_ping), leading: Icon(Icons.network_ping),
@ -637,13 +643,19 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
), ),
], ],
), ),
if (isAndroid && !disabledSettings && !outgoingOnly) if (isAndroid &&
!disabledSettings &&
!outgoingOnly &&
!hideSecuritySettings)
SettingsSection( SettingsSection(
title: Text(translate("Share Screen")), title: Text(translate("Share Screen")),
tiles: shareScreenTiles, tiles: shareScreenTiles,
), ),
if (!bind.isIncomingOnly()) defaultDisplaySection(), if (!bind.isIncomingOnly()) defaultDisplaySection(),
if (isAndroid && !disabledSettings && !outgoingOnly) if (isAndroid &&
!disabledSettings &&
!outgoingOnly &&
!hideSecuritySettings)
SettingsSection( SettingsSection(
title: Text(translate("Enhancements")), title: Text(translate("Enhancements")),
tiles: enhancementsTiles, tiles: enhancementsTiles,

View File

@ -69,6 +69,7 @@ lazy_static::lazy_static! {
pub static ref DEFAULT_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default(); pub static ref DEFAULT_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
pub static ref OVERWRITE_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default(); pub static ref OVERWRITE_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
pub static ref HARD_SETTINGS: RwLock<HashMap<String, String>> = Default::default(); pub static ref HARD_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
pub static ref BUILDIN_SETTINGS: RwLock<HashMap<String, String>> = Default::default();
} }
lazy_static::lazy_static! { lazy_static::lazy_static! {
@ -2096,12 +2097,22 @@ pub mod keys {
pub const OPTION_KEY: &str = "key"; pub const OPTION_KEY: &str = "key";
pub const OPTION_PRESET_ADDRESS_BOOK_NAME: &str = "preset-address-book-name"; pub const OPTION_PRESET_ADDRESS_BOOK_NAME: &str = "preset-address-book-name";
pub const OPTION_PRESET_ADDRESS_BOOK_TAG: &str = "preset-address-book-tag"; pub const OPTION_PRESET_ADDRESS_BOOK_TAG: &str = "preset-address-book-tag";
pub const OPTION_PRESET_USERNAME: &str = "preset-user-name";
pub const OPTION_PRESET_STRATEGY_NAME: &str = "preset-strategy-name";
pub const OPTION_ENABLE_DIRECTX_CAPTURE: &str = "enable-directx-capture"; pub const OPTION_ENABLE_DIRECTX_CAPTURE: &str = "enable-directx-capture";
pub const OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE: &str = pub const OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE: &str =
"enable-android-software-encoding-half-scale"; "enable-android-software-encoding-half-scale";
// buildin options
pub const OPTION_DISPLAY_NAME: &str = "display-name";
pub const OPTION_DISABLE_UDP: &str = "disable-udp"; pub const OPTION_DISABLE_UDP: &str = "disable-udp";
pub const OPTION_PRESET_USERNAME: &str = "preset-user-name";
pub const OPTION_PRESET_STRATEGY_NAME: &str = "preset-strategy-name";
pub const OPTION_REMOVE_PRESET_PASSWORD_WARNING: &str = "remove-preset-password-warning";
pub const OPTION_HIDE_SECURITY_SETTINGS: &str = "hide-security-settings";
pub const OPTION_HIDE_NETWORK_SETTINGS: &str = "hide-network-settings";
pub const OPTION_HIDE_SERVER_SETTINGS: &str = "hide-server-settings";
pub const OPTION_HIDE_PROXY_SETTINGS: &str = "hide-proxy-settings";
pub const OPTION_HIDE_USERNAME_ON_CARD: &str = "hide-username-on-card";
pub const OPTION_HIDE_HELP_CARDS: &str = "hide-help-cards";
// flutter local options // flutter local options
pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState"; pub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState";
@ -2126,8 +2137,6 @@ pub mod keys {
pub const OPTION_DISABLE_GROUP_PANEL: &str = "disable-group-panel"; pub const OPTION_DISABLE_GROUP_PANEL: &str = "disable-group-panel";
pub const OPTION_PRE_ELEVATE_SERVICE: &str = "pre-elevate-service"; pub const OPTION_PRE_ELEVATE_SERVICE: &str = "pre-elevate-service";
pub const OPTION_DISPLAY_NAME: &str = "display-name";
// proxy settings // proxy settings
// The following options are not real keys, they are just used for custom client advanced settings. // The following options are not real keys, they are just used for custom client advanced settings.
// The real keys are in Config2::socks. // The real keys are in Config2::socks.
@ -2191,15 +2200,7 @@ pub mod keys {
OPTION_KEEP_SCREEN_ON, OPTION_KEEP_SCREEN_ON,
OPTION_DISABLE_GROUP_PANEL, OPTION_DISABLE_GROUP_PANEL,
OPTION_PRE_ELEVATE_SERVICE, OPTION_PRE_ELEVATE_SERVICE,
OPTION_DISPLAY_NAME,
"remove-preset-password-warning",
"hide-security-settings",
"hide-network-settings",
"hide-server-settings",
"hide-proxy-settings",
"hide-username-on-card",
OPTION_ALLOW_REMOTE_CM_MODIFICATION, OPTION_ALLOW_REMOTE_CM_MODIFICATION,
"hide-help-cards",
]; ];
// DEFAULT_SETTINGS, OVERWRITE_SETTINGS // DEFAULT_SETTINGS, OVERWRITE_SETTINGS
pub const KEYS_SETTINGS: &[&str] = &[ pub const KEYS_SETTINGS: &[&str] = &[
@ -2238,9 +2239,21 @@ pub mod keys {
OPTION_PRESET_ADDRESS_BOOK_TAG, OPTION_PRESET_ADDRESS_BOOK_TAG,
OPTION_ENABLE_DIRECTX_CAPTURE, OPTION_ENABLE_DIRECTX_CAPTURE,
OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE, OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE,
];
// BUILDIN_SETTINGS
pub const KEYS_BUILDIN_SETTINGS: &[&str] = &[
OPTION_DISPLAY_NAME,
OPTION_DISABLE_UDP, OPTION_DISABLE_UDP,
OPTION_PRESET_USERNAME, OPTION_PRESET_USERNAME,
OPTION_PRESET_STRATEGY_NAME, OPTION_PRESET_STRATEGY_NAME,
OPTION_REMOVE_PRESET_PASSWORD_WARNING,
OPTION_HIDE_SECURITY_SETTINGS,
OPTION_HIDE_NETWORK_SETTINGS,
OPTION_HIDE_SERVER_SETTINGS,
OPTION_HIDE_PROXY_SETTINGS,
OPTION_HIDE_USERNAME_ON_CARD,
OPTION_HIDE_HELP_CARDS,
]; ];
} }

View File

@ -60,7 +60,7 @@ use crate::{
check_port, check_port,
common::input::{MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP}, common::input::{MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP},
create_symmetric_key_msg, decode_id_pk, get_rs_pk, is_keyboard_mode_supported, secure_tcp, create_symmetric_key_msg, decode_id_pk, get_rs_pk, is_keyboard_mode_supported, secure_tcp,
ui_interface::use_texture_render, ui_interface::{get_buildin_option, use_texture_render},
ui_session_interface::{InvokeUiSession, Session}, ui_session_interface::{InvokeUiSession, Session},
}; };
@ -2027,7 +2027,7 @@ impl LoginConfigHandler {
} else { } else {
(my_id, self.id.clone()) (my_id, self.id.clone())
}; };
let mut display_name = LocalConfig::get_option(&config::keys::OPTION_DISPLAY_NAME); let mut display_name = get_buildin_option(config::keys::OPTION_DISPLAY_NAME);
if display_name.is_empty() { if display_name.is_empty() {
display_name = crate::username(); display_name = crate::username();
} }

View File

@ -1341,6 +1341,7 @@ fn read_custom_client_advanced_settings(
map_display_settings: &HashMap<String, &&str>, map_display_settings: &HashMap<String, &&str>,
map_local_settings: &HashMap<String, &&str>, map_local_settings: &HashMap<String, &&str>,
map_settings: &HashMap<String, &&str>, map_settings: &HashMap<String, &&str>,
map_buildin_settings: &HashMap<String, &&str>,
is_override: bool, is_override: bool,
) { ) {
let mut display_settings = if is_override { let mut display_settings = if is_override {
@ -1358,6 +1359,8 @@ fn read_custom_client_advanced_settings(
} else { } else {
config::DEFAULT_SETTINGS.write().unwrap() config::DEFAULT_SETTINGS.write().unwrap()
}; };
let mut buildin_settings = config::BUILDIN_SETTINGS.write().unwrap();
if let Some(settings) = settings.as_object() { if let Some(settings) = settings.as_object() {
for (k, v) in settings { for (k, v) in settings {
let Some(v) = v.as_str() else { let Some(v) = v.as_str() else {
@ -1369,6 +1372,8 @@ fn read_custom_client_advanced_settings(
local_settings.insert(k2.to_string(), v.to_owned()); local_settings.insert(k2.to_string(), v.to_owned());
} else if let Some(k2) = map_settings.get(k) { } else if let Some(k2) = map_settings.get(k) {
server_settings.insert(k2.to_string(), v.to_owned()); server_settings.insert(k2.to_string(), v.to_owned());
} else if let Some(k2) = map_buildin_settings.get(k) {
buildin_settings.insert(k2.to_string(), v.to_owned());
} else { } else {
let k2 = k.replace("_", "-"); let k2 = k.replace("_", "-");
let k = k2.replace("-", "_"); let k = k2.replace("-", "_");
@ -1381,6 +1386,9 @@ fn read_custom_client_advanced_settings(
// server // server
server_settings.insert(k.clone(), v.to_owned()); server_settings.insert(k.clone(), v.to_owned());
server_settings.insert(k2.clone(), v.to_owned()); server_settings.insert(k2.clone(), v.to_owned());
// buildin
buildin_settings.insert(k.clone(), v.to_owned());
buildin_settings.insert(k2.clone(), v.to_owned());
} }
} }
} }
@ -1443,12 +1451,17 @@ pub fn read_custom_client(config: &str) {
for s in config::keys::KEYS_SETTINGS { for s in config::keys::KEYS_SETTINGS {
map_settings.insert(s.replace("_", "-"), s); map_settings.insert(s.replace("_", "-"), s);
} }
let mut buildin_settings = HashMap::new();
for s in config::keys::KEYS_BUILDIN_SETTINGS {
buildin_settings.insert(s.replace("_", "-"), s);
}
if let Some(default_settings) = data.remove("default-settings") { if let Some(default_settings) = data.remove("default-settings") {
read_custom_client_advanced_settings( read_custom_client_advanced_settings(
default_settings, default_settings,
&map_display_settings, &map_display_settings,
&map_local_settings, &map_local_settings,
&map_settings, &map_settings,
&buildin_settings,
false, false,
); );
} }
@ -1458,6 +1471,7 @@ pub fn read_custom_client(config: &str) {
&map_display_settings, &map_display_settings,
&map_local_settings, &map_local_settings,
&map_settings, &map_settings,
&buildin_settings,
true, true,
); );
} }

View File

@ -2213,6 +2213,10 @@ pub fn main_get_hard_option(key: String) -> SyncReturn<String> {
SyncReturn(get_hard_option(key)) SyncReturn(get_hard_option(key))
} }
pub fn main_get_buildin_option(key: String) -> SyncReturn<String> {
SyncReturn(get_buildin_option(&key))
}
pub fn main_check_hwcodec() { pub fn main_check_hwcodec() {
check_hwcodec() check_hwcodec()
} }

View File

@ -5,7 +5,7 @@ use std::{
}; };
#[cfg(not(any(target_os = "ios")))] #[cfg(not(any(target_os = "ios")))]
use crate::Connection; use crate::{ui_interface::get_buildin_option, Connection};
use hbb_common::{ use hbb_common::{
config::{keys, Config, LocalConfig}, config::{keys, Config, LocalConfig},
tokio::{self, sync::broadcast, time::Instant}, tokio::{self, sync::broadcast, time::Instant},
@ -91,11 +91,11 @@ async fn start_hbbs_sync_async() {
if !ab_tag.is_empty() { if !ab_tag.is_empty() {
v[keys::OPTION_PRESET_ADDRESS_BOOK_TAG] = json!(ab_tag); v[keys::OPTION_PRESET_ADDRESS_BOOK_TAG] = json!(ab_tag);
} }
let username = Config::get_option(keys::OPTION_PRESET_USERNAME); let username = get_buildin_option(keys::OPTION_PRESET_USERNAME);
if !username.is_empty() { if !username.is_empty() {
v[keys::OPTION_PRESET_USERNAME] = json!(username); v[keys::OPTION_PRESET_USERNAME] = json!(username);
} }
let strategy_name = Config::get_option(keys::OPTION_PRESET_STRATEGY_NAME); let strategy_name = get_buildin_option(keys::OPTION_PRESET_STRATEGY_NAME);
if !strategy_name.is_empty() { if !strategy_name.is_empty() {
v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name); v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name);
} }

View File

@ -29,6 +29,7 @@ use hbb_common::{
use crate::{ use crate::{
check_port, check_port,
server::{check_zombie, new as new_server, ServerPtr}, server::{check_zombie, new as new_server, ServerPtr},
ui_interface::get_buildin_option,
}; };
type Message = RendezvousMessage; type Message = RendezvousMessage;
@ -387,7 +388,7 @@ impl RendezvousMediator {
}; };
if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some()) if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some())
|| is_http_proxy || is_http_proxy
|| Config::get_option(config::keys::OPTION_DISABLE_UDP) == "Y" || get_buildin_option(config::keys::OPTION_DISABLE_UDP) == "Y"
{ {
Self::start_tcp(server, host).await Self::start_tcp(server, host).await
} else { } else {

View File

@ -202,6 +202,16 @@ pub fn get_hard_option(key: String) -> String {
.unwrap_or_default() .unwrap_or_default()
} }
#[inline]
pub fn get_buildin_option(key: &str) -> String {
config::BUILDIN_SETTINGS
.read()
.unwrap()
.get(key)
.cloned()
.unwrap_or_default()
}
#[inline] #[inline]
pub fn set_local_option(key: String, value: String) { pub fn set_local_option(key: String, value: String) {
LocalConfig::set_option(key, value); LocalConfig::set_option(key, value);