add access mode
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
8b1f78d84f
commit
688519320e
@ -260,6 +260,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
bool checked = await bind.mainCheckSuperUserPermission();
|
bool checked = await bind.mainCheckSuperUserPermission();
|
||||||
if (checked) {
|
if (checked) {
|
||||||
bind.mainSetOption(key: "stop-service", value: "");
|
bind.mainSetOption(key: "stop-service", value: "");
|
||||||
|
bind.mainSetOption(key: "access-mode", value: "");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(translate("Start Service"), style: textStyle))
|
child: Text(translate("Start Service"), style: textStyle))
|
||||||
|
@ -413,6 +413,13 @@ class _GeneralState extends State<_General> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum _AccessMode {
|
||||||
|
custom,
|
||||||
|
full,
|
||||||
|
view,
|
||||||
|
deny,
|
||||||
|
}
|
||||||
|
|
||||||
class _Safety extends StatefulWidget {
|
class _Safety extends StatefulWidget {
|
||||||
const _Safety({Key? key}) : super(key: key);
|
const _Safety({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -459,26 +466,113 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
|
|
||||||
Widget permissions(context) {
|
Widget permissions(context) {
|
||||||
bool enabled = !locked;
|
bool enabled = !locked;
|
||||||
|
|
||||||
|
return _futureBuilder(future: () async {
|
||||||
|
bool stopService = option2bool(
|
||||||
|
'stop-service', await bind.mainGetOption(key: 'stop-service'));
|
||||||
|
final accessMode = await bind.mainGetOption(key: 'access-mode');
|
||||||
|
return {'stopService': stopService, 'accessMode': accessMode};
|
||||||
|
}(), hasData: (data) {
|
||||||
|
var map = data! as Map<String, dynamic>;
|
||||||
|
bool stopService = map['stopService'] as bool;
|
||||||
|
String accessMode = map['accessMode'] as String;
|
||||||
|
_AccessMode mode;
|
||||||
|
if (stopService) {
|
||||||
|
mode = _AccessMode.deny;
|
||||||
|
} else {
|
||||||
|
if (accessMode == 'full') {
|
||||||
|
mode = _AccessMode.full;
|
||||||
|
} else if (accessMode == 'view') {
|
||||||
|
mode = _AccessMode.view;
|
||||||
|
} else {
|
||||||
|
mode = _AccessMode.custom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String initialKey;
|
||||||
|
bool? fakeValue;
|
||||||
|
switch (mode) {
|
||||||
|
case _AccessMode.custom:
|
||||||
|
initialKey = '';
|
||||||
|
fakeValue = null;
|
||||||
|
break;
|
||||||
|
case _AccessMode.full:
|
||||||
|
initialKey = 'full';
|
||||||
|
fakeValue = true;
|
||||||
|
break;
|
||||||
|
case _AccessMode.view:
|
||||||
|
initialKey = 'view';
|
||||||
|
fakeValue = false;
|
||||||
|
break;
|
||||||
|
case _AccessMode.deny:
|
||||||
|
initialKey = 'deny';
|
||||||
|
fakeValue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return _Card(title: 'Permissions', children: [
|
return _Card(title: 'Permissions', children: [
|
||||||
_OptionCheckBox(context, 'Enable Keyboard/Mouse', 'enable-keyboard',
|
_ComboBox(
|
||||||
enabled: enabled),
|
keys: [
|
||||||
|
'',
|
||||||
|
'full',
|
||||||
|
'view',
|
||||||
|
'deny'
|
||||||
|
],
|
||||||
|
values: [
|
||||||
|
translate('Custom'),
|
||||||
|
translate('Full Access'),
|
||||||
|
translate('Screen Share'),
|
||||||
|
translate('Deny remote access'),
|
||||||
|
],
|
||||||
|
initialKey: initialKey,
|
||||||
|
onChanged: (mode) async {
|
||||||
|
String modeValue;
|
||||||
|
bool stopService;
|
||||||
|
if (mode == 'deny') {
|
||||||
|
modeValue = '';
|
||||||
|
stopService = true;
|
||||||
|
} else {
|
||||||
|
modeValue = mode;
|
||||||
|
stopService = false;
|
||||||
|
}
|
||||||
|
await bind.mainSetOption(key: 'access-mode', value: modeValue);
|
||||||
|
await bind.mainSetOption(
|
||||||
|
key: 'stop-service',
|
||||||
|
value: bool2option('stop-service', stopService));
|
||||||
|
setState(() {});
|
||||||
|
}).marginOnly(left: _kContentHMargin),
|
||||||
|
Offstage(
|
||||||
|
offstage: mode == _AccessMode.deny,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_OptionCheckBox(
|
||||||
|
context, 'Enable Keyboard/Mouse', 'enable-keyboard',
|
||||||
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable Clipboard', 'enable-clipboard',
|
_OptionCheckBox(context, 'Enable Clipboard', 'enable-clipboard',
|
||||||
enabled: enabled),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable File Transfer', 'enable-file-transfer',
|
_OptionCheckBox(
|
||||||
enabled: enabled),
|
context, 'Enable File Transfer', 'enable-file-transfer',
|
||||||
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable Audio', 'enable-audio',
|
_OptionCheckBox(context, 'Enable Audio', 'enable-audio',
|
||||||
enabled: enabled),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable TCP Tunneling', 'enable-tunnel',
|
_OptionCheckBox(context, 'Enable TCP Tunneling', 'enable-tunnel',
|
||||||
enabled: enabled),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable Remote Restart', 'enable-remote-restart',
|
_OptionCheckBox(
|
||||||
enabled: enabled),
|
context, 'Enable Remote Restart', 'enable-remote-restart',
|
||||||
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(
|
_OptionCheckBox(
|
||||||
context, 'Enable Recording Session', 'enable-record-session',
|
context, 'Enable Recording Session', 'enable-record-session',
|
||||||
enabled: enabled),
|
enabled: enabled, fakeValue: fakeValue),
|
||||||
_OptionCheckBox(context, 'Enable remote configuration modification',
|
_OptionCheckBox(
|
||||||
|
context,
|
||||||
|
'Enable remote configuration modification',
|
||||||
'allow-remote-config-modification',
|
'allow-remote-config-modification',
|
||||||
enabled: enabled),
|
enabled: enabled,
|
||||||
|
fakeValue: fakeValue),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
]);
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget password(BuildContext context) {
|
Widget password(BuildContext context) {
|
||||||
@ -566,12 +660,6 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
|||||||
Widget more(BuildContext context) {
|
Widget more(BuildContext context) {
|
||||||
bool enabled = !locked;
|
bool enabled = !locked;
|
||||||
return _Card(title: 'Security', children: [
|
return _Card(title: 'Security', children: [
|
||||||
_OptionCheckBox(context, 'Deny remote access', 'stop-service',
|
|
||||||
checkedIcon: const Icon(
|
|
||||||
Icons.warning_amber_rounded,
|
|
||||||
color: kColorWarn,
|
|
||||||
),
|
|
||||||
enabled: enabled),
|
|
||||||
Offstage(
|
Offstage(
|
||||||
offstage: !Platform.isWindows,
|
offstage: !Platform.isWindows,
|
||||||
child: _OptionCheckBox(context, 'Enable RDP', 'enable-rdp',
|
child: _OptionCheckBox(context, 'Enable RDP', 'enable-rdp',
|
||||||
@ -941,7 +1029,8 @@ Widget _OptionCheckBox(BuildContext context, String label, String key,
|
|||||||
{Function()? update,
|
{Function()? update,
|
||||||
bool reverse = false,
|
bool reverse = false,
|
||||||
bool enabled = true,
|
bool enabled = true,
|
||||||
Icon? checkedIcon}) {
|
Icon? checkedIcon,
|
||||||
|
bool? fakeValue}) {
|
||||||
return _futureBuilder(
|
return _futureBuilder(
|
||||||
future: bind.mainGetOption(key: key),
|
future: bind.mainGetOption(key: key),
|
||||||
hasData: (data) {
|
hasData: (data) {
|
||||||
@ -958,6 +1047,11 @@ Widget _OptionCheckBox(BuildContext context, String label, String key,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fakeValue != null) {
|
||||||
|
ref.value = fakeValue;
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Row(
|
() => Row(
|
||||||
|
@ -249,10 +249,12 @@ class DesktopTab extends StatelessWidget {
|
|||||||
var block = false.obs;
|
var block = false.obs;
|
||||||
return Obx(() => MouseRegion(
|
return Obx(() => MouseRegion(
|
||||||
onEnter: (_) async {
|
onEnter: (_) async {
|
||||||
if (!option2bool(
|
var access_mode = await bind.mainGetOption(key: 'access-mode');
|
||||||
|
var option = option2bool(
|
||||||
'allow-remote-config-modification',
|
'allow-remote-config-modification',
|
||||||
await bind.mainGetOption(
|
await bind.mainGetOption(
|
||||||
key: 'allow-remote-config-modification'))) {
|
key: 'allow-remote-config-modification'));
|
||||||
|
if (access_mode == 'view' || (access_mode.isEmpty && !option)) {
|
||||||
var time0 = DateTime.now().millisecondsSinceEpoch;
|
var time0 = DateTime.now().millisecondsSinceEpoch;
|
||||||
await bind.mainCheckMouseTime();
|
await bind.mainCheckMouseTime();
|
||||||
Timer(const Duration(milliseconds: 120), () async {
|
Timer(const Duration(milliseconds: 120), () async {
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", "其他"),
|
("Other", "其他"),
|
||||||
("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"),
|
("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"),
|
||||||
("Keyboard Settings", "键盘设置"),
|
("Keyboard Settings", "键盘设置"),
|
||||||
|
("Custom", "自定义"),
|
||||||
|
("Full Access", "完全访问"),
|
||||||
|
("Screen Share", "仅共享屏幕"),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", "他の"),
|
("Other", "他の"),
|
||||||
("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"),
|
("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", "其他"),
|
("Other", "其他"),
|
||||||
("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"),
|
("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"),
|
||||||
("Keyboard Settings", "鍵盤設置"),
|
("Keyboard Settings", "鍵盤設置"),
|
||||||
|
("Custom", "自定義"),
|
||||||
|
("Full Access", "完全訪問"),
|
||||||
|
("Screen Share", "僅共享屏幕"),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -374,5 +374,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
|||||||
("Other", ""),
|
("Other", ""),
|
||||||
("Confirm before closing multiple tabs", ""),
|
("Confirm before closing multiple tabs", ""),
|
||||||
("Keyboard Settings", ""),
|
("Keyboard Settings", ""),
|
||||||
|
("Custom", ""),
|
||||||
|
("Full Access", ""),
|
||||||
|
("Screen Share", ""),
|
||||||
].iter().cloned().collect();
|
].iter().cloned().collect();
|
||||||
}
|
}
|
||||||
|
@ -167,12 +167,12 @@ impl Connection {
|
|||||||
port_forward_address: "".to_owned(),
|
port_forward_address: "".to_owned(),
|
||||||
tx_to_cm,
|
tx_to_cm,
|
||||||
authorized: false,
|
authorized: false,
|
||||||
keyboard: Config::get_option("enable-keyboard").is_empty(),
|
keyboard: Connection::permission("enable-keyboard"),
|
||||||
clipboard: Config::get_option("enable-clipboard").is_empty(),
|
clipboard: Connection::permission("enable-clipboard"),
|
||||||
audio: Config::get_option("enable-audio").is_empty(),
|
audio: Connection::permission("enable-audio"),
|
||||||
file: Config::get_option("enable-file-transfer").is_empty(),
|
file: Connection::permission("enable-file-transfer"),
|
||||||
restart: Config::get_option("enable-remote-restart").is_empty(),
|
restart: Connection::permission("enable-remote-restart"),
|
||||||
recording: Config::get_option("enable-record-session").is_empty(),
|
recording: Connection::permission("enable-record-session"),
|
||||||
last_test_delay: 0,
|
last_test_delay: 0,
|
||||||
lock_after_session_end: false,
|
lock_after_session_end: false,
|
||||||
show_remote_cursor: false,
|
show_remote_cursor: false,
|
||||||
@ -922,6 +922,20 @@ impl Connection {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn permission(enable_prefix_option: &str) -> bool {
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
{
|
||||||
|
let access_mode = Config::get_option("access-mode");
|
||||||
|
if access_mode == "full" {
|
||||||
|
return true;
|
||||||
|
} else if access_mode == "view" {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Config::get_option(enable_prefix_option).is_empty();
|
||||||
|
}
|
||||||
|
|
||||||
async fn on_message(&mut self, msg: Message) -> bool {
|
async fn on_message(&mut self, msg: Message) -> bool {
|
||||||
if let Some(message::Union::LoginRequest(lr)) = msg.union {
|
if let Some(message::Union::LoginRequest(lr)) = msg.union {
|
||||||
self.lr = lr.clone();
|
self.lr = lr.clone();
|
||||||
@ -950,7 +964,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
match lr.union {
|
match lr.union {
|
||||||
Some(login_request::Union::FileTransfer(ft)) => {
|
Some(login_request::Union::FileTransfer(ft)) => {
|
||||||
if !Config::get_option("enable-file-transfer").is_empty() {
|
if !Connection::permission("enable-file-transfer") {
|
||||||
self.send_login_error("No permission of file transfer")
|
self.send_login_error("No permission of file transfer")
|
||||||
.await;
|
.await;
|
||||||
sleep(1.).await;
|
sleep(1.).await;
|
||||||
@ -965,8 +979,8 @@ impl Connection {
|
|||||||
pf.port = 3389;
|
pf.port = 3389;
|
||||||
is_rdp = true;
|
is_rdp = true;
|
||||||
}
|
}
|
||||||
if is_rdp && !Config::get_option("enable-rdp").is_empty()
|
if is_rdp && !Connection::permission("enable-rdp")
|
||||||
|| !is_rdp && !Config::get_option("enable-tunnel").is_empty()
|
|| !is_rdp && !Connection::permission("enable-tunnel")
|
||||||
{
|
{
|
||||||
if is_rdp {
|
if is_rdp {
|
||||||
self.send_login_error("No permission of RDP").await;
|
self.send_login_error("No permission of RDP").await;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user