mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
force relay when id is suffixed with "/r"
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -1405,13 +1405,14 @@ bool callUniLinksUriHandler(Uri uri) {
|
||||
connectMainDesktop(String id,
|
||||
{required bool isFileTransfer,
|
||||
required bool isTcpTunneling,
|
||||
required bool isRDP}) async {
|
||||
required bool isRDP,
|
||||
bool? forceRelay}) async {
|
||||
if (isFileTransfer) {
|
||||
await rustDeskWinManager.newFileTransfer(id);
|
||||
await rustDeskWinManager.newFileTransfer(id, forceRelay: forceRelay);
|
||||
} else if (isTcpTunneling || isRDP) {
|
||||
await rustDeskWinManager.newPortForward(id, isRDP);
|
||||
await rustDeskWinManager.newPortForward(id, isRDP, forceRelay: forceRelay);
|
||||
} else {
|
||||
await rustDeskWinManager.newRemoteDesktop(id);
|
||||
await rustDeskWinManager.newRemoteDesktop(id, forceRelay: forceRelay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1422,7 +1423,8 @@ connectMainDesktop(String id,
|
||||
connect(BuildContext context, String id,
|
||||
{bool isFileTransfer = false,
|
||||
bool isTcpTunneling = false,
|
||||
bool isRDP = false}) async {
|
||||
bool isRDP = false,
|
||||
bool forceRelay = false}) async {
|
||||
if (id == '') return;
|
||||
id = id.replaceAll(' ', '');
|
||||
assert(!(isFileTransfer && isTcpTunneling && isRDP),
|
||||
@@ -1430,18 +1432,18 @@ connect(BuildContext context, String id,
|
||||
|
||||
if (isDesktop) {
|
||||
if (desktopType == DesktopType.main) {
|
||||
await connectMainDesktop(
|
||||
id,
|
||||
isFileTransfer: isFileTransfer,
|
||||
isTcpTunneling: isTcpTunneling,
|
||||
isRDP: isRDP,
|
||||
);
|
||||
await connectMainDesktop(id,
|
||||
isFileTransfer: isFileTransfer,
|
||||
isTcpTunneling: isTcpTunneling,
|
||||
isRDP: isRDP,
|
||||
forceRelay: forceRelay);
|
||||
} else {
|
||||
await rustDeskWinManager.call(WindowType.Main, kWindowConnect, {
|
||||
'id': id,
|
||||
'isFileTransfer': isFileTransfer,
|
||||
'isTcpTunneling': isTcpTunneling,
|
||||
'isRDP': isRDP,
|
||||
"forceRelay": forceRelay,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -1735,6 +1737,7 @@ Future<void> updateSystemWindowTheme() async {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// macOS only
|
||||
///
|
||||
/// Note: not found a general solution for rust based AVFoundation bingding.
|
||||
|
||||
@@ -66,7 +66,8 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
_idFocusNode.addListener(() {
|
||||
_idInputFocused.value = _idFocusNode.hasFocus;
|
||||
// select all to faciliate removing text, just following the behavior of address input of chrome
|
||||
_idController.selection = TextSelection(baseOffset: 0, extentOffset: _idController.value.text.length);
|
||||
_idController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _idController.value.text.length);
|
||||
});
|
||||
windowManager.addListener(this);
|
||||
}
|
||||
@@ -149,8 +150,11 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
/// Callback for the connect button.
|
||||
/// Connects to the selected peer.
|
||||
void onConnect({bool isFileTransfer = false}) {
|
||||
final id = _idController.id;
|
||||
connect(context, id, isFileTransfer: isFileTransfer);
|
||||
var id = _idController.id;
|
||||
var forceRelay = id.endsWith(r'/r');
|
||||
if (forceRelay) id = id.substring(0, id.length - 2);
|
||||
connect(context, id,
|
||||
isFileTransfer: isFileTransfer, forceRelay: forceRelay);
|
||||
}
|
||||
|
||||
/// UI for the remote ID TextField.
|
||||
|
||||
@@ -556,6 +556,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
isFileTransfer: call.arguments['isFileTransfer'],
|
||||
isTcpTunneling: call.arguments['isTcpTunneling'],
|
||||
isRDP: call.arguments['isRDP'],
|
||||
forceRelay: call.arguments['forceRelay'],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,8 +46,10 @@ enum MouseFocusScope {
|
||||
}
|
||||
|
||||
class FileManagerPage extends StatefulWidget {
|
||||
const FileManagerPage({Key? key, required this.id}) : super(key: key);
|
||||
const FileManagerPage({Key? key, required this.id, this.forceRelay})
|
||||
: super(key: key);
|
||||
final String id;
|
||||
final bool? forceRelay;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _FileManagerPageState();
|
||||
@@ -102,7 +104,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ffi = FFI();
|
||||
_ffi.start(widget.id, isFileTransfer: true);
|
||||
_ffi.start(widget.id, isFileTransfer: true, forceRelay: widget.forceRelay);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_ffi.dialogManager
|
||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||
|
||||
@@ -41,7 +41,11 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => () => tabController.closeBy(params['id']),
|
||||
page: FileManagerPage(key: ValueKey(params['id']), id: params['id'])));
|
||||
page: FileManagerPage(
|
||||
key: ValueKey(params['id']),
|
||||
id: params['id'],
|
||||
forceRelay: params['forceRelay'],
|
||||
)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -64,7 +68,11 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => tabController.closeBy(id),
|
||||
page: FileManagerPage(key: ValueKey(id), id: id)));
|
||||
page: FileManagerPage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
forceRelay: args['forceRelay'],
|
||||
)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
|
||||
@@ -26,10 +26,12 @@ class _PortForward {
|
||||
}
|
||||
|
||||
class PortForwardPage extends StatefulWidget {
|
||||
const PortForwardPage({Key? key, required this.id, required this.isRDP})
|
||||
const PortForwardPage(
|
||||
{Key? key, required this.id, required this.isRDP, this.forceRelay})
|
||||
: super(key: key);
|
||||
final String id;
|
||||
final bool isRDP;
|
||||
final bool? forceRelay;
|
||||
|
||||
@override
|
||||
State<PortForwardPage> createState() => _PortForwardPageState();
|
||||
@@ -47,7 +49,7 @@ class _PortForwardPageState extends State<PortForwardPage>
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ffi = FFI();
|
||||
_ffi.start(widget.id, isPortForward: true);
|
||||
_ffi.start(widget.id, isPortForward: true, forceRelay: widget.forceRelay);
|
||||
Get.put(_ffi, tag: 'pf_${widget.id}');
|
||||
if (!Platform.isLinux) {
|
||||
Wakelock.enable();
|
||||
|
||||
@@ -44,6 +44,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
key: ValueKey(params['id']),
|
||||
id: params['id'],
|
||||
isRDP: isRDP,
|
||||
forceRelay: params['forceRelay'],
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -72,7 +73,12 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
page: PortForwardPage(id: id, isRDP: isRDP)));
|
||||
page: PortForwardPage(
|
||||
key: ValueKey(args['id']),
|
||||
id: id,
|
||||
isRDP: isRDP,
|
||||
forceRelay: args['forceRelay'],
|
||||
)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
|
||||
@@ -34,11 +34,13 @@ class RemotePage extends StatefulWidget {
|
||||
required this.id,
|
||||
required this.menubarState,
|
||||
this.switchUuid,
|
||||
this.forceRelay,
|
||||
}) : super(key: key);
|
||||
|
||||
final String id;
|
||||
final MenubarState menubarState;
|
||||
final String? switchUuid;
|
||||
final bool? forceRelay;
|
||||
final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null);
|
||||
|
||||
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
||||
@@ -107,6 +109,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
_ffi.start(
|
||||
widget.id,
|
||||
switchUuid: widget.switchUuid,
|
||||
forceRelay: widget.forceRelay,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
|
||||
@@ -70,6 +70,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
id: peerId,
|
||||
menubarState: _menubarState,
|
||||
switchUuid: params['switch_uuid'],
|
||||
forceRelay: params['forceRelay'],
|
||||
),
|
||||
));
|
||||
_update_remote_count();
|
||||
@@ -104,6 +105,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
id: id,
|
||||
menubarState: _menubarState,
|
||||
switchUuid: switchUuid,
|
||||
forceRelay: args['forceRelay'],
|
||||
),
|
||||
));
|
||||
} else if (call.method == "onDestroy") {
|
||||
|
||||
@@ -1339,7 +1339,8 @@ class FFI {
|
||||
void start(String id,
|
||||
{bool isFileTransfer = false,
|
||||
bool isPortForward = false,
|
||||
String? switchUuid}) {
|
||||
String? switchUuid,
|
||||
bool? forceRelay}) {
|
||||
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
||||
if (isFileTransfer) {
|
||||
connType = ConnType.fileTransfer;
|
||||
@@ -1355,11 +1356,11 @@ class FFI {
|
||||
}
|
||||
// ignore: unused_local_variable
|
||||
final addRes = bind.sessionAddSync(
|
||||
id: id,
|
||||
isFileTransfer: isFileTransfer,
|
||||
isPortForward: isPortForward,
|
||||
switchUuid: switchUuid ?? "",
|
||||
);
|
||||
id: id,
|
||||
isFileTransfer: isFileTransfer,
|
||||
isPortForward: isPortForward,
|
||||
switchUuid: switchUuid ?? "",
|
||||
forceRelay: forceRelay ?? false);
|
||||
final stream = bind.sessionStart(id: id);
|
||||
final cb = ffiModel.startEventListener(id);
|
||||
() async {
|
||||
|
||||
@@ -41,11 +41,15 @@ class RustDeskMultiWindowManager {
|
||||
int? _fileTransferWindowId;
|
||||
int? _portForwardWindowId;
|
||||
|
||||
Future<dynamic> newRemoteDesktop(String remoteId,
|
||||
{String? switch_uuid}) async {
|
||||
Future<dynamic> newRemoteDesktop(
|
||||
String remoteId, {
|
||||
String? switch_uuid,
|
||||
bool? forceRelay,
|
||||
}) async {
|
||||
var params = {
|
||||
"type": WindowType.RemoteDesktop.index,
|
||||
"id": remoteId,
|
||||
"forceRelay": forceRelay
|
||||
};
|
||||
if (switch_uuid != null) {
|
||||
params['switch_uuid'] = switch_uuid;
|
||||
@@ -78,9 +82,12 @@ class RustDeskMultiWindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> newFileTransfer(String remoteId) async {
|
||||
final msg =
|
||||
jsonEncode({"type": WindowType.FileTransfer.index, "id": remoteId});
|
||||
Future<dynamic> newFileTransfer(String remoteId, {bool? forceRelay}) async {
|
||||
var msg = jsonEncode({
|
||||
"type": WindowType.FileTransfer.index,
|
||||
"id": remoteId,
|
||||
"forceRelay": forceRelay,
|
||||
});
|
||||
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
@@ -107,9 +114,14 @@ class RustDeskMultiWindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> newPortForward(String remoteId, bool isRDP) async {
|
||||
final msg = jsonEncode(
|
||||
{"type": WindowType.PortForward.index, "id": remoteId, "isRDP": isRDP});
|
||||
Future<dynamic> newPortForward(String remoteId, bool isRDP,
|
||||
{bool? forceRelay}) async {
|
||||
final msg = jsonEncode({
|
||||
"type": WindowType.PortForward.index,
|
||||
"id": remoteId,
|
||||
"isRDP": isRDP,
|
||||
"forceRelay": forceRelay,
|
||||
});
|
||||
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
|
||||
Reference in New Issue
Block a user