From 7360bf96f81a52f422fbe35a7d093571e9c79533 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 18:52:29 +0100 Subject: [PATCH] Fix rustls panic in example bots --- Cargo.toml | 2 +- examples/testbot_commands.rs | 7 +++++-- examples/testbot_instance.rs | 6 +++++- examples/testbot_instances.rs | 6 +++++- examples/testbot_manual.rs | 6 +++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 917f0b4..0ae6832 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ default-features = false features = ["std", "derive", "deprecated"] [dev-dependencies] # For example bot +rustls = "0.23.19" tokio = { version = "1.42.0", features = ["rt-multi-thread"] } [[example]] @@ -56,7 +57,6 @@ rust.redundant_lifetimes = "warn" rust.single_use_lifetimes = "warn" rust.unit_bindings = "warn" rust.unnameable_types = "warn" -rust.unused_crate_dependencies = "warn" rust.unused_import_braces = "warn" rust.unused_lifetimes = "warn" rust.unused_qualifications = "warn" diff --git a/examples/testbot_commands.rs b/examples/testbot_commands.rs index f6d184a..c3afada 100644 --- a/examples/testbot_commands.rs +++ b/examples/testbot_commands.rs @@ -1,5 +1,3 @@ -#![allow(unused_crate_dependencies)] - // TODO Add description // TODO Clean up and unify test bots @@ -94,6 +92,11 @@ impl HasStartTime for Bot { #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let mut instances = Instances::new(ServerConfig::default()); diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index f748429..f60f3b9 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -1,6 +1,5 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). -#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; @@ -123,6 +122,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let _instance = ServerConfig::default() diff --git a/examples/testbot_instances.rs b/examples/testbot_instances.rs index 2ad134b..0fb612f 100644 --- a/examples/testbot_instances.rs +++ b/examples/testbot_instances.rs @@ -1,6 +1,5 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). -#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; @@ -124,6 +123,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let mut instances = Instances::new(ServerConfig::default()); diff --git a/examples/testbot_manual.rs b/examples/testbot_manual.rs index 71a7280..da21db0 100644 --- a/examples/testbot_manual.rs +++ b/examples/testbot_manual.rs @@ -1,6 +1,5 @@ //! A small bot that doesn't use the `bot` submodule. Meant to show how the main //! parts of the API fit together. -#![allow(unused_crate_dependencies)] use std::error::Error; use std::time::Duration; @@ -127,6 +126,11 @@ async fn on_packet(packet: ParsedPacket, conn_tx: &ConnTx, state: &State) -> Res #[tokio::main] async fn main() -> Result<(), Box> { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (mut conn, _) = Conn::connect(DOMAIN, ROOM, false, None, TIMEOUT).await?; while let Ok(packet) = conn.recv().await {