mirror of
https://github.com/htrefil/rkvm.git
synced 2024-11-16 07:47:24 +01:00
Add an option to disable propagation of switch keys
This commit is contained in:
parent
e4ff7137d7
commit
e46d14bb14
4 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
listen = "0.0.0.0:5258"
|
||||
# See `switch-keys.md` in the repository root for the list of all possible keys.
|
||||
switch-keys = ["left-alt", "left-ctrl"]
|
||||
# Whether switch key presses should be propagated on the server and its clients.
|
||||
# Optional, defaults to true.
|
||||
# propagate-switch-keys = true
|
||||
certificate = "/etc/rkvm/certificate.pem"
|
||||
key = "/etc/rkvm/key.pem"
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct Config {
|
|||
pub key: PathBuf,
|
||||
pub password: String,
|
||||
pub switch_keys: HashSet<SwitchKey>,
|
||||
pub propagate_switch_keys: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -68,9 +68,10 @@ async fn main() -> ExitCode {
|
|||
};
|
||||
|
||||
let switch_keys = config.switch_keys.into_iter().map(Into::into).collect();
|
||||
let propagate_switch_keys = config.propagate_switch_keys.unwrap_or(true);
|
||||
|
||||
tokio::select! {
|
||||
result = server::run(config.listen, acceptor, &config.password, &switch_keys) => {
|
||||
result = server::run(config.listen, acceptor, &config.password, &switch_keys, propagate_switch_keys) => {
|
||||
if let Err(err) = result {
|
||||
tracing::error!("Error: {}", err);
|
||||
return ExitCode::FAILURE;
|
||||
|
|
|
@ -38,6 +38,7 @@ pub async fn run(
|
|||
acceptor: TlsAcceptor,
|
||||
password: &str,
|
||||
switch_keys: &HashSet<Key>,
|
||||
propagate_switch_keys: bool,
|
||||
) -> Result<(), Error> {
|
||||
let listener = TcpListener::bind(&listen).await.map_err(Error::Network)?;
|
||||
tracing::info!("Listening on {}", listen);
|
||||
|
@ -221,6 +222,10 @@ pub async fn run(
|
|||
}
|
||||
}
|
||||
|
||||
if press && !propagate_switch_keys {
|
||||
continue;
|
||||
}
|
||||
|
||||
let events = [event]
|
||||
.into_iter()
|
||||
.chain(press.then_some(Event::Sync(SyncEvent::All)));
|
||||
|
|
Loading…
Reference in a new issue