mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-04 06:07:19 +02:00
Merge pull request #42 from winapps-org/rewrite-freerdp-backend
Add freerdp backend
This commit is contained in:
commit
3e8c6dbb94
@ -1,4 +1,4 @@
|
||||
use clap::Command;
|
||||
use clap::{arg, Command};
|
||||
use winapps::freerdp::freerdp_back::Freerdp;
|
||||
use winapps::quickemu::{create_vm, kill_vm, start_vm};
|
||||
use winapps::RemoteClient;
|
||||
@ -11,6 +11,11 @@ fn cli() -> Command {
|
||||
.allow_external_subcommands(true)
|
||||
.subcommand(Command::new("check").about("Checks remote connection"))
|
||||
.subcommand(Command::new("connect").about("Connects to remote"))
|
||||
.subcommand(
|
||||
Command::new("run")
|
||||
.about("Connects to app on remote")
|
||||
.arg(arg!(<APP> "App to open")),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("vm")
|
||||
.about("Manage a windows 10 vm using quickemu")
|
||||
@ -27,17 +32,24 @@ fn main() {
|
||||
let cli = cli();
|
||||
let matches = cli.clone().get_matches();
|
||||
|
||||
let config = winapps::load_config(None);
|
||||
let client: &dyn RemoteClient = &Freerdp {};
|
||||
let config = winapps::load_config(None);
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("check", _)) => {
|
||||
println!("Checking remote connection");
|
||||
|
||||
client.check_depends(config);
|
||||
}
|
||||
Some(("connect", _)) => {
|
||||
println!("Connecting to remote");
|
||||
client.run_app(config, "explorer");
|
||||
|
||||
client.run_app(config, None);
|
||||
}
|
||||
Some(("run", sub_matches)) => {
|
||||
println!("Connecting to app on remote");
|
||||
|
||||
client.run_app(config, sub_matches.get_one::<String>("APP"));
|
||||
}
|
||||
|
||||
Some(("vm", command)) => {
|
||||
|
@ -6,20 +6,57 @@ pub mod freerdp_back {
|
||||
pub struct Freerdp {}
|
||||
|
||||
impl RemoteClient for Freerdp {
|
||||
fn check_depends(&self, _config: Config) {
|
||||
fn check_depends(&self, config: Config) {
|
||||
let mut xfreerdp = Command::new("xfreerdp");
|
||||
xfreerdp.stdout(Stdio::null());
|
||||
xfreerdp.stderr(Stdio::null());
|
||||
xfreerdp.args(["-h"]);
|
||||
xfreerdp
|
||||
.spawn()
|
||||
.expect("Freerdp execution failed! It needs to be installed!");
|
||||
println!("Freerdp found!");
|
||||
|
||||
println!("Checks success!");
|
||||
println!("All dependencies found!");
|
||||
println!("Running explorer as test!");
|
||||
println!("Check yourself if it appears correctly!");
|
||||
|
||||
self.run_app(config, Some(&"explorer.exe".to_string()));
|
||||
|
||||
println!("Test finished!");
|
||||
}
|
||||
|
||||
fn run_app(&self, _config: Config, _app: &str) {
|
||||
todo!()
|
||||
fn run_app(&self, config: Config, app: Option<&String>) {
|
||||
let mut xfreerdp = Command::new("xfreerdp");
|
||||
xfreerdp.stdout(Stdio::null());
|
||||
xfreerdp.stderr(Stdio::null());
|
||||
match app {
|
||||
Some(exe) => {
|
||||
xfreerdp.args([
|
||||
&format!("/app:{}", exe),
|
||||
&format!("/d:{}", &config.rdp.domain),
|
||||
&format!("/u:{}", &config.rdp.username),
|
||||
&format!("/p:{}", &config.rdp.password),
|
||||
&format!("/v:{}", &config.rdp.host),
|
||||
"/dynamic-resolution",
|
||||
"+auto-reconnect",
|
||||
"+clipboard",
|
||||
"+home-drive",
|
||||
]);
|
||||
}
|
||||
None => {
|
||||
xfreerdp.args([
|
||||
&format!("/d:{}", &config.rdp.domain),
|
||||
&format!("/u:{}", &config.rdp.username),
|
||||
&format!("/p:{}", &config.rdp.password),
|
||||
&format!("/v:{}", &config.rdp.host),
|
||||
"/dynamic-resolution",
|
||||
"+auto-reconnect",
|
||||
"+clipboard",
|
||||
"+home-drive",
|
||||
]);
|
||||
}
|
||||
}
|
||||
xfreerdp.spawn().expect("Freerdp execution failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub mod freerdp;
|
||||
pub trait RemoteClient {
|
||||
fn check_depends(&self, config: Config);
|
||||
|
||||
fn run_app(&self, config: Config, app: &str);
|
||||
fn run_app(&self, config: Config, app: Option<&String>);
|
||||
}
|
||||
|
||||
#[derive(new, Debug, Deserialize, Serialize)]
|
||||
@ -45,13 +45,13 @@ pub struct HostConfig {
|
||||
|
||||
#[derive(new, Debug, Deserialize, Serialize)]
|
||||
pub struct RemoteConfig {
|
||||
#[new(value = "\"RDPWindows\".to_string()")]
|
||||
#[new(value = "\"127.0.0.1\".to_string()")]
|
||||
host: String,
|
||||
#[new(value = "\"WORKGROUP\".to_string()")]
|
||||
domain: String,
|
||||
#[new(value = "\"RDPUser\".to_string()")]
|
||||
#[new(value = "\"Quickemu\".to_string()")]
|
||||
username: String,
|
||||
#[new(value = "\"RDPPass\".to_string()")]
|
||||
#[new(value = "\"quickemu\".to_string()")]
|
||||
password: String,
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user