add support for session encryption

This commit is contained in:
joeyahines committed 2026-10-24 20:11:53 -06:00
1 parent ce112f31a1
commit 6a5df9054c
8 files changed
+140 -12

No files matched your search

+1
View File
@@ -12,3 +12,4 @@ egui = "0.36.2"
eframe = "0.36.2"
tokio = { version = "1.53.2", features = ["rt", "rt-multi-thread", "macros"] }
thiserror = "2.0.21"
hex = "0.4.3"
+27 -5
View File
@@ -31,6 +31,8 @@ pub struct Tap {
device: String,
denny_jack_host: String,
warning: String,
key: String,
decoded_key: Vec<u8>,
join_handle: Option<JoinHandle<Result<(), ThreadError>>>,
channel: Option<std::sync::mpsc::Sender<Commands>>,
host: cpal::Host,
@@ -49,6 +51,8 @@ impl Tap {
device: "".to_string(),
denny_jack_host: "158.69.121.46:9999".to_string(),
warning: "".to_string(),
key: "".to_string(),
decoded_key: vec![],
join_handle: None,
channel: None,
host: cpal::default_host(),
@@ -58,6 +62,7 @@ impl Tap {
pub fn bg_threads(
device: &str,
host: &str,
key: &[u8],
channel: Receiver<Commands>,
) -> Result<(), ThreadError> {
let udp_connection =
@@ -72,7 +77,7 @@ impl Tap {
let audio_source_thread = AudioSourceThread::new(device.to_string(), host, channel);
// Run until completion
audio_source_thread.worker(udp_connection)?;
audio_source_thread.worker(udp_connection, key)?;
Ok(())
}
@@ -89,6 +94,9 @@ impl App for Tap {
State::Init => {
ui.label("Denny Jack Host");
ui.text_edit_singleline(&mut self.denny_jack_host);
ui.label("Denny Jack Session Key");
ui.text_edit_singleline(&mut self.key);
egui::containers::ComboBox::from_label("Device")
.selected_text(&self.device)
.show_ui(ui, |ui| {
@@ -102,11 +110,21 @@ impl App for Tap {
});
if ui.button("Connect").clicked() {
if self.device.is_empty() || self.denny_jack_host.is_empty() {
if self.device.is_empty()
|| self.denny_jack_host.is_empty()
|| self.key.is_empty()
{
self.warning = "Enter connection details and try again".to_string();
} else {
self.warning = "".to_string();
self.mode = State::Connecting;
if let Ok(key) = hex::decode(&self.key)
&& key.len() == 32
{
self.warning = "".to_string();
self.mode = State::Connecting;
self.decoded_key = key;
} else {
self.warning = "Invalid session key".to_string()
}
}
}
@@ -121,7 +139,10 @@ impl App for Tap {
let (sender, receiver) = channel();
let join = thread::spawn(move || Self::bg_threads(&device, &host, receiver));
let decoded_key = self.decoded_key.clone();
let join = thread::spawn(move || {
Self::bg_threads(&device, &host, &decoded_key, receiver)
});
self.join_handle = Some(join);
self.channel = Some(sender);
@@ -148,6 +169,7 @@ impl App for Tap {
let _ = handle.join();
self.join_handle = None;
self.mode = State::Init;
self.decoded_key = vec![];
}
}
}