android direct ip access
This commit is contained in:
parent
0abda2edef
commit
9911f4d2f5
@ -136,8 +136,9 @@ class MyTheme {
|
|||||||
titleLarge: TextStyle(fontSize: 19, color: Colors.black87),
|
titleLarge: TextStyle(fontSize: 19, color: Colors.black87),
|
||||||
titleSmall: TextStyle(fontSize: 14, color: Colors.black87),
|
titleSmall: TextStyle(fontSize: 14, color: Colors.black87),
|
||||||
bodySmall: TextStyle(fontSize: 12, color: Colors.black87, height: 1.25),
|
bodySmall: TextStyle(fontSize: 12, color: Colors.black87, height: 1.25),
|
||||||
bodyMedium: TextStyle(fontSize: 14, color: Colors.black87, height: 1.25),
|
bodyMedium:
|
||||||
),
|
TextStyle(fontSize: 14, color: Colors.black87, height: 1.25),
|
||||||
|
labelLarge: TextStyle(fontSize: 16.0, color: MyTheme.accent80)),
|
||||||
hintColor: Color(0xFFAAAAAA),
|
hintColor: Color(0xFFAAAAAA),
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
@ -166,7 +167,9 @@ class MyTheme {
|
|||||||
titleLarge: TextStyle(fontSize: 19),
|
titleLarge: TextStyle(fontSize: 19),
|
||||||
titleSmall: TextStyle(fontSize: 14),
|
titleSmall: TextStyle(fontSize: 14),
|
||||||
bodySmall: TextStyle(fontSize: 12, height: 1.25),
|
bodySmall: TextStyle(fontSize: 12, height: 1.25),
|
||||||
bodyMedium: TextStyle(fontSize: 14, height: 1.25)),
|
bodyMedium: TextStyle(fontSize: 14, height: 1.25),
|
||||||
|
labelLarge: TextStyle(
|
||||||
|
fontSize: 16.0, fontWeight: FontWeight.bold, color: accent80)),
|
||||||
cardColor: Color(0xFF252525),
|
cardColor: Color(0xFF252525),
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
|
@ -155,3 +155,54 @@ void changeWhiteList({Function()? callback}) async {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> changeDirectAccessPort(
|
||||||
|
String currentIP, String currentPort) async {
|
||||||
|
final controller = TextEditingController(text: currentPort);
|
||||||
|
await gFFI.dialogManager.show((setState, close) {
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Text(translate("Change Local Port")),
|
||||||
|
content: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 8.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
maxLines: null,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: '21118',
|
||||||
|
isCollapsed: true,
|
||||||
|
prefix: Text('$currentIP : '),
|
||||||
|
suffix: IconButton(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
icon: const Icon(Icons.clear, size: 16),
|
||||||
|
onPressed: () => controller.clear())),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.allow(RegExp(
|
||||||
|
r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$')),
|
||||||
|
],
|
||||||
|
controller: controller,
|
||||||
|
focusNode: FocusNode()..requestFocus()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await bind.mainSetOption(
|
||||||
|
key: 'direct-access-port', value: controller.text);
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
child: Text(translate("OK"))),
|
||||||
|
],
|
||||||
|
onCancel: close,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return controller.text;
|
||||||
|
}
|
||||||
|
@ -333,14 +333,8 @@ class PermissionRow extends StatelessWidget {
|
|||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(name,
|
child:
|
||||||
style: TextStyle(
|
Text(name, style: Theme.of(context).textTheme.labelLarge))),
|
||||||
fontSize: 16.0,
|
|
||||||
fontWeight:
|
|
||||||
Theme.of(context).brightness == Brightness.dark
|
|
||||||
? FontWeight.bold
|
|
||||||
: null,
|
|
||||||
color: MyTheme.accent80)))),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
|
@ -36,6 +36,9 @@ var _ignoreBatteryOpt = false;
|
|||||||
var _enableAbr = false;
|
var _enableAbr = false;
|
||||||
var _denyLANDiscovery = false;
|
var _denyLANDiscovery = false;
|
||||||
var _onlyWhiteList = false;
|
var _onlyWhiteList = false;
|
||||||
|
var _enableDirectIPAccess = false;
|
||||||
|
var _localIP = "";
|
||||||
|
var _directAccessPort = "";
|
||||||
|
|
||||||
class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||||
String? username;
|
String? username;
|
||||||
@ -77,6 +80,26 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
_onlyWhiteList = onlyWhiteList;
|
_onlyWhiteList = onlyWhiteList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final enableDirectIPAccess = option2bool(
|
||||||
|
'direct-server', await bind.mainGetOption(key: 'direct-server'));
|
||||||
|
if (enableDirectIPAccess != _enableDirectIPAccess) {
|
||||||
|
update = true;
|
||||||
|
_enableDirectIPAccess = enableDirectIPAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
final localIP = await bind.mainGetOption(key: 'local-ip-addr');
|
||||||
|
if (localIP != _localIP) {
|
||||||
|
update = true;
|
||||||
|
_localIP = localIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
final directAccessPort =
|
||||||
|
await bind.mainGetOption(key: 'direct-access-port');
|
||||||
|
if (directAccessPort != _directAccessPort) {
|
||||||
|
update = true;
|
||||||
|
_directAccessPort = directAccessPort;
|
||||||
|
}
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
@ -113,20 +136,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
final enhancementsTiles = [
|
final List<AbstractSettingsTile> enhancementsTiles = [];
|
||||||
SettingsTile.switchTile(
|
final List<AbstractSettingsTile> shareScreenTiles = [
|
||||||
title: Text('${translate('Adaptive Bitrate')} (beta)'),
|
|
||||||
initialValue: _enableAbr,
|
|
||||||
onToggle: (v) async {
|
|
||||||
await bind.mainSetOption(key: "enable-abr", value: v ? "" : "N");
|
|
||||||
final newValue = await bind.mainGetOption(key: "enable-abr") != "N";
|
|
||||||
setState(() {
|
|
||||||
_enableAbr = newValue;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
];
|
|
||||||
final shareScreenTiles = [
|
|
||||||
SettingsTile.switchTile(
|
SettingsTile.switchTile(
|
||||||
title: Text(translate('Deny LAN Discovery')),
|
title: Text(translate('Deny LAN Discovery')),
|
||||||
initialValue: _denyLANDiscovery,
|
initialValue: _denyLANDiscovery,
|
||||||
@ -143,7 +154,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
),
|
),
|
||||||
SettingsTile.switchTile(
|
SettingsTile.switchTile(
|
||||||
title: Row(children: [
|
title: Row(children: [
|
||||||
Text(translate('Use IP Whitelisting')),
|
Expanded(child: Text(translate('Use IP Whitelisting'))),
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !_onlyWhiteList,
|
offstage: !_onlyWhiteList,
|
||||||
child: const Icon(Icons.warning_amber_rounded,
|
child: const Icon(Icons.warning_amber_rounded,
|
||||||
@ -164,6 +175,58 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
changeWhiteList(callback: update);
|
changeWhiteList(callback: update);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
SettingsTile.switchTile(
|
||||||
|
title: Text('${translate('Adaptive Bitrate')} (beta)'),
|
||||||
|
initialValue: _enableAbr,
|
||||||
|
onToggle: (v) async {
|
||||||
|
await bind.mainSetOption(key: "enable-abr", value: v ? "" : "N");
|
||||||
|
final newValue = await bind.mainGetOption(key: "enable-abr") != "N";
|
||||||
|
setState(() {
|
||||||
|
_enableAbr = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SettingsTile.switchTile(
|
||||||
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(translate("Direct IP Access")),
|
||||||
|
Offstage(
|
||||||
|
offstage: !_enableDirectIPAccess,
|
||||||
|
child: Text(
|
||||||
|
'${translate("Local Address")}: $_localIP${_directAccessPort.isEmpty ? "" : ":$_directAccessPort"}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
)),
|
||||||
|
])),
|
||||||
|
Offstage(
|
||||||
|
offstage: !_enableDirectIPAccess,
|
||||||
|
child: IconButton(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
icon: Icon(
|
||||||
|
Icons.edit,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final port = await changeDirectAccessPort(
|
||||||
|
_localIP, _directAccessPort);
|
||||||
|
setState(() {
|
||||||
|
_directAccessPort = port;
|
||||||
|
});
|
||||||
|
}))
|
||||||
|
]),
|
||||||
|
initialValue: _enableDirectIPAccess,
|
||||||
|
onToggle: (_) async {
|
||||||
|
_enableDirectIPAccess = !_enableDirectIPAccess;
|
||||||
|
String value = bool2option('direct-server', _enableDirectIPAccess);
|
||||||
|
await bind.mainSetOption(key: 'direct-server', value: value);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
if (_hasIgnoreBattery) {
|
if (_hasIgnoreBattery) {
|
||||||
@ -171,9 +234,13 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
|||||||
0,
|
0,
|
||||||
SettingsTile.switchTile(
|
SettingsTile.switchTile(
|
||||||
initialValue: _ignoreBatteryOpt,
|
initialValue: _ignoreBatteryOpt,
|
||||||
title: Text(translate('Keep RustDesk background service')),
|
title: Column(
|
||||||
description:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text('* ${translate('Ignore Battery Optimizations')}'),
|
children: [
|
||||||
|
Text(translate('Keep RustDesk background service')),
|
||||||
|
Text('* ${translate('Ignore Battery Optimizations')}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall),
|
||||||
|
]),
|
||||||
onToggle: (v) async {
|
onToggle: (v) async {
|
||||||
if (v) {
|
if (v) {
|
||||||
PermissionManager.request("ignore_battery_optimizations");
|
PermissionManager.request("ignore_battery_optimizations");
|
||||||
|
@ -13,7 +13,7 @@ import '../desktop/widgets/tabbar_widget.dart';
|
|||||||
import '../mobile/pages/server_page.dart';
|
import '../mobile/pages/server_page.dart';
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
const KLoginDialogTag = "LOGIN";
|
const kLoginDialogTag = "LOGIN";
|
||||||
|
|
||||||
const kUseTemporaryPassword = "use-temporary-password";
|
const kUseTemporaryPassword = "use-temporary-password";
|
||||||
const kUsePermanentPassword = "use-permanent-password";
|
const kUsePermanentPassword = "use-permanent-password";
|
||||||
@ -578,7 +578,7 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getLoginDialogTag(int id) {
|
String getLoginDialogTag(int id) {
|
||||||
return KLoginDialogTag + id.toString();
|
return kLoginDialogTag + id.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
showInputWarnAlert(FFI ffi) {
|
showInputWarnAlert(FFI ffi) {
|
||||||
|
@ -317,6 +317,7 @@ async fn test_nat_type_() -> ResultType<bool> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Config::set_option("local-ip-addr".to_owned(), addr.ip().to_string());
|
||||||
let ok = port1 > 0 && port2 > 0;
|
let ok = port1 > 0 && port2 > 0;
|
||||||
if ok {
|
if ok {
|
||||||
let t = if port1 == port2 {
|
let t = if port1 == port2 {
|
||||||
|
@ -32,16 +32,15 @@ fn initialize(app_dir: &str) {
|
|||||||
);
|
);
|
||||||
#[cfg(feature = "mediacodec")]
|
#[cfg(feature = "mediacodec")]
|
||||||
scrap::mediacodec::check_mediacodec();
|
scrap::mediacodec::check_mediacodec();
|
||||||
|
crate::common::test_rendezvous_server();
|
||||||
|
crate::common::test_nat_type();
|
||||||
|
crate::common::check_software_update();
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "ios")]
|
#[cfg(target_os = "ios")]
|
||||||
{
|
{
|
||||||
use hbb_common::env_logger::*;
|
use hbb_common::env_logger::*;
|
||||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));
|
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
{
|
|
||||||
crate::common::check_software_update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FFI for rustdesk core's main entry.
|
/// FFI for rustdesk core's main entry.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user