Merge pull request #4376 from Kingtous/master
fix: rdp entry for port forward
This commit is contained in:
commit
2d7bebb54b
@ -49,7 +49,10 @@ class _PortForwardPageState extends State<PortForwardPage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_ffi = FFI();
|
_ffi = FFI();
|
||||||
_ffi.start(widget.id, isPortForward: true, forceRelay: widget.forceRelay);
|
_ffi.start(widget.id,
|
||||||
|
isPortForward: true,
|
||||||
|
forceRelay: widget.forceRelay,
|
||||||
|
isRdp: widget.isRDP);
|
||||||
Get.put(_ffi, tag: 'pf_${widget.id}');
|
Get.put(_ffi, tag: 'pf_${widget.id}');
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
|
@ -1597,6 +1597,7 @@ class FFI {
|
|||||||
void start(String id,
|
void start(String id,
|
||||||
{bool isFileTransfer = false,
|
{bool isFileTransfer = false,
|
||||||
bool isPortForward = false,
|
bool isPortForward = false,
|
||||||
|
bool isRdp = false,
|
||||||
String? switchUuid,
|
String? switchUuid,
|
||||||
String? password,
|
String? password,
|
||||||
bool? forceRelay}) {
|
bool? forceRelay}) {
|
||||||
@ -1619,6 +1620,7 @@ class FFI {
|
|||||||
id: id,
|
id: id,
|
||||||
isFileTransfer: isFileTransfer,
|
isFileTransfer: isFileTransfer,
|
||||||
isPortForward: isPortForward,
|
isPortForward: isPortForward,
|
||||||
|
isRdp: isRdp,
|
||||||
switchUuid: switchUuid ?? "",
|
switchUuid: switchUuid ?? "",
|
||||||
forceRelay: forceRelay ?? false,
|
forceRelay: forceRelay ?? false,
|
||||||
password: password ?? "",
|
password: password ?? "",
|
||||||
|
@ -505,7 +505,7 @@ impl InvokeUiSession for FlutterHandler {
|
|||||||
match hook {
|
match hook {
|
||||||
SessionHook::OnSessionRgba(cb) => {
|
SessionHook::OnSessionRgba(cb) => {
|
||||||
cb(key.to_owned(), rgba);
|
cb(key.to_owned(), rgba);
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the current rgba is not fetched by flutter, i.e., is valid.
|
// If the current rgba is not fetched by flutter, i.e., is valid.
|
||||||
@ -688,6 +688,7 @@ pub fn session_add(
|
|||||||
id: &str,
|
id: &str,
|
||||||
is_file_transfer: bool,
|
is_file_transfer: bool,
|
||||||
is_port_forward: bool,
|
is_port_forward: bool,
|
||||||
|
is_rdp: bool,
|
||||||
switch_uuid: &str,
|
switch_uuid: &str,
|
||||||
force_relay: bool,
|
force_relay: bool,
|
||||||
password: String,
|
password: String,
|
||||||
@ -704,11 +705,14 @@ pub fn session_add(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO rdp
|
|
||||||
let conn_type = if is_file_transfer {
|
let conn_type = if is_file_transfer {
|
||||||
ConnType::FILE_TRANSFER
|
ConnType::FILE_TRANSFER
|
||||||
} else if is_port_forward {
|
} else if is_port_forward {
|
||||||
ConnType::PORT_FORWARD
|
if is_rdp {
|
||||||
|
ConnType::RDP
|
||||||
|
} else {
|
||||||
|
ConnType::PORT_FORWARD
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ConnType::DEFAULT_CONN
|
ConnType::DEFAULT_CONN
|
||||||
};
|
};
|
||||||
@ -725,7 +729,11 @@ pub fn session_add(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.initialize(session_id, conn_type, switch_uuid, force_relay);
|
.initialize(session_id, conn_type, switch_uuid, force_relay);
|
||||||
|
|
||||||
if let Some(same_id_session) = SESSIONS.write().unwrap().insert(id.to_owned(), session.clone()) {
|
if let Some(same_id_session) = SESSIONS
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.insert(id.to_owned(), session.clone())
|
||||||
|
{
|
||||||
same_id_session.close();
|
same_id_session.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1068,4 +1076,4 @@ unsafe extern "C" fn get_rgba() {}
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum SessionHook {
|
pub enum SessionHook {
|
||||||
OnSessionRgba(fn(String, &mut scrap::ImageRgb)),
|
OnSessionRgba(fn(String, &mut scrap::ImageRgb)),
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ pub fn session_add_sync(
|
|||||||
id: String,
|
id: String,
|
||||||
is_file_transfer: bool,
|
is_file_transfer: bool,
|
||||||
is_port_forward: bool,
|
is_port_forward: bool,
|
||||||
|
is_rdp: bool,
|
||||||
switch_uuid: String,
|
switch_uuid: String,
|
||||||
force_relay: bool,
|
force_relay: bool,
|
||||||
password: String,
|
password: String,
|
||||||
@ -84,6 +85,7 @@ pub fn session_add_sync(
|
|||||||
&id,
|
&id,
|
||||||
is_file_transfer,
|
is_file_transfer,
|
||||||
is_port_forward,
|
is_port_forward,
|
||||||
|
is_rdp,
|
||||||
&switch_uuid,
|
&switch_uuid,
|
||||||
force_relay,
|
force_relay,
|
||||||
password,
|
password,
|
||||||
|
@ -903,7 +903,6 @@ fn get_install_info_with_subkey(subkey: String) -> (String, String, String, Stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
|
pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
|
||||||
#[cfg(feature = "flutter")]
|
|
||||||
let main_raw = format!(
|
let main_raw = format!(
|
||||||
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
|
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
|
||||||
PathBuf::from(src_raw)
|
PathBuf::from(src_raw)
|
||||||
@ -913,12 +912,6 @@ pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
_path
|
_path
|
||||||
);
|
);
|
||||||
#[cfg(not(feature = "flutter"))]
|
|
||||||
let main_raw = format!(
|
|
||||||
"copy /Y \"{src_raw}\" \"{raw}\"",
|
|
||||||
src_raw = src_raw,
|
|
||||||
raw = _raw
|
|
||||||
);
|
|
||||||
return main_raw;
|
return main_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,18 +932,6 @@ pub fn copy_exe_cmd(src_exe: &str, exe: &str, path: &str) -> String {
|
|||||||
pub fn update_me() -> ResultType<()> {
|
pub fn update_me() -> ResultType<()> {
|
||||||
let (_, path, _, exe, _dll) = get_install_info();
|
let (_, path, _, exe, _dll) = get_install_info();
|
||||||
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
|
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
|
||||||
#[cfg(not(feature = "flutter"))]
|
|
||||||
let src_dll = std::env::current_exe()?
|
|
||||||
.parent()
|
|
||||||
.unwrap_or(&Path::new(&get_default_install_path()))
|
|
||||||
.join("sciter.dll")
|
|
||||||
.to_str()
|
|
||||||
.unwrap_or("")
|
|
||||||
.to_owned();
|
|
||||||
#[cfg(feature = "flutter")]
|
|
||||||
let copy_dll = "".to_string();
|
|
||||||
#[cfg(not(feature = "flutter"))]
|
|
||||||
let copy_dll = copy_raw_cmd(&src_dll, &_dll, &path);
|
|
||||||
let cmds = format!(
|
let cmds = format!(
|
||||||
"
|
"
|
||||||
chcp 65001
|
chcp 65001
|
||||||
@ -958,12 +939,10 @@ pub fn update_me() -> ResultType<()> {
|
|||||||
taskkill /F /IM {broker_exe}
|
taskkill /F /IM {broker_exe}
|
||||||
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
|
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
|
||||||
{copy_exe}
|
{copy_exe}
|
||||||
{copy_dll}
|
|
||||||
sc start {app_name}
|
sc start {app_name}
|
||||||
{lic}
|
{lic}
|
||||||
",
|
",
|
||||||
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
|
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
|
||||||
copy_dll = copy_dll,
|
|
||||||
broker_exe = WIN_MAG_INJECTED_PROCESS_EXE,
|
broker_exe = WIN_MAG_INJECTED_PROCESS_EXE,
|
||||||
app_name = crate::get_app_name(),
|
app_name = crate::get_app_name(),
|
||||||
lic = register_licence(),
|
lic = register_licence(),
|
||||||
@ -1133,18 +1112,6 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
|
|||||||
app_name = crate::get_app_name(),
|
app_name = crate::get_app_name(),
|
||||||
);
|
);
|
||||||
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_string();
|
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_string();
|
||||||
#[cfg(not(feature = "flutter"))]
|
|
||||||
let src_dll = std::env::current_exe()?
|
|
||||||
.parent()
|
|
||||||
.unwrap_or(&Path::new(&get_default_install_path()))
|
|
||||||
.join("sciter.dll")
|
|
||||||
.to_str()
|
|
||||||
.unwrap_or("")
|
|
||||||
.to_owned();
|
|
||||||
#[cfg(feature = "flutter")]
|
|
||||||
let copy_dll = "".to_string();
|
|
||||||
#[cfg(not(feature = "flutter"))]
|
|
||||||
let copy_dll = copy_raw_cmd(&src_dll, &_dll, &path);
|
|
||||||
|
|
||||||
let install_cert = if options.contains("driverCert") {
|
let install_cert = if options.contains("driverCert") {
|
||||||
format!("\"{}\" --install-cert \"RustDeskIddDriver.cer\"", src_exe)
|
format!("\"{}\" --install-cert \"RustDeskIddDriver.cer\"", src_exe)
|
||||||
@ -1158,7 +1125,6 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
|
|||||||
chcp 65001
|
chcp 65001
|
||||||
md \"{path}\"
|
md \"{path}\"
|
||||||
{copy_exe}
|
{copy_exe}
|
||||||
{copy_dll}
|
|
||||||
reg add {subkey} /f
|
reg add {subkey} /f
|
||||||
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
|
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
|
||||||
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
|
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
|
||||||
@ -1218,7 +1184,6 @@ sc delete {app_name}
|
|||||||
&dels
|
&dels
|
||||||
},
|
},
|
||||||
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
|
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
|
||||||
copy_dll = copy_dll
|
|
||||||
);
|
);
|
||||||
run_cmds(cmds, debug, "install")?;
|
run_cmds(cmds, debug, "install")?;
|
||||||
std::thread::sleep(std::time::Duration::from_millis(2000));
|
std::thread::sleep(std::time::Duration::from_millis(2000));
|
||||||
|
@ -92,6 +92,7 @@ pub async fn listen(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Some(Data::NewRDP) => {
|
Some(Data::NewRDP) => {
|
||||||
|
println!("receive run_rdp from ui_receiver");
|
||||||
run_rdp(addr.port());
|
run_rdp(addr.port());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -88,11 +88,11 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_port_forward(&self) -> bool {
|
pub fn is_port_forward(&self) -> bool {
|
||||||
self.lc
|
let conn_type = self.lc
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.conn_type
|
.conn_type;
|
||||||
.eq(&ConnType::PORT_FORWARD)
|
conn_type == ConnType::PORT_FORWARD || conn_type == ConnType::RDP
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user