added a new module and the ability to specify a config file if you want

to.
This commit is contained in:
pyro committed 2026-08-12 17:05:35 -05:00
1 parent 4ce461025c
commit 7b1f9f9d4e
10 files changed
+208 -33

No files matched your search

+19 -5
View File
@@ -17,7 +17,6 @@ use tokio_rustls::rustls::pki_types::{CertificateDer, PrivateKeyDer};
enum ClientAction {
Output(String),
Cmd(String),
Ping,
}
pub struct Client {
@@ -240,6 +239,10 @@ where
lock.clients.iter_mut().find(|c| c.id == source_id)
{
if source_client.controlling != 0 {
println!(
"deslelcting client: {}",
source_client.controlling
);
let dest_client_id = source_client.controlling.clone();
if let Some(dest_client) = lock
.clients
@@ -247,6 +250,7 @@ where
.find(|c| c.id == dest_client_id)
{
dest_client.controlled = 0;
println!("client {} deselected", dest_client.id);
}
}
}
@@ -268,7 +272,12 @@ where
}
"LIST_CLIENTS" => {
lock.clients.iter().for_each(|c| {
let out = format!("{}: {}", c.id, c.address);
let out;
if let Some(hostname) = c.hostname.clone() {
out = format!("{}: {}({})", c.id, hostname, c.address);
} else {
out = format!("{}: {}", c.id, c.address);
}
println!("client list requested!");
println!("adding {} to response...", out);
responses.push(ClientAction::Output(out));
@@ -277,6 +286,14 @@ where
"TEST" => {
responses.push(ClientAction::Output("TEST BACK".to_string()));
}
"SET_HOSTNAME" => {
lock.clients
.iter_mut()
.filter(|c| c.id == source_id)
.for_each(|c| {
c.hostname = Some(data.trim().to_string());
});
}
_ => {}
}
}
@@ -293,9 +310,6 @@ where
println!("adding {} to output", text);
messages.push(format!("OUTPUT|{}", text));
}
ClientAction::Ping => {
messages.push(format!("PONG"));
}
}
}
let full_message = messages.join("||");