mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-21 21:25:20 +00:00
rdp: lookup cert/key from .config by default
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
ffb7492d9e
commit
1927fffb21
49
Cargo.lock
generated
49
Cargo.lock
generated
@ -1067,6 +1067,27 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@ -2660,6 +2681,16 @@ version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libusb1-sys"
|
||||
version = "0.7.0"
|
||||
@ -2991,6 +3022,12 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "option-operations"
|
||||
version = "0.5.0"
|
||||
@ -3512,6 +3549,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"clap 4.5.20",
|
||||
"dirs",
|
||||
"enumflags2",
|
||||
"futures-util",
|
||||
"ironrdp",
|
||||
@ -3701,6 +3739,17 @@ dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libredox",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
|
@ -8,8 +8,9 @@ use zbus::{
|
||||
fdo,
|
||||
fdo::ManagedObjects,
|
||||
names::{BusName, OwnedUniqueName, UniqueName, WellKnownName},
|
||||
proxy::OwnerChangedStream,
|
||||
zvariant::OwnedObjectPath,
|
||||
Connection, proxy::OwnerChangedStream,
|
||||
Connection,
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -32,3 +32,4 @@ ironrdp = { git = "https://github.com/Devolutions/IronRDP", features = [
|
||||
futures-util = "0.3"
|
||||
zbus.workspace = true
|
||||
enumflags2 = "0.7.10"
|
||||
dirs = "5.0.1"
|
||||
|
@ -21,7 +21,7 @@ pub struct Args {
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Commands {
|
||||
/// Start a RDP server
|
||||
#[command(arg_required_else_help = true)]
|
||||
#[command()]
|
||||
Serve(ServerArgs),
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ pub struct ServerArgs {
|
||||
|
||||
/// Path to tls certificate
|
||||
#[clap(short, long, value_parser)]
|
||||
pub cert: PathBuf,
|
||||
pub cert: Option<PathBuf>,
|
||||
|
||||
/// Path to private key
|
||||
#[clap(short, long, value_parser)]
|
||||
pub key: PathBuf,
|
||||
pub key: Option<PathBuf>,
|
||||
|
||||
/// RemoteFx encoding
|
||||
#[clap(value_enum, long, default_value = "enable")]
|
||||
|
@ -3,7 +3,9 @@ mod display;
|
||||
mod input;
|
||||
mod sound;
|
||||
|
||||
use anyhow::Error;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::{bail, Error};
|
||||
use enumflags2::BitFlags;
|
||||
use ironrdp::server::{Credentials, ServerEvent, TlsIdentityCtx};
|
||||
|
||||
@ -35,6 +37,25 @@ impl Server {
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) -> Result<(), Error> {
|
||||
let (cert, key) = match (&self.args.cert, &self.args.key) {
|
||||
(Some(cert), Some(key)) => (cert.as_path().to_owned(), key.as_path().to_owned()),
|
||||
(None, None) => {
|
||||
let mut config_dir = dirs::config_dir().expect("configuration directory");
|
||||
config_dir.push("qemu-rdp");
|
||||
let cert: PathBuf = [config_dir.clone(), PathBuf::from("cert.der")]
|
||||
.iter()
|
||||
.collect();
|
||||
let key: PathBuf = [config_dir, PathBuf::from("key.der")].iter().collect();
|
||||
(cert, key)
|
||||
}
|
||||
_ => {
|
||||
bail!("Provide both --cert and --key")
|
||||
}
|
||||
};
|
||||
|
||||
println!("Waiting for org.qemu...");
|
||||
Display::lookup(&self.dbus, true, None).await?;
|
||||
|
||||
let dbus_display = Display::new::<()>(&self.dbus, None).await?;
|
||||
|
||||
let handler = InputHandler::connect(&dbus_display).await?;
|
||||
@ -48,8 +69,7 @@ impl Server {
|
||||
}
|
||||
};
|
||||
|
||||
let tls =
|
||||
TlsIdentityCtx::init_from_paths(self.args.cert.as_path(), self.args.key.as_path())?;
|
||||
let tls = TlsIdentityCtx::init_from_paths(&cert, &key)?;
|
||||
let mut server = RdpServer::builder()
|
||||
.with_addr(self.args.bind_addr)
|
||||
.with_hybrid(tls.make_acceptor()?, tls.pub_key)
|
||||
@ -80,7 +100,11 @@ impl Server {
|
||||
.request_name_with_flags("org.QemuDisplay", BitFlags::EMPTY)
|
||||
.await?;
|
||||
|
||||
server.run().await
|
||||
println!("Starting RDP server, args: {:?}", self.args);
|
||||
println!("Cert: {cert:?}, Key: {key:?}");
|
||||
server.run().await?;
|
||||
println!("RDP server ended");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ async fn display_from_opt(opt: Rc<RefCell<AppOptions>>) -> Option<Display<'stati
|
||||
.map(Into::into)
|
||||
} else {
|
||||
if opt.borrow().wait {
|
||||
unimplemented!(); // FIXME
|
||||
Display::lookup(&conn, true, None).await.unwrap();
|
||||
}
|
||||
BusName::try_from("org.qemu").ok()
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user