mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 19:17:58 +00:00
Merge pull request #3196 from 21pages/relay_id
force relay when id is suffixed with "/r"
This commit is contained in:
@@ -298,6 +298,8 @@ class FfiModel with ChangeNotifier {
|
||||
showWaitUacDialog(id, dialogManager, type);
|
||||
} else if (type == 'elevation-error') {
|
||||
showElevationError(id, type, title, text, dialogManager);
|
||||
} else if (type == "relay-hint") {
|
||||
showRelayHintDialog(id, type, title, text, dialogManager);
|
||||
} else {
|
||||
var hasRetry = evt['hasRetry'] == 'true';
|
||||
showMsgBox(id, type, title, text, link, hasRetry, dialogManager);
|
||||
@@ -312,7 +314,7 @@ class FfiModel with ChangeNotifier {
|
||||
_timer?.cancel();
|
||||
if (hasRetry) {
|
||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||
bind.sessionReconnect(id: id);
|
||||
bind.sessionReconnect(id: id, forceRelay: false);
|
||||
clearPermissions();
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
onCancel: closeConnection);
|
||||
@@ -323,6 +325,44 @@ class FfiModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
void showRelayHintDialog(String id, String type, String title, String text,
|
||||
OverlayDialogManager dialogManager) {
|
||||
dialogManager.show(tag: '$id-$type', (setState, close) {
|
||||
onClose() {
|
||||
closeConnection();
|
||||
close();
|
||||
}
|
||||
|
||||
reconnect(bool forceRelay) {
|
||||
bind.sessionReconnect(id: id, forceRelay: forceRelay);
|
||||
clearPermissions();
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
onCancel: closeConnection);
|
||||
}
|
||||
|
||||
final style =
|
||||
ElevatedButton.styleFrom(backgroundColor: Colors.green[700]);
|
||||
return CustomAlertDialog(
|
||||
title: null,
|
||||
content: msgboxContent(type, title,
|
||||
"${translate(text)}\n\n${translate('relay_hint_tip')}"),
|
||||
actions: [
|
||||
dialogButton('Close', onPressed: onClose, isOutline: true),
|
||||
dialogButton('Retry', onPressed: () => reconnect(false)),
|
||||
dialogButton('Connect via relay',
|
||||
onPressed: () => reconnect(true), buttonStyle: style),
|
||||
dialogButton('Always connect via relay', onPressed: () {
|
||||
const option = 'force-always-relay';
|
||||
bind.sessionPeerOption(
|
||||
id: id, name: option, value: bool2option(option, true));
|
||||
reconnect(true);
|
||||
}, buttonStyle: style),
|
||||
],
|
||||
onCancel: onClose,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle the peer info event based on [evt].
|
||||
handlePeerInfo(Map<String, dynamic> evt, String peerId) async {
|
||||
// recent peer updated by handle_peer_info(ui_session_interface.rs) --> handle_peer_info(client.rs) --> save_config(client.rs)
|
||||
@@ -1341,7 +1381,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;
|
||||
@@ -1357,11 +1398,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 {
|
||||
|
||||
Reference in New Issue
Block a user