From 2c6f4dc839a279b9d5c10d674489998b021908b8 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 5 Feb 2023 20:57:47 +0100 Subject: update deps --- client-native-lib/src/crypto.rs | 9 ++-- client-native-lib/src/peer.rs | 93 ++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 55 deletions(-) (limited to 'client-native-lib/src') diff --git a/client-native-lib/src/crypto.rs b/client-native-lib/src/crypto.rs index 239c9f3..0472ec7 100644 --- a/client-native-lib/src/crypto.rs +++ b/client-native-lib/src/crypto.rs @@ -7,6 +7,7 @@ use aes_gcm::{ aead::{generic_array::sequence::GenericSequence, Aead}, Aes256Gcm, KeyInit, Nonce, }; +use base64::Engine; use log::info; pub struct Key(Aes256Gcm); @@ -14,7 +15,9 @@ pub struct Key(Aes256Gcm); impl Key { pub fn derive(secret: &str) -> Self { info!("running key generation..."); - let salt = base64::decode("thisisagoodsaltAAAAAAA==").unwrap(); + let salt = base64::engine::general_purpose::STANDARD + .decode("thisisagoodsaltAAAAAAA==") + .unwrap(); let mut key = [0u8; 32]; fastpbkdf2::pbkdf2_hmac_sha256(secret.as_bytes(), salt.as_slice(), 250000, &mut key); @@ -28,10 +31,10 @@ impl Key { let ciphertext = self.0.encrypt(&iv, s.as_bytes()).unwrap(); let mut packet = iv.to_vec(); // TODO this could be doing less allocations packet.extend(ciphertext); - base64::encode(packet) + base64::engine::general_purpose::STANDARD.encode(packet) } pub fn decrypt(&self, s: &str) -> String { - let r = base64::decode(s).unwrap(); + let r = base64::engine::general_purpose::STANDARD.decode(s).unwrap(); let iv = &r[0..12]; let ciphertext = &r[12..]; let plaintext = self.0.decrypt(Nonce::from_slice(iv), ciphertext).unwrap(); diff --git a/client-native-lib/src/peer.rs b/client-native-lib/src/peer.rs index b3b4dd4..8c27234 100644 --- a/client-native-lib/src/peer.rs +++ b/client-native-lib/src/peer.rs @@ -69,34 +69,28 @@ impl Peer { .on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| { info!("connection state changed: {s}"); Box::pin(async {}) - })) - .await; - + })); { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_ice_candidate(box move |c| { - if let Some(peer) = weak.upgrade() { - Box::pin(async move { - if let Some(c) = c { - peer.on_ice_candidate(c).await - } - }) - } else { - Box::pin(async move {}) - } - }) - .await; + peer.peer_connection.on_ice_candidate(box move |c| { + if let Some(peer) = weak.upgrade() { + Box::pin(async move { + if let Some(c) = c { + peer.on_ice_candidate(c).await + } + }) + } else { + Box::pin(async move {}) + } + }) } { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_negotiation_needed(box move || { - let peer = weak.upgrade().unwrap(); - Box::pin(async { peer.on_negotiation_needed().await }) - }) - .await; + peer.peer_connection.on_negotiation_needed(box move || { + let peer = weak.upgrade().unwrap(); + Box::pin(async { peer.on_negotiation_needed().await }) + }) } { @@ -124,37 +118,34 @@ impl Peer { } }) }) - .await; } { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_data_channel(box move |dc| { - let peer = weak.upgrade().unwrap(); - Box::pin(async move { - if let Some(res) = peer - .remote_provided - .read() - .await - .get(&dc.label().to_string()) - { - info!("data channel for ({:?}) '{:?}'", res.id, res.label); - peer.inst - .event_handler - .resource_connected( - peer.clone(), - res, - TransportChannel::DataChannel(dc), - ) - .await; - } else { - warn!("got unassociated data channel; closed connection"); - dc.close().await.unwrap(); - } - }) + peer.peer_connection.on_data_channel(box move |dc| { + let peer = weak.upgrade().unwrap(); + Box::pin(async move { + if let Some(res) = peer + .remote_provided + .read() + .await + .get(&dc.label().to_string()) + { + info!("data channel for ({:?}) '{:?}'", res.id, res.label); + peer.inst + .event_handler + .resource_connected( + peer.clone(), + res, + TransportChannel::DataChannel(dc), + ) + .await; + } else { + warn!("got unassociated data channel; closed connection"); + dc.close().await.unwrap(); + } }) - .await; + }) } peer } @@ -228,10 +219,8 @@ impl Peer { pub async fn on_ice_candidate(&self, candidate: RTCIceCandidate) { debug!("publishing local ICE candidate"); - self.send_relay(RelayMessage::IceCandidate( - candidate.to_json().await.unwrap(), - )) - .await; + self.send_relay(RelayMessage::IceCandidate(candidate.to_json().unwrap())) + .await; } pub async fn on_remote_ice_candidate(&self, candidate: RTCIceCandidateInit) { debug!("adding remote ICE candidate"); -- cgit v1.2.3-70-g09d2 From d2ab09569b78c2fa5c73293e146ccb8f704851aa Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 21 Feb 2023 21:51:20 +0100 Subject: compat fixup --- client-native-gui/src/chat.rs | 2 +- client-native-gui/src/main.rs | 4 +++- client-native-lib/src/lib.rs | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'client-native-lib/src') diff --git a/client-native-gui/src/chat.rs b/client-native-gui/src/chat.rs index c1f7868..364d1bb 100644 --- a/client-native-gui/src/chat.rs +++ b/client-native-gui/src/chat.rs @@ -47,7 +47,7 @@ impl Chat { }; } let r = TextEdit::singleline(&mut self.input_line).show(ui).response; - if r.lost_focus() && r.ctx.input().key_down(Key::Enter) { + if r.lost_focus() && r.ctx.input(|i| i.key_down(Key::Enter)) { self.send(ChatMesssage::Text(self.input_line.to_owned())); self.input_line = "".into(); r.request_focus(); diff --git a/client-native-gui/src/main.rs b/client-native-gui/src/main.rs index 83de3a0..f0c3a9f 100644 --- a/client-native-gui/src/main.rs +++ b/client-native-gui/src/main.rs @@ -69,7 +69,8 @@ async fn main() { }); Box::new(App::new(args)) }), - ); + ) + .unwrap(); } enum App { @@ -478,6 +479,7 @@ async fn track_to_raw( let (packet, _) = track.read_rtp().await?; if !packet.payload.is_empty() { let raw_payload = cached_packet.depacketize(&packet.payload)?; + // let raw_payload = packet.payload; if raw_payload.len() != 0 { debug!("writing {} bytes", raw_payload.len()); diff --git a/client-native-lib/src/lib.rs b/client-native-lib/src/lib.rs index 1380688..32418d4 100644 --- a/client-native-lib/src/lib.rs +++ b/client-native-lib/src/lib.rs @@ -35,7 +35,6 @@ pub struct Config { pub(crate) fn build_api() -> webrtc::api::API { let mut media_engine = MediaEngine::default(); media_engine.register_default_codecs().unwrap(); - let mut registry = Registry::new(); registry = register_default_interceptors(registry, &mut media_engine).unwrap(); APIBuilder::new() -- cgit v1.2.3-70-g09d2