Skip to content

Commit

Permalink
upgrade baybridge
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaschan committed Nov 3, 2024
1 parent 88bd681 commit eb79efe
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 35 deletions.
105 changes: 76 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions insanity-native-tui-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ tracing-subscriber = "0.3.18"
tempfile = "3.12.0"
indicatif = { version = "0.17.8", features = ["tokio"] }
zip = "2.2.0"
base64 = "0.22.1"
13 changes: 7 additions & 6 deletions insanity-native-tui-app/src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
},
};

use base64::{prelude::BASE64_URL_SAFE, Engine};
use insanity_core::user_input_event::UserInputEvent;
use insanity_tui_adapter::AppEvent;

Expand Down Expand Up @@ -99,7 +100,8 @@ impl ConnectionManager {
// Query self and add to UI.
if let Some(app_event_tx) = app_event_tx.clone() {
let my_public_key = action.whoami().await;
if let Err(e) = app_event_tx.send(AppEvent::SetOwnPublicKey(my_public_key)) {
let my_public_key_base64 = BASE64_URL_SAFE.encode(my_public_key.as_bytes());
if let Err(e) = app_event_tx.send(AppEvent::SetOwnPublicKey(my_public_key_base64)) {
log::debug!("Failed to write own public key to UI: {e}");
}
}
Expand Down Expand Up @@ -127,7 +129,7 @@ impl ConnectionManager {
pub enum IpVersion {
Ipv4,
Ipv6,
Dualstack
Dualstack,
}

pub struct ConnectionManagerBuilder {
Expand Down Expand Up @@ -194,7 +196,6 @@ impl ConnectionManagerBuilder {
}
}


/// Creates the local socket, uploads connection info, and begins searching for connections.
pub async fn start(self) -> anyhow::Result<ConnectionManager> {
let cancellation_token = self.cancellation_token.unwrap_or_default();
Expand All @@ -210,16 +211,16 @@ impl ConnectionManagerBuilder {
IpVersion::Ipv4 => {
let v4_addr = SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, self.listen_port);
VeqSocket::bind_with_keypair(&v4_addr.to_string(), keypair).await?
},
}
IpVersion::Ipv6 => {
let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, self.listen_port + 1, 0, 0);
VeqSocket::bind_with_keypair(&v6_addr.to_string(), keypair).await?
},
}
IpVersion::Dualstack => {
let v4_addr = SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, self.listen_port);
let v6_addr = SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, self.listen_port + 1, 0, 0);
VeqSocket::dualstack_with_keypair(v4_addr, v6_addr, keypair).await?
},
}
};

let (user_action_tx, user_action_rx) = mpsc::unbounded_channel();
Expand Down

0 comments on commit eb79efe

Please sign in to comment.