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:
parent
759c1901a5
commit
6f106251f9
@ -1405,13 +1405,14 @@ bool callUniLinksUriHandler(Uri uri) {
|
|||||||
connectMainDesktop(String id,
|
connectMainDesktop(String id,
|
||||||
{required bool isFileTransfer,
|
{required bool isFileTransfer,
|
||||||
required bool isTcpTunneling,
|
required bool isTcpTunneling,
|
||||||
required bool isRDP}) async {
|
required bool isRDP,
|
||||||
|
bool? forceRelay}) async {
|
||||||
if (isFileTransfer) {
|
if (isFileTransfer) {
|
||||||
await rustDeskWinManager.newFileTransfer(id);
|
await rustDeskWinManager.newFileTransfer(id, forceRelay: forceRelay);
|
||||||
} else if (isTcpTunneling || isRDP) {
|
} else if (isTcpTunneling || isRDP) {
|
||||||
await rustDeskWinManager.newPortForward(id, isRDP);
|
await rustDeskWinManager.newPortForward(id, isRDP, forceRelay: forceRelay);
|
||||||
} else {
|
} else {
|
||||||
await rustDeskWinManager.newRemoteDesktop(id);
|
await rustDeskWinManager.newRemoteDesktop(id, forceRelay: forceRelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1422,7 +1423,8 @@ connectMainDesktop(String id,
|
|||||||
connect(BuildContext context, String id,
|
connect(BuildContext context, String id,
|
||||||
{bool isFileTransfer = false,
|
{bool isFileTransfer = false,
|
||||||
bool isTcpTunneling = false,
|
bool isTcpTunneling = false,
|
||||||
bool isRDP = false}) async {
|
bool isRDP = false,
|
||||||
|
bool forceRelay = false}) async {
|
||||||
if (id == '') return;
|
if (id == '') return;
|
||||||
id = id.replaceAll(' ', '');
|
id = id.replaceAll(' ', '');
|
||||||
assert(!(isFileTransfer && isTcpTunneling && isRDP),
|
assert(!(isFileTransfer && isTcpTunneling && isRDP),
|
||||||
@ -1430,18 +1432,18 @@ connect(BuildContext context, String id,
|
|||||||
|
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
if (desktopType == DesktopType.main) {
|
if (desktopType == DesktopType.main) {
|
||||||
await connectMainDesktop(
|
await connectMainDesktop(id,
|
||||||
id,
|
isFileTransfer: isFileTransfer,
|
||||||
isFileTransfer: isFileTransfer,
|
isTcpTunneling: isTcpTunneling,
|
||||||
isTcpTunneling: isTcpTunneling,
|
isRDP: isRDP,
|
||||||
isRDP: isRDP,
|
forceRelay: forceRelay);
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
await rustDeskWinManager.call(WindowType.Main, kWindowConnect, {
|
await rustDeskWinManager.call(WindowType.Main, kWindowConnect, {
|
||||||
'id': id,
|
'id': id,
|
||||||
'isFileTransfer': isFileTransfer,
|
'isFileTransfer': isFileTransfer,
|
||||||
'isTcpTunneling': isTcpTunneling,
|
'isTcpTunneling': isTcpTunneling,
|
||||||
'isRDP': isRDP,
|
'isRDP': isRDP,
|
||||||
|
"forceRelay": forceRelay,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1735,6 +1737,7 @@ Future<void> updateSystemWindowTheme() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// macOS only
|
/// macOS only
|
||||||
///
|
///
|
||||||
/// Note: not found a general solution for rust based AVFoundation bingding.
|
/// Note: not found a general solution for rust based AVFoundation bingding.
|
||||||
|
|||||||
@ -66,7 +66,8 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
_idFocusNode.addListener(() {
|
_idFocusNode.addListener(() {
|
||||||
_idInputFocused.value = _idFocusNode.hasFocus;
|
_idInputFocused.value = _idFocusNode.hasFocus;
|
||||||
// select all to faciliate removing text, just following the behavior of address input of chrome
|
// 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);
|
windowManager.addListener(this);
|
||||||
}
|
}
|
||||||
@ -149,8 +150,11 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
/// Callback for the connect button.
|
/// Callback for the connect button.
|
||||||
/// Connects to the selected peer.
|
/// Connects to the selected peer.
|
||||||
void onConnect({bool isFileTransfer = false}) {
|
void onConnect({bool isFileTransfer = false}) {
|
||||||
final id = _idController.id;
|
var id = _idController.id;
|
||||||
connect(context, id, isFileTransfer: isFileTransfer);
|
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.
|
/// UI for the remote ID TextField.
|
||||||
|
|||||||
@ -556,6 +556,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
isFileTransfer: call.arguments['isFileTransfer'],
|
isFileTransfer: call.arguments['isFileTransfer'],
|
||||||
isTcpTunneling: call.arguments['isTcpTunneling'],
|
isTcpTunneling: call.arguments['isTcpTunneling'],
|
||||||
isRDP: call.arguments['isRDP'],
|
isRDP: call.arguments['isRDP'],
|
||||||
|
forceRelay: call.arguments['forceRelay'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -46,8 +46,10 @@ enum MouseFocusScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FileManagerPage extends StatefulWidget {
|
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 String id;
|
||||||
|
final bool? forceRelay;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _FileManagerPageState();
|
State<StatefulWidget> createState() => _FileManagerPageState();
|
||||||
@ -102,7 +104,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_ffi = FFI();
|
_ffi = FFI();
|
||||||
_ffi.start(widget.id, isFileTransfer: true);
|
_ffi.start(widget.id, isFileTransfer: true, forceRelay: widget.forceRelay);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_ffi.dialogManager
|
_ffi.dialogManager
|
||||||
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
.showLoading(translate('Connecting...'), onCancel: closeConnection);
|
||||||
|
|||||||
@ -41,7 +41,11 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
|||||||
selectedIcon: selectedIcon,
|
selectedIcon: selectedIcon,
|
||||||
unselectedIcon: unselectedIcon,
|
unselectedIcon: unselectedIcon,
|
||||||
onTabCloseButton: () => () => tabController.closeBy(params['id']),
|
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
|
@override
|
||||||
@ -64,7 +68,11 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
|||||||
selectedIcon: selectedIcon,
|
selectedIcon: selectedIcon,
|
||||||
unselectedIcon: unselectedIcon,
|
unselectedIcon: unselectedIcon,
|
||||||
onTabCloseButton: () => tabController.closeBy(id),
|
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") {
|
} else if (call.method == "onDestroy") {
|
||||||
tabController.clear();
|
tabController.clear();
|
||||||
} else if (call.method == kWindowActionRebuild) {
|
} else if (call.method == kWindowActionRebuild) {
|
||||||
|
|||||||
@ -26,10 +26,12 @@ class _PortForward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PortForwardPage extends StatefulWidget {
|
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);
|
: super(key: key);
|
||||||
final String id;
|
final String id;
|
||||||
final bool isRDP;
|
final bool isRDP;
|
||||||
|
final bool? forceRelay;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PortForwardPage> createState() => _PortForwardPageState();
|
State<PortForwardPage> createState() => _PortForwardPageState();
|
||||||
@ -47,7 +49,7 @@ class _PortForwardPageState extends State<PortForwardPage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_ffi = FFI();
|
_ffi = FFI();
|
||||||
_ffi.start(widget.id, isPortForward: true);
|
_ffi.start(widget.id, isPortForward: true, forceRelay: widget.forceRelay);
|
||||||
Get.put(_ffi, tag: 'pf_${widget.id}');
|
Get.put(_ffi, tag: 'pf_${widget.id}');
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
|||||||
key: ValueKey(params['id']),
|
key: ValueKey(params['id']),
|
||||||
id: params['id'],
|
id: params['id'],
|
||||||
isRDP: isRDP,
|
isRDP: isRDP,
|
||||||
|
forceRelay: params['forceRelay'],
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,12 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
|||||||
label: id,
|
label: id,
|
||||||
selectedIcon: selectedIcon,
|
selectedIcon: selectedIcon,
|
||||||
unselectedIcon: unselectedIcon,
|
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") {
|
} else if (call.method == "onDestroy") {
|
||||||
tabController.clear();
|
tabController.clear();
|
||||||
} else if (call.method == kWindowActionRebuild) {
|
} else if (call.method == kWindowActionRebuild) {
|
||||||
|
|||||||
@ -34,11 +34,13 @@ class RemotePage extends StatefulWidget {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.menubarState,
|
required this.menubarState,
|
||||||
this.switchUuid,
|
this.switchUuid,
|
||||||
|
this.forceRelay,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final MenubarState menubarState;
|
final MenubarState menubarState;
|
||||||
final String? switchUuid;
|
final String? switchUuid;
|
||||||
|
final bool? forceRelay;
|
||||||
final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null);
|
final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null);
|
||||||
|
|
||||||
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
||||||
@ -107,6 +109,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_ffi.start(
|
_ffi.start(
|
||||||
widget.id,
|
widget.id,
|
||||||
switchUuid: widget.switchUuid,
|
switchUuid: widget.switchUuid,
|
||||||
|
forceRelay: widget.forceRelay,
|
||||||
);
|
);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
|
|||||||
@ -70,6 +70,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
id: peerId,
|
id: peerId,
|
||||||
menubarState: _menubarState,
|
menubarState: _menubarState,
|
||||||
switchUuid: params['switch_uuid'],
|
switchUuid: params['switch_uuid'],
|
||||||
|
forceRelay: params['forceRelay'],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
_update_remote_count();
|
_update_remote_count();
|
||||||
@ -104,6 +105,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
id: id,
|
id: id,
|
||||||
menubarState: _menubarState,
|
menubarState: _menubarState,
|
||||||
switchUuid: switchUuid,
|
switchUuid: switchUuid,
|
||||||
|
forceRelay: args['forceRelay'],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
} else if (call.method == "onDestroy") {
|
} else if (call.method == "onDestroy") {
|
||||||
|
|||||||
@ -1339,7 +1339,8 @@ class FFI {
|
|||||||
void start(String id,
|
void start(String id,
|
||||||
{bool isFileTransfer = false,
|
{bool isFileTransfer = false,
|
||||||
bool isPortForward = false,
|
bool isPortForward = false,
|
||||||
String? switchUuid}) {
|
String? switchUuid,
|
||||||
|
bool? forceRelay}) {
|
||||||
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
||||||
if (isFileTransfer) {
|
if (isFileTransfer) {
|
||||||
connType = ConnType.fileTransfer;
|
connType = ConnType.fileTransfer;
|
||||||
@ -1355,11 +1356,11 @@ class FFI {
|
|||||||
}
|
}
|
||||||
// ignore: unused_local_variable
|
// ignore: unused_local_variable
|
||||||
final addRes = bind.sessionAddSync(
|
final addRes = bind.sessionAddSync(
|
||||||
id: id,
|
id: id,
|
||||||
isFileTransfer: isFileTransfer,
|
isFileTransfer: isFileTransfer,
|
||||||
isPortForward: isPortForward,
|
isPortForward: isPortForward,
|
||||||
switchUuid: switchUuid ?? "",
|
switchUuid: switchUuid ?? "",
|
||||||
);
|
forceRelay: forceRelay ?? false);
|
||||||
final stream = bind.sessionStart(id: id);
|
final stream = bind.sessionStart(id: id);
|
||||||
final cb = ffiModel.startEventListener(id);
|
final cb = ffiModel.startEventListener(id);
|
||||||
() async {
|
() async {
|
||||||
|
|||||||
@ -41,11 +41,15 @@ class RustDeskMultiWindowManager {
|
|||||||
int? _fileTransferWindowId;
|
int? _fileTransferWindowId;
|
||||||
int? _portForwardWindowId;
|
int? _portForwardWindowId;
|
||||||
|
|
||||||
Future<dynamic> newRemoteDesktop(String remoteId,
|
Future<dynamic> newRemoteDesktop(
|
||||||
{String? switch_uuid}) async {
|
String remoteId, {
|
||||||
|
String? switch_uuid,
|
||||||
|
bool? forceRelay,
|
||||||
|
}) async {
|
||||||
var params = {
|
var params = {
|
||||||
"type": WindowType.RemoteDesktop.index,
|
"type": WindowType.RemoteDesktop.index,
|
||||||
"id": remoteId,
|
"id": remoteId,
|
||||||
|
"forceRelay": forceRelay
|
||||||
};
|
};
|
||||||
if (switch_uuid != null) {
|
if (switch_uuid != null) {
|
||||||
params['switch_uuid'] = switch_uuid;
|
params['switch_uuid'] = switch_uuid;
|
||||||
@ -78,9 +82,12 @@ class RustDeskMultiWindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> newFileTransfer(String remoteId) async {
|
Future<dynamic> newFileTransfer(String remoteId, {bool? forceRelay}) async {
|
||||||
final msg =
|
var msg = jsonEncode({
|
||||||
jsonEncode({"type": WindowType.FileTransfer.index, "id": remoteId});
|
"type": WindowType.FileTransfer.index,
|
||||||
|
"id": remoteId,
|
||||||
|
"forceRelay": forceRelay,
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||||
@ -107,9 +114,14 @@ class RustDeskMultiWindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> newPortForward(String remoteId, bool isRDP) async {
|
Future<dynamic> newPortForward(String remoteId, bool isRDP,
|
||||||
final msg = jsonEncode(
|
{bool? forceRelay}) async {
|
||||||
{"type": WindowType.PortForward.index, "id": remoteId, "isRDP": isRDP});
|
final msg = jsonEncode({
|
||||||
|
"type": WindowType.PortForward.index,
|
||||||
|
"id": remoteId,
|
||||||
|
"isRDP": isRDP,
|
||||||
|
"forceRelay": forceRelay,
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||||
|
|||||||
@ -3,15 +3,15 @@ use std::{
|
|||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
ops::{Deref, Not},
|
ops::{Deref, Not},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{Arc, atomic::AtomicBool, mpsc, Mutex, RwLock},
|
sync::{atomic::AtomicBool, mpsc, Arc, Mutex, RwLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use async_trait::async_trait;
|
pub use async_trait::async_trait;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
||||||
use cpal::{
|
use cpal::{
|
||||||
Device,
|
traits::{DeviceTrait, HostTrait, StreamTrait},
|
||||||
Host, StreamConfig, traits::{DeviceTrait, HostTrait, StreamTrait},
|
Device, Host, StreamConfig,
|
||||||
};
|
};
|
||||||
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
@ -19,26 +19,26 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
pub use file_trait::FileManager;
|
pub use file_trait::FileManager;
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
AddrMangle,
|
|
||||||
allow_err,
|
allow_err,
|
||||||
anyhow::{anyhow, Context},
|
anyhow::{anyhow, Context},
|
||||||
bail,
|
bail,
|
||||||
config::{
|
config::{
|
||||||
Config, CONNECT_TIMEOUT, PeerConfig, PeerInfoSerde, READ_TIMEOUT, RELAY_PORT,
|
Config, PeerConfig, PeerInfoSerde, CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT,
|
||||||
RENDEZVOUS_TIMEOUT,
|
RENDEZVOUS_TIMEOUT,
|
||||||
}, get_version_number,
|
},
|
||||||
log,
|
get_version_number, log,
|
||||||
message_proto::{*, option_message::BoolOption},
|
message_proto::{option_message::BoolOption, *},
|
||||||
protobuf::Message as _,
|
protobuf::Message as _,
|
||||||
rand,
|
rand,
|
||||||
rendezvous_proto::*,
|
rendezvous_proto::*,
|
||||||
ResultType,
|
|
||||||
socket_client,
|
socket_client,
|
||||||
sodiumoxide::crypto::{box_, secretbox, sign},
|
sodiumoxide::crypto::{box_, secretbox, sign},
|
||||||
Stream, timeout, tokio::time::Duration,
|
timeout,
|
||||||
|
tokio::time::Duration,
|
||||||
|
AddrMangle, ResultType, Stream,
|
||||||
};
|
};
|
||||||
pub use helper::*;
|
|
||||||
pub use helper::LatencyController;
|
pub use helper::LatencyController;
|
||||||
|
pub use helper::*;
|
||||||
use scrap::{
|
use scrap::{
|
||||||
codec::{Decoder, DecoderCfg},
|
codec::{Decoder, DecoderCfg},
|
||||||
record::{Recorder, RecorderContext},
|
record::{Recorder, RecorderContext},
|
||||||
@ -943,7 +943,13 @@ impl LoginConfigHandler {
|
|||||||
///
|
///
|
||||||
/// * `id` - id of peer
|
/// * `id` - id of peer
|
||||||
/// * `conn_type` - Connection type enum.
|
/// * `conn_type` - Connection type enum.
|
||||||
pub fn initialize(&mut self, id: String, conn_type: ConnType, switch_uuid: Option<String>) {
|
pub fn initialize(
|
||||||
|
&mut self,
|
||||||
|
id: String,
|
||||||
|
conn_type: ConnType,
|
||||||
|
switch_uuid: Option<String>,
|
||||||
|
force_relay: bool,
|
||||||
|
) {
|
||||||
self.id = id;
|
self.id = id;
|
||||||
self.conn_type = conn_type;
|
self.conn_type = conn_type;
|
||||||
let config = self.load_config();
|
let config = self.load_config();
|
||||||
@ -952,7 +958,7 @@ impl LoginConfigHandler {
|
|||||||
self.session_id = rand::random();
|
self.session_id = rand::random();
|
||||||
self.supported_encoding = None;
|
self.supported_encoding = None;
|
||||||
self.restarting_remote_device = false;
|
self.restarting_remote_device = false;
|
||||||
self.force_relay = !self.get_option("force-always-relay").is_empty();
|
self.force_relay = !self.get_option("force-always-relay").is_empty() || force_relay;
|
||||||
self.direct = None;
|
self.direct = None;
|
||||||
self.received = false;
|
self.received = false;
|
||||||
self.switch_uuid = switch_uuid;
|
self.switch_uuid = switch_uuid;
|
||||||
|
|||||||
@ -3,19 +3,19 @@ use crate::{
|
|||||||
flutter_ffi::EventToUI,
|
flutter_ffi::EventToUI,
|
||||||
ui_session_interface::{io_loop, InvokeUiSession, Session},
|
ui_session_interface::{io_loop, InvokeUiSession, Session},
|
||||||
};
|
};
|
||||||
use flutter_rust_bridge::{StreamSink};
|
use flutter_rust_bridge::StreamSink;
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
|
bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
|
||||||
ResultType,
|
ResultType,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ffi::CString,
|
ffi::CString,
|
||||||
os::raw::{c_char, c_int},
|
os::raw::{c_char, c_int},
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
|
|
||||||
pub(super) const APP_TYPE_MAIN: &str = "main";
|
pub(super) const APP_TYPE_MAIN: &str = "main";
|
||||||
pub(super) const APP_TYPE_CM: &str = "cm";
|
pub(super) const APP_TYPE_CM: &str = "cm";
|
||||||
@ -114,7 +114,7 @@ pub struct FlutterHandler {
|
|||||||
// SAFETY: [rgba] is guarded by [rgba_valid], and it's safe to reach [rgba] with `rgba_valid == true`.
|
// SAFETY: [rgba] is guarded by [rgba_valid], and it's safe to reach [rgba] with `rgba_valid == true`.
|
||||||
// We must check the `rgba_valid` before reading [rgba].
|
// We must check the `rgba_valid` before reading [rgba].
|
||||||
pub rgba: Arc<RwLock<Vec<u8>>>,
|
pub rgba: Arc<RwLock<Vec<u8>>>,
|
||||||
pub rgba_valid: Arc<AtomicBool>
|
pub rgba_valid: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlutterHandler {
|
impl FlutterHandler {
|
||||||
@ -449,6 +449,7 @@ pub fn session_add(
|
|||||||
is_file_transfer: bool,
|
is_file_transfer: bool,
|
||||||
is_port_forward: bool,
|
is_port_forward: bool,
|
||||||
switch_uuid: &str,
|
switch_uuid: &str,
|
||||||
|
force_relay: bool,
|
||||||
) -> ResultType<()> {
|
) -> ResultType<()> {
|
||||||
let session_id = get_session_id(id.to_owned());
|
let session_id = get_session_id(id.to_owned());
|
||||||
LocalConfig::set_remote_id(&session_id);
|
LocalConfig::set_remote_id(&session_id);
|
||||||
@ -477,7 +478,7 @@ pub fn session_add(
|
|||||||
.lc
|
.lc
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.initialize(session_id, conn_type, switch_uuid);
|
.initialize(session_id, conn_type, switch_uuid, force_relay);
|
||||||
|
|
||||||
if let Some(same_id_session) = SESSIONS.write().unwrap().insert(id.to_owned(), session) {
|
if let Some(same_id_session) = SESSIONS.write().unwrap().insert(id.to_owned(), session) {
|
||||||
same_id_session.close();
|
same_id_session.close();
|
||||||
@ -667,7 +668,7 @@ pub fn session_get_rgba_size(id: *const char) -> usize {
|
|||||||
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
|
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
|
||||||
if let Ok(id) = id.to_str() {
|
if let Ok(id) = id.to_str() {
|
||||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
|
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
|
||||||
return session.rgba.read().unwrap().len();
|
return session.rgba.read().unwrap().len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0
|
0
|
||||||
@ -692,4 +693,4 @@ pub fn session_next_rgba(id: *const char) {
|
|||||||
return session.next_rgba();
|
return session.next_rgba();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use crate::ui_session_interface::InvokeUiSession;
|
||||||
use crate::{
|
use crate::{
|
||||||
client::file_trait::FileManager,
|
client::file_trait::FileManager,
|
||||||
common::make_fd_to_json,
|
common::make_fd_to_json,
|
||||||
@ -20,7 +21,6 @@ use std::{
|
|||||||
os::raw::c_char,
|
os::raw::c_char,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
use crate::ui_session_interface::InvokeUiSession;
|
|
||||||
|
|
||||||
// use crate::hbbs_http::account::AuthResult;
|
// use crate::hbbs_http::account::AuthResult;
|
||||||
|
|
||||||
@ -84,8 +84,15 @@ pub fn session_add_sync(
|
|||||||
is_file_transfer: bool,
|
is_file_transfer: bool,
|
||||||
is_port_forward: bool,
|
is_port_forward: bool,
|
||||||
switch_uuid: String,
|
switch_uuid: String,
|
||||||
|
force_relay: bool,
|
||||||
) -> SyncReturn<String> {
|
) -> SyncReturn<String> {
|
||||||
if let Err(e) = session_add(&id, is_file_transfer, is_port_forward, &switch_uuid) {
|
if let Err(e) = session_add(
|
||||||
|
&id,
|
||||||
|
is_file_transfer,
|
||||||
|
is_port_forward,
|
||||||
|
&switch_uuid,
|
||||||
|
force_relay,
|
||||||
|
) {
|
||||||
SyncReturn(format!("Failed to add session with id {}, {}", &id, e))
|
SyncReturn(format!("Failed to add session with id {}, {}", &id, e))
|
||||||
} else {
|
} else {
|
||||||
SyncReturn("".to_owned())
|
SyncReturn("".to_owned())
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
|
use std::sync::RwLock;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
use std::sync::RwLock;
|
|
||||||
|
|
||||||
use sciter::{
|
use sciter::{
|
||||||
dom::{
|
dom::{
|
||||||
Element,
|
event::{EventReason, BEHAVIOR_EVENTS, EVENT_GROUPS, PHASE_MASK},
|
||||||
event::{BEHAVIOR_EVENTS, EVENT_GROUPS, EventReason, PHASE_MASK}, HELEMENT,
|
Element, HELEMENT,
|
||||||
},
|
},
|
||||||
make_args,
|
make_args,
|
||||||
|
video::{video_destination, AssetPtr, COLOR_SPACE},
|
||||||
Value,
|
Value,
|
||||||
video::{AssetPtr, COLOR_SPACE, video_destination},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use hbb_common::tokio::io::AsyncReadExt;
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
|
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
|
||||||
};
|
};
|
||||||
use hbb_common::tokio::io::AsyncReadExt;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::*,
|
client::*,
|
||||||
@ -286,7 +286,9 @@ impl InvokeUiSession for SciterHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// RGBA is directly rendered by [on_rgba]. No need to store the rgba for the sciter ui.
|
/// RGBA is directly rendered by [on_rgba]. No need to store the rgba for the sciter ui.
|
||||||
fn get_rgba(&self) -> *const u8 { std::ptr::null() }
|
fn get_rgba(&self) -> *const u8 {
|
||||||
|
std::ptr::null()
|
||||||
|
}
|
||||||
|
|
||||||
fn next_rgba(&mut self) {}
|
fn next_rgba(&mut self) {}
|
||||||
}
|
}
|
||||||
@ -467,7 +469,11 @@ impl SciterSession {
|
|||||||
ConnType::DEFAULT_CONN
|
ConnType::DEFAULT_CONN
|
||||||
};
|
};
|
||||||
|
|
||||||
session.lc.write().unwrap().initialize(id, conn_type, None);
|
session
|
||||||
|
.lc
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.initialize(id, conn_type, None, false);
|
||||||
|
|
||||||
Self(session)
|
Self(session)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user