From 09a6153d2cd3bb9136414752f67b9614bd4c97b4 Mon Sep 17 00:00:00 2001 From: Swanand Mulay <73115739+swanandx@users.noreply.github.com> Date: Sat, 27 Jan 2024 14:38:56 +0530 Subject: [PATCH 1/9] feat(rumqttc): optimize topic and filter validation (#788) --- rumqttc/src/mqttbytes/topic.rs | 51 +++++++++++++++++--------------- rumqttc/src/v5/mqttbytes/mod.rs | 52 ++++++++++++++++++--------------- 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/rumqttc/src/mqttbytes/topic.rs b/rumqttc/src/mqttbytes/topic.rs index 5524fe24f..a66c35f85 100644 --- a/rumqttc/src/mqttbytes/topic.rs +++ b/rumqttc/src/mqttbytes/topic.rs @@ -5,11 +5,8 @@ pub fn has_wildcards(s: &str) -> bool { /// Checks if a topic is valid pub fn valid_topic(topic: &str) -> bool { - if topic.contains('+') { - return false; - } - - if topic.contains('#') { + // topic can't contain wildcards + if topic.contains('+') || topic.contains('#') { return false; } @@ -24,27 +21,33 @@ pub fn valid_filter(filter: &str) -> bool { return false; } - let hirerarchy = filter.split('/').collect::>(); - if let Some((last, remaining)) = hirerarchy.split_last() { - for entry in remaining.iter() { - // # is not allowed in filter except as a last entry - // invalid: sport/tennis#/player - // invalid: sport/tennis/#/ranking - if entry.contains('#') { - return false; - } - - // + must occupy an entire level of the filter - // invalid: sport+ - if entry.len() > 1 && entry.contains('+') { - return false; - } + // rev() is used so we can easily get the last entry + let mut hirerarchy = filter.split('/').rev(); + + // split will never return an empty iterator + // even if the pattern isn't matched, the original string will be there + // so it is safe to just unwrap here! + let last = hirerarchy.next().unwrap(); + + // only single '#" or '+' is allowed in last entry + // invalid: sport/tennis# + // invalid: sport/++ + if last.len() != 1 && (last.contains('#') || last.contains('+')) { + return false; + } + + // remaining entries + for entry in hirerarchy { + // # is not allowed in filter except as a last entry + // invalid: sport/tennis#/player + // invalid: sport/tennis/#/ranking + if entry.contains('#') { + return false; } - // only single '#" or '+' is allowed in last entry - // invalid: sport/tennis# - // invalid: sport/++ - if last.len() != 1 && (last.contains('#') || last.contains('+')) { + // + must occupy an entire level of the filter + // invalid: sport+ + if entry.len() > 1 && entry.contains('+') { return false; } } diff --git a/rumqttc/src/v5/mqttbytes/mod.rs b/rumqttc/src/v5/mqttbytes/mod.rs index 281a91d5b..231c68067 100644 --- a/rumqttc/src/v5/mqttbytes/mod.rs +++ b/rumqttc/src/v5/mqttbytes/mod.rs @@ -39,11 +39,8 @@ pub fn has_wildcards(s: &str) -> bool { /// Checks if a topic is valid pub fn valid_topic(topic: &str) -> bool { - if topic.contains('+') { - return false; - } - - if topic.contains('#') { + // topic can't contain wildcards + if topic.contains('+') || topic.contains('#') { return false; } @@ -58,30 +55,37 @@ pub fn valid_filter(filter: &str) -> bool { return false; } - let hirerarchy = filter.split('/').collect::>(); - if let Some((last, remaining)) = hirerarchy.split_last() { - for entry in remaining.iter() { - // # is not allowed in filter except as a last entry - // invalid: sport/tennis#/player - // invalid: sport/tennis/#/ranking - if entry.contains('#') { - return false; - } - - // + must occupy an entire level of the filter - // invalid: sport+ - if entry.len() > 1 && entry.contains('+') { - return false; - } + // rev() is used so we can easily get the last entry + let mut hirerarchy = filter.split('/').rev(); + + // split will never return an empty iterator + // even if the pattern isn't matched, the original string will be there + // so it is safe to just unwrap here! + let last = hirerarchy.next().unwrap(); + + // only single '#" or '+' is allowed in last entry + // invalid: sport/tennis# + // invalid: sport/++ + if last.len() != 1 && (last.contains('#') || last.contains('+')) { + return false; + } + + // remaining entries + for entry in hirerarchy { + // # is not allowed in filter except as a last entry + // invalid: sport/tennis#/player + // invalid: sport/tennis/#/ranking + if entry.contains('#') { + return false; } - // only single '#" or '+' is allowed in last entry - // invalid: sport/tennis# - // invalid: sport/++ - if last.len() != 1 && (last.contains('#') || last.contains('+')) { + // + must occupy an entire level of the filter + // invalid: sport+ + if entry.len() > 1 && entry.contains('+') { return false; } } + true } From e63925a7cea19db023ecb4d89ffdac2c04707f16 Mon Sep 17 00:00:00 2001 From: Swanand Mulay <73115739+swanandx@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:41:59 +0530 Subject: [PATCH 2/9] fix(rumqttd): fix session present flag in connack (#792) --- rumqttd/CHANGELOG.md | 1 + rumqttd/src/router/graveyard.rs | 41 ++++++++++++++--------- rumqttd/src/router/routing.rs | 59 ++++++++++++++++++++------------- 3 files changed, 62 insertions(+), 39 deletions(-) diff --git a/rumqttd/CHANGELOG.md b/rumqttd/CHANGELOG.md index 572518e81..6088c2b23 100644 --- a/rumqttd/CHANGELOG.md +++ b/rumqttd/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - MQTT keep alive interval - record client id for remote link's span +- session present flag in connack ### Security diff --git a/rumqttd/src/router/graveyard.rs b/rumqttd/src/router/graveyard.rs index d7c1437f0..12932c10e 100644 --- a/rumqttd/src/router/graveyard.rs +++ b/rumqttd/src/router/graveyard.rs @@ -23,7 +23,7 @@ impl Graveyard { } /// Save connection tracker - pub fn save( + pub fn save_state( &mut self, mut tracker: Tracker, subscriptions: HashSet, @@ -33,13 +33,28 @@ impl Graveyard { tracker.pause(PauseReason::Busy); let id = tracker.id.clone(); + let session_state = SessionState { + tracker, + subscriptions, + unacked_pubrels, + }; + + self.connections.insert( + id, + SavedState { + session_state: Some(session_state), + metrics, + }, + ); + } + + /// Save only metrics for connection + pub fn save_metrics(&mut self, id: String, metrics: ConnectionEvents) { self.connections.insert( id, SavedState { - tracker, - subscriptions, + session_state: None, metrics, - unacked_pubrels, }, ); } @@ -47,20 +62,14 @@ impl Graveyard { #[derive(Debug)] pub struct SavedState { + pub session_state: Option, + pub metrics: ConnectionEvents, +} + +#[derive(Debug)] +pub struct SessionState { pub tracker: Tracker, pub subscriptions: HashSet, - pub metrics: ConnectionEvents, // used for pubrel in qos2 pub unacked_pubrels: VecDeque, } - -impl SavedState { - pub fn new(client_id: String) -> SavedState { - SavedState { - tracker: Tracker::new(client_id), - subscriptions: HashSet::new(), - metrics: ConnectionEvents::default(), - unacked_pubrels: VecDeque::new(), - } - } -} diff --git a/rumqttd/src/router/routing.rs b/rumqttd/src/router/routing.rs index 3f1e960e1..3d285a99f 100644 --- a/rumqttd/src/router/routing.rs +++ b/rumqttd/src/router/routing.rs @@ -5,9 +5,8 @@ use crate::protocol::{ SubscribeReasonCode, UnsubAck, UnsubAckReason, }; use crate::router::alertlog::alert; -use crate::router::graveyard::SavedState; use crate::router::scheduler::{PauseReason, Tracker}; -use crate::router::Forward; +use crate::router::{ConnectionEvents, Forward}; use crate::segments::Position; use crate::*; use flume::{bounded, Receiver, RecvError, Sender, TryRecvError}; @@ -304,23 +303,36 @@ impl Router { // Retrieve previous connection state from graveyard let saved = self.graveyard.retrieve(&client_id); let clean_session = connection.clean; - let previous_session = saved.is_some(); + let previous_session = saved.as_ref().is_some_and(|s| s.session_state.is_some()); // for qos2 pending pubrels let mut pending_acks = VecDeque::new(); + let tracker = if !clean_session { - let saved = saved.map_or(SavedState::new(client_id.clone()), |s| s); - connection.subscriptions = saved.subscriptions; - connection.events = saved.metrics; - // for using in acklog - pending_acks = saved.unacked_pubrels.clone(); - outgoing.unacked_pubrels = saved.unacked_pubrels; - saved.tracker + // if there was some saved state, restore the metrics + // and get the session's state if present + let saved_state = saved.and_then(|saved| { + connection.events = saved.metrics; + saved.session_state + }); + + // if session's state is present, restore that session + // otherwise, just start new one + saved_state.map_or_else( + || Tracker::new(client_id.clone()), + |session_state| { + connection.subscriptions = session_state.subscriptions; + // for using in acklog + pending_acks = session_state.unacked_pubrels.clone(); + outgoing.unacked_pubrels = session_state.unacked_pubrels; + session_state.tracker + }, + ) } else { // Only retrieve metrics in clean session - let saved = saved.map_or(SavedState::new(client_id.clone()), |s| s); - connection.events = saved.metrics; + connection.events = saved.map_or_else(ConnectionEvents::default, |s| s.metrics); Tracker::new(client_id.clone()) }; + let ackslog = AckLog::new(); let time = match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { @@ -503,20 +515,17 @@ impl Router { } } - self.graveyard.save( + self.graveyard.save_state( tracker, connection.subscriptions, connection.events, outgoing.unacked_pubrels, ); } else { + tracker.pause(PauseReason::Busy); + let id = tracker.id.clone(); // Only save metrics in clean session - self.graveyard.save( - Tracker::new(client_id), - HashSet::new(), - connection.events, - VecDeque::new(), - ); + self.graveyard.save_metrics(id, connection.events); } self.router_meters.total_connections -= 1; } @@ -1657,10 +1666,14 @@ fn print_status(router: &mut Router, metrics: Print) { let metrics = match metrics { Some(v) => Some(v), - None => router - .graveyard - .retrieve(&id) - .map(|v| (v.metrics, v.tracker)), + None => router.graveyard.retrieve(&id).map(|v| { + ( + v.metrics, + v.session_state + .map(|s| s.tracker) + .unwrap_or(Tracker::new(id)), + ) + }), }; println!("{metrics:#?}"); From c719181bb1e3c41a691a7827bfafd393b004e88c Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Wed, 7 Feb 2024 21:18:12 +0530 Subject: [PATCH 3/9] refactor(rumqttc): clean-up examples (#794) Co-authored-by: swanandx <73115739+swanandx@users.noreply.github.com> --- Cargo.lock | 1 - rumqttc/Cargo.toml | 23 ++++++++++++++++++++--- rumqttc/examples/async_manual_acks.rs | 4 ++-- rumqttc/examples/async_manual_acks_v5.rs | 3 +-- rumqttc/examples/asyncpubsub.rs | 4 ++-- rumqttc/examples/asyncpubsub_v5.rs | 2 +- rumqttc/examples/serde.rs | 4 ++-- rumqttc/examples/subscription_ids.rs | 2 +- rumqttc/examples/syncpubsub.rs | 2 +- rumqttc/examples/syncrecv.rs | 2 +- rumqttc/examples/tls.rs | 14 ++++---------- rumqttc/examples/tls2.rs | 12 +++--------- rumqttc/examples/topic_alias.rs | 2 +- rumqttc/examples/websocket.rs | 14 ++------------ rumqttc/examples/websocket_proxy.rs | 14 ++------------ rumqttc/src/lib.rs | 2 +- 16 files changed, 44 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c697f384b..76c7eea3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,7 +1834,6 @@ dependencies = [ "native-tls", "pretty_assertions", "pretty_env_logger", - "rustls", "rustls-native-certs", "rustls-pemfile", "rustls-webpki", diff --git a/rumqttc/Cargo.toml b/rumqttc/Cargo.toml index 1a3e1f703..483f9de7b 100644 --- a/rumqttc/Cargo.toml +++ b/rumqttc/Cargo.toml @@ -54,7 +54,24 @@ color-backtrace = "0.6" matches = "0.1" pretty_assertions = "1" pretty_env_logger = "0.5" -rustls = "0.21" -rustls-native-certs = "0.6" serde = { version = "1", features = ["derive"] } -tokio = { version = "1", features = ["full", "macros"] } + +[[example]] +name = "tls" +path = "examples/tls.rs" +required-features = ["use-rustls"] + +[[example]] +name = "tls2" +path = "examples/tls2.rs" +required-features = ["use-rustls"] + +[[example]] +name = "websocket" +path = "examples/websocket.rs" +required-features = ["websocket"] + +[[example]] +name = "websocket_proxy" +path = "examples/websocket_proxy.rs" +required-features = ["websocket", "proxy"] diff --git a/rumqttc/examples/async_manual_acks.rs b/rumqttc/examples/async_manual_acks.rs index 71ed62a01..e5360aa04 100644 --- a/rumqttc/examples/async_manual_acks.rs +++ b/rumqttc/examples/async_manual_acks.rs @@ -1,6 +1,6 @@ use tokio::{task, time}; -use rumqttc::{self, AsyncClient, Event, EventLoop, Incoming, MqttOptions, QoS}; +use rumqttc::{AsyncClient, Event, EventLoop, Incoming, MqttOptions, QoS}; use std::error::Error; use std::time::Duration; @@ -14,7 +14,7 @@ fn create_conn() -> (AsyncClient, EventLoop) { AsyncClient::new(mqttoptions, 10) } -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/rumqttc/examples/async_manual_acks_v5.rs b/rumqttc/examples/async_manual_acks_v5.rs index edb12fe1f..bcf1bf356 100644 --- a/rumqttc/examples/async_manual_acks_v5.rs +++ b/rumqttc/examples/async_manual_acks_v5.rs @@ -1,4 +1,3 @@ -#![allow(dead_code, unused_imports)] use rumqttc::v5::mqttbytes::v5::Packet; use rumqttc::v5::mqttbytes::QoS; use tokio::{task, time}; @@ -17,7 +16,7 @@ fn create_conn() -> (AsyncClient, EventLoop) { AsyncClient::new(mqttoptions, 10) } -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { // todo!("fix this example with new way of spawning clients") pretty_env_logger::init(); diff --git a/rumqttc/examples/asyncpubsub.rs b/rumqttc/examples/asyncpubsub.rs index a2498d0e8..d4d70d3ff 100644 --- a/rumqttc/examples/asyncpubsub.rs +++ b/rumqttc/examples/asyncpubsub.rs @@ -1,10 +1,10 @@ use tokio::{task, time}; -use rumqttc::{self, AsyncClient, MqttOptions, QoS}; +use rumqttc::{AsyncClient, MqttOptions, QoS}; use std::error::Error; use std::time::Duration; -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); // color_backtrace::install(); diff --git a/rumqttc/examples/asyncpubsub_v5.rs b/rumqttc/examples/asyncpubsub_v5.rs index d6a0fdd8b..fd53b53fd 100644 --- a/rumqttc/examples/asyncpubsub_v5.rs +++ b/rumqttc/examples/asyncpubsub_v5.rs @@ -5,7 +5,7 @@ use rumqttc::v5::{AsyncClient, MqttOptions}; use std::error::Error; use std::time::Duration; -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); // color_backtrace::install(); diff --git a/rumqttc/examples/serde.rs b/rumqttc/examples/serde.rs index 3e251e43b..478a88d56 100644 --- a/rumqttc/examples/serde.rs +++ b/rumqttc/examples/serde.rs @@ -51,8 +51,8 @@ fn main() { }); // Iterate to poll the eventloop for connection progress - for notification in connection.iter() { - if let Ok(Event::Incoming(Incoming::Publish(packet))) = notification { + for notification in connection.iter().flatten() { + if let Event::Incoming(Incoming::Publish(packet)) = notification { match Message::try_from(packet.payload.as_ref()) { Ok(message) => println!("Payload = {message:?}"), Err(error) => println!("Error = {error}"), diff --git a/rumqttc/examples/subscription_ids.rs b/rumqttc/examples/subscription_ids.rs index 0c1a014ef..b741bfaf7 100644 --- a/rumqttc/examples/subscription_ids.rs +++ b/rumqttc/examples/subscription_ids.rs @@ -6,7 +6,7 @@ use rumqttc::v5::{AsyncClient, MqttOptions}; use std::error::Error; use std::time::Duration; -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/rumqttc/examples/syncpubsub.rs b/rumqttc/examples/syncpubsub.rs index e3bd2d4dd..5c42ad43c 100644 --- a/rumqttc/examples/syncpubsub.rs +++ b/rumqttc/examples/syncpubsub.rs @@ -1,4 +1,4 @@ -use rumqttc::{self, Client, LastWill, MqttOptions, QoS}; +use rumqttc::{Client, LastWill, MqttOptions, QoS}; use std::thread; use std::time::Duration; diff --git a/rumqttc/examples/syncrecv.rs b/rumqttc/examples/syncrecv.rs index 74ff2d5ee..f0da81775 100644 --- a/rumqttc/examples/syncrecv.rs +++ b/rumqttc/examples/syncrecv.rs @@ -1,4 +1,4 @@ -use rumqttc::{self, Client, LastWill, MqttOptions, QoS}; +use rumqttc::{Client, LastWill, MqttOptions, QoS}; use std::thread; use std::time::Duration; diff --git a/rumqttc/examples/tls.rs b/rumqttc/examples/tls.rs index f04e26479..1f57b829e 100644 --- a/rumqttc/examples/tls.rs +++ b/rumqttc/examples/tls.rs @@ -1,12 +1,11 @@ //! Example of how to configure rumqttd to connect to a server using TLS and authentication. use std::error::Error; -#[cfg(feature = "use-rustls")] -#[tokio::main] -async fn main() -> Result<(), Box> { - use rumqttc::{self, AsyncClient, Event, Incoming, MqttOptions, Transport}; - use tokio_rustls::rustls::ClientConfig; +use rumqttc::{AsyncClient, Event, Incoming, MqttOptions, Transport}; +use tokio_rustls::rustls::ClientConfig; +#[tokio::main(flavor = "current_thread")] +async fn main() -> Result<(), Box> { pretty_env_logger::init(); color_backtrace::install(); @@ -45,8 +44,3 @@ async fn main() -> Result<(), Box> { } } } - -#[cfg(not(feature = "use-rustls"))] -fn main() -> Result<(), Box> { - panic!("Enable feature 'use-rustls'"); -} diff --git a/rumqttc/examples/tls2.rs b/rumqttc/examples/tls2.rs index 920b20ace..c088adb09 100644 --- a/rumqttc/examples/tls2.rs +++ b/rumqttc/examples/tls2.rs @@ -1,11 +1,10 @@ //! Example of how to configure rumqttd to connect to a server using TLS and authentication. use std::error::Error; -#[cfg(feature = "use-rustls")] -#[tokio::main] -async fn main() -> Result<(), Box> { - use rumqttc::{self, AsyncClient, MqttOptions, TlsConfiguration, Transport}; +use rumqttc::{AsyncClient, MqttOptions, TlsConfiguration, Transport}; +#[tokio::main(flavor = "current_thread")] +async fn main() -> Result<(), Box> { pretty_env_logger::init(); color_backtrace::install(); @@ -44,8 +43,3 @@ async fn main() -> Result<(), Box> { Ok(()) } - -#[cfg(not(feature = "use-rustls"))] -fn main() -> Result<(), Box> { - panic!("Enable feature 'use-rustls'"); -} diff --git a/rumqttc/examples/topic_alias.rs b/rumqttc/examples/topic_alias.rs index 4583867b3..394ad3cd5 100644 --- a/rumqttc/examples/topic_alias.rs +++ b/rumqttc/examples/topic_alias.rs @@ -5,7 +5,7 @@ use rumqttc::v5::{AsyncClient, MqttOptions}; use std::error::Error; use std::time::Duration; -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/rumqttc/examples/websocket.rs b/rumqttc/examples/websocket.rs index b09fe9671..8aceb5bfd 100644 --- a/rumqttc/examples/websocket.rs +++ b/rumqttc/examples/websocket.rs @@ -1,12 +1,8 @@ -#[cfg(feature = "websocket")] -use rumqttc::{self, AsyncClient, MqttOptions, QoS, Transport}; -#[cfg(feature = "websocket")] +use rumqttc::{AsyncClient, MqttOptions, QoS, Transport}; use std::{error::Error, time::Duration}; -#[cfg(feature = "websocket")] use tokio::{task, time}; -#[cfg(feature = "websocket")] -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { pretty_env_logger::init(); @@ -39,7 +35,6 @@ async fn main() -> Result<(), Box> { } } -#[cfg(feature = "websocket")] async fn requests(client: AsyncClient) { client .subscribe("hello/world", QoS::AtMostOnce) @@ -57,8 +52,3 @@ async fn requests(client: AsyncClient) { time::sleep(Duration::from_secs(120)).await; } - -#[cfg(not(feature = "websocket"))] -fn main() { - panic!("Enable websocket feature with `--features=websocket`"); -} diff --git a/rumqttc/examples/websocket_proxy.rs b/rumqttc/examples/websocket_proxy.rs index 6aa680837..42c12353e 100644 --- a/rumqttc/examples/websocket_proxy.rs +++ b/rumqttc/examples/websocket_proxy.rs @@ -1,12 +1,8 @@ -#[cfg(all(feature = "websocket", feature = "proxy"))] -use rumqttc::{self, AsyncClient, Proxy, ProxyAuth, ProxyType, QoS, Transport}; -#[cfg(all(feature = "websocket", feature = "proxy"))] +use rumqttc::{AsyncClient, Proxy, ProxyAuth, ProxyType, QoS, Transport}; use std::{error::Error, time::Duration}; -#[cfg(all(feature = "websocket", feature = "proxy"))] use tokio::{task, time}; -#[cfg(all(feature = "websocket", feature = "proxy"))] -#[tokio::main(worker_threads = 1)] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { use rumqttc::MqttOptions; @@ -48,7 +44,6 @@ async fn main() -> Result<(), Box> { } } -#[cfg(all(feature = "websocket", feature = "proxy"))] async fn requests(client: AsyncClient) { client .subscribe("hello/world", QoS::AtMostOnce) @@ -66,8 +61,3 @@ async fn requests(client: AsyncClient) { time::sleep(Duration::from_secs(120)).await; } - -#[cfg(not(all(feature = "websocket", feature = "proxy")))] -fn main() { - panic!("Enable websocket and proxy feature with `--features=websocket, proxy`"); -} diff --git a/rumqttc/src/lib.rs b/rumqttc/src/lib.rs index 72c2e1fbc..3ff32db43 100644 --- a/rumqttc/src/lib.rs +++ b/rumqttc/src/lib.rs @@ -38,7 +38,7 @@ //! use std::time::Duration; //! use std::error::Error; //! -//! # #[tokio::main(worker_threads = 1)] +//! # #[tokio::main(flavor = "current_thread")] //! # async fn main() { //! let mut mqttoptions = MqttOptions::new("rumqtt-async", "test.mosquitto.org", 1883); //! mqttoptions.set_keep_alive(Duration::from_secs(5)); From 0266b85bd5986f556b3eaedc806c964e906232b8 Mon Sep 17 00:00:00 2001 From: Arunanshu Biswas <48434243+arunanshub@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:53:36 +0530 Subject: [PATCH 4/9] fix(rumqttc): allow empty client id (#791) --- rumqttc/CHANGELOG.md | 2 ++ rumqttc/src/lib.rs | 43 +++++++++++++++++++++++-------------------- rumqttc/src/v5/mod.rs | 24 +++--------------------- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/rumqttc/CHANGELOG.md b/rumqttc/CHANGELOG.md index 0705a9db4..b9c6f73b8 100644 --- a/rumqttc/CHANGELOG.md +++ b/rumqttc/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Surfaced `AsyncClient`'s `from_senders` method to the `Client` as `from_sender` ### Changed +- `MqttOptions::new` now accepts empty client id. +- `MqttOptions::set_clean_session` now panics if client ID is empty and `clean_session` flag is set to false. - Synchronous client methods take `&self` instead of `&mut self` (#646) - Removed the `Key` enum: users do not need to specify the TLS key variant in the `TlsConfiguration` anymore, this is inferred automatically. To update your code simply remove `Key::ECC()` or `Key::RSA()` from the initialization. diff --git a/rumqttc/src/lib.rs b/rumqttc/src/lib.rs index 3ff32db43..ce52b452a 100644 --- a/rumqttc/src/lib.rs +++ b/rumqttc/src/lib.rs @@ -491,25 +491,14 @@ impl MqttOptions { /// # use rumqttc::MqttOptions; /// let options = MqttOptions::new("123", "localhost", 1883); /// ``` - /// NOTE: you are not allowed to use an id that starts with a whitespace or is empty. - /// for example, the following code would panic: - /// ```should_panic - /// # use rumqttc::MqttOptions; - /// let options = MqttOptions::new("", "localhost", 1883); - /// ``` pub fn new, T: Into>(id: S, host: T, port: u16) -> MqttOptions { - let id = id.into(); - if id.starts_with(' ') || id.is_empty() { - panic!("Invalid client id"); - } - MqttOptions { broker_addr: host.into(), port, transport: Transport::tcp(), keep_alive: Duration::from_secs(60), clean_session: true, - client_id: id, + client_id: id.into(), credentials: None, max_incoming_packet_size: 10 * 1024, max_outgoing_packet_size: 10 * 1024, @@ -624,7 +613,21 @@ impl MqttOptions { /// When set `false`, broker will hold the client state and performs pending /// operations on the client when reconnection with same `client_id` /// happens. Local queue state is also held to retransmit packets after reconnection. + /// + /// # Panic + /// + /// Panics if `clean_session` is false when `client_id` is empty. + /// + /// ```should_panic + /// # use rumqttc::MqttOptions; + /// let mut options = MqttOptions::new("", "localhost", 1883); + /// options.set_clean_session(false); + /// ``` pub fn set_clean_session(&mut self, clean_session: bool) -> &mut Self { + assert!( + !self.client_id.is_empty() || clean_session, + "Cannot unset clean session when client id is empty" + ); self.clean_session = clean_session; self } @@ -918,12 +921,6 @@ impl Debug for MqttOptions { mod test { use super::*; - #[test] - #[should_panic] - fn client_id_startswith_space() { - let _mqtt_opts = MqttOptions::new(" client_a", "127.0.0.1", 1883).set_clean_session(true); - } - #[test] #[cfg(all(feature = "use-rustls", feature = "websocket"))] fn no_scheme() { @@ -1008,8 +1005,14 @@ mod test { } #[test] - #[should_panic] - fn no_client_id() { + fn accept_empty_client_id() { let _mqtt_opts = MqttOptions::new("", "127.0.0.1", 1883).set_clean_session(true); } + + #[test] + fn set_clean_session_when_client_id_present() { + let mut options = MqttOptions::new("client_id", "127.0.0.1", 1883); + options.set_clean_session(false); + options.set_clean_session(true); + } } diff --git a/rumqttc/src/v5/mod.rs b/rumqttc/src/v5/mod.rs index 4b6793b03..04a50a4c2 100644 --- a/rumqttc/src/v5/mod.rs +++ b/rumqttc/src/v5/mod.rs @@ -113,28 +113,17 @@ impl MqttOptions { /// - port: The port number on which broker must be listening for incoming connections /// /// ``` - /// # use rumqttc::MqttOptions; + /// # use rumqttc::v5::MqttOptions; /// let options = MqttOptions::new("123", "localhost", 1883); /// ``` - /// NOTE: you are not allowed to use an id that starts with a whitespace or is empty. - /// for example, the following code would panic: - /// ```should_panic - /// # use rumqttc::MqttOptions; - /// let options = MqttOptions::new("", "localhost", 1883); - /// ``` pub fn new, T: Into>(id: S, host: T, port: u16) -> MqttOptions { - let id = id.into(); - if id.starts_with(' ') || id.is_empty() { - panic!("Invalid client id"); - } - MqttOptions { broker_addr: host.into(), port, transport: Transport::tcp(), keep_alive: Duration::from_secs(60), clean_start: true, - client_id: id, + client_id: id.into(), credentials: None, request_channel_capacity: 10, max_request_batch: 0, @@ -730,12 +719,6 @@ impl Debug for MqttOptions { mod test { use super::*; - #[test] - #[should_panic] - fn client_id_startswith_space() { - let _mqtt_opts = MqttOptions::new(" client_a", "127.0.0.1", 1883).set_clean_start(true); - } - #[test] #[cfg(all(feature = "use-rustls", feature = "websocket"))] fn no_scheme() { @@ -821,8 +804,7 @@ mod test { } #[test] - #[should_panic] - fn no_client_id() { + fn allow_empty_client_id() { let _mqtt_opts = MqttOptions::new("", "127.0.0.1", 1883).set_clean_start(true); } } From d34871065ca9cae7830a67b86aedfefcb46af960 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Wed, 14 Feb 2024 16:45:17 +0000 Subject: [PATCH 5/9] chore(rumqttd): update rustls and friends (#795) --- Cargo.lock | 86 +++++++++++++++++++++++++++++++++----- rumqttd/CHANGELOG.md | 2 + rumqttd/Cargo.toml | 8 ++-- rumqttd/src/link/bridge.rs | 49 ++++++---------------- rumqttd/src/server/tls.rs | 47 ++++++++++++--------- 5 files changed, 121 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76c7eea3d..9522b1b68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,7 +184,7 @@ dependencies = [ "pin-project-lite", "rustls-native-certs", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tungstenite", ] @@ -1835,13 +1835,13 @@ dependencies = [ "pretty_assertions", "pretty_env_logger", "rustls-native-certs", - "rustls-pemfile", - "rustls-webpki", + "rustls-pemfile 1.0.4", + "rustls-webpki 0.101.7", "serde", "thiserror", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.24.1", "url", "ws_stream_tungstenite", ] @@ -1863,15 +1863,15 @@ dependencies = [ "pretty_assertions", "pretty_env_logger", "rand", - "rustls-pemfile", - "rustls-webpki", + "rustls-pemfile 2.0.0", + "rustls-webpki 0.102.2", "serde", "serde_json", "slab", "thiserror", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.25.0", "tokio-util", "tracing", "tracing-subscriber", @@ -1934,10 +1934,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -1945,7 +1959,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] @@ -1959,6 +1973,22 @@ dependencies = [ "base64 0.21.5", ] +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64 0.21.5", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -1969,6 +1999,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2207,6 +2248,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "symbolic-common" version = "12.8.0" @@ -2412,7 +2459,18 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.2", + "rustls-pki-types", "tokio", ] @@ -2548,7 +2606,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls", + "rustls 0.21.10", "sha1", "thiserror", "url", @@ -2972,3 +3030,9 @@ dependencies = [ "quote", "syn 2.0.40", ] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/rumqttd/CHANGELOG.md b/rumqttd/CHANGELOG.md index 6088c2b23..e429b0a72 100644 --- a/rumqttd/CHANGELOG.md +++ b/rumqttd/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Public re-export `Strategy` for shared subscriptions - Peer initiated disconnects logged as info rather than error. +- Update `tokio-rustls` to `0.25.0`, `rustls-webpki` to `0.102.1`, `tokio-native-tls` to `0.3.1` and + `rust-pemfile` to `2.0.0`. ### Deprecated diff --git a/rumqttd/Cargo.toml b/rumqttd/Cargo.toml index e8d96dfbc..62c9f5f51 100644 --- a/rumqttd/Cargo.toml +++ b/rumqttd/Cargo.toml @@ -20,10 +20,10 @@ flume = { version = "0.11.0", default-features = false, features = ["async"]} slab = "0.4.9" thiserror = "1.0.49" tokio-util = { version = "0.7", features = ["codec"], optional = true } -tokio-rustls = { version = "0.24", optional = true } -rustls-webpki = { version = "0.101.6", optional = true } -tokio-native-tls = { version = "0.3", optional = true } -rustls-pemfile = { version = "1", optional = true } +tokio-rustls = { version = "0.25.0", optional = true } +rustls-webpki = { version = "0.102.1", optional = true } +tokio-native-tls = { version = "0.3.1", optional = true } +rustls-pemfile = { version = "2.0.0", optional = true } async-tungstenite = { version = "0.23", default-features = false, features = ["tokio-runtime"], optional = true } ws_stream_tungstenite = { version= "0.11", default-features = false, features = ["tokio_io"], optional = true } x509-parser = {version= "0.15.1", optional = true} diff --git a/rumqttd/src/link/bridge.rs b/rumqttd/src/link/bridge.rs index 7898ac5df..cc3089473 100644 --- a/rumqttd/src/link/bridge.rs +++ b/rumqttd/src/link/bridge.rs @@ -18,8 +18,8 @@ use tokio::{ #[cfg(feature = "use-rustls")] use tokio_rustls::{ rustls::{ - client::InvalidDnsNameError, Certificate, ClientConfig, Error as TLSError, - OwnedTrustAnchor, PrivateKey, RootCertStore, ServerName, + pki_types::{InvalidDnsNameError, ServerName}, + ClientConfig, Error as TLSError, RootCertStore, }, TlsConnector, }; @@ -198,62 +198,39 @@ pub async fn tls_connect>( ) -> Result, BridgeError> { let mut root_cert_store = RootCertStore::empty(); - let ca_certs = rustls_pemfile::certs(&mut BufReader::new(Cursor::new(fs::read(ca_file)?)))?; - let trust_anchors = ca_certs.iter().map_while(|cert| { - if let Ok(ta) = webpki::TrustAnchor::try_from_cert_der(&cert[..]) { - Some(OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - )) - } else { - None - } - }); - - root_cert_store.add_trust_anchors(trust_anchors); + for cert in rustls_pemfile::certs(&mut BufReader::new(Cursor::new(fs::read(ca_file)?))) { + root_cert_store.add(cert?)?; + } if root_cert_store.is_empty() { return Err(BridgeError::NoValidCertInChain); } - let config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(root_cert_store); + let config = ClientConfig::builder().with_root_certificates(root_cert_store); let config = if let Some(ClientAuth { certs: certs_path, key: key_path, }) = client_auth_opt { - let read_certs = - rustls_pemfile::certs(&mut BufReader::new(Cursor::new(fs::read(certs_path)?)))?; + let certs = rustls_pemfile::certs(&mut BufReader::new(Cursor::new(fs::read(certs_path)?))) + .collect::, _>>()?; - let read_keys = match rustls_pemfile::read_one(&mut BufReader::new(Cursor::new(fs::read( + let key = match rustls_pemfile::read_one(&mut BufReader::new(Cursor::new(fs::read( key_path, )?)))? { - Some(rustls_pemfile::Item::RSAKey(_)) => rustls_pemfile::rsa_private_keys( - &mut BufReader::new(Cursor::new(fs::read(key_path)?)), - )?, - Some(rustls_pemfile::Item::PKCS8Key(_)) => rustls_pemfile::pkcs8_private_keys( - &mut BufReader::new(Cursor::new(fs::read(key_path)?)), - )?, + Some(rustls_pemfile::Item::Pkcs1Key(key)) => key.into(), + Some(rustls_pemfile::Item::Pkcs8Key(key)) => key.into(), None | Some(_) => return Err(BridgeError::NoValidCertInChain), }; - let read_key = match read_keys.first() { - Some(v) => v.clone(), - None => return Err(BridgeError::NoValidCertInChain), - }; - - let certs = read_certs.into_iter().map(Certificate).collect(); - config.with_client_auth_cert(certs, PrivateKey(read_key))? + config.with_client_auth_cert(certs, key)? } else { config.with_no_client_auth() }; let connector = TlsConnector::from(Arc::new(config)); - let domain = ServerName::try_from(host).unwrap(); + let domain = ServerName::try_from(host)?.to_owned(); Ok(Box::new(connector.connect(domain, tcp).await?)) } diff --git a/rumqttd/src/server/tls.rs b/rumqttd/src/server/tls.rs index d402c8440..3f28ffdaa 100644 --- a/rumqttd/src/server/tls.rs +++ b/rumqttd/src/server/tls.rs @@ -9,12 +9,12 @@ use { use crate::TlsConfig; #[cfg(feature = "verify-client-cert")] -use tokio_rustls::rustls::{server::AllowAnyAuthenticatedClient, RootCertStore}; +use tokio_rustls::rustls::{server::WebPkiClientVerifier, RootCertStore}; #[cfg(feature = "use-rustls")] use { rustls_pemfile::Item, std::{io::BufReader, sync::Arc}, - tokio_rustls::rustls::{Certificate, Error as RustlsError, PrivateKey, ServerConfig}, + tokio_rustls::rustls::{pki_types::PrivateKeyDer, Error as RustlsError, ServerConfig}, tracing::error, }; @@ -127,7 +127,7 @@ impl TLSAcceptor { let peer_certificates = session .peer_certificates() .ok_or(Error::NoPeerCertificate)?; - extract_tenant_id(&peer_certificates[0].0)? + extract_tenant_id(&peer_certificates[0])? }; #[cfg(not(feature = "verify-client-cert"))] let tenant_id: Option = None; @@ -200,12 +200,9 @@ impl TLSAcceptor { // Get certificates let cert_file = File::open(cert_path); let cert_file = cert_file.map_err(|_| Error::ServerCertNotFound(cert_path.clone()))?; - let certs = rustls_pemfile::certs(&mut BufReader::new(cert_file)); - let certs = certs.map_err(|_| Error::InvalidServerCert(cert_path.to_string()))?; - let certs = certs - .iter() - .map(|cert| Certificate(cert.to_owned())) - .collect(); + let certs = rustls_pemfile::certs(&mut BufReader::new(cert_file)) + .collect::, _>>() + .map_err(|_| Error::InvalidServerCert(cert_path.to_string()))?; // Get private key let key = first_private_key_in_pemfile(key_path)?; @@ -213,7 +210,7 @@ impl TLSAcceptor { (certs, key) }; - let builder = ServerConfig::builder().with_safe_defaults(); + let builder = ServerConfig::builder(); // client authentication with a CA. CA isn't required otherwise #[cfg(feature = "verify-client-cert")] @@ -221,18 +218,22 @@ impl TLSAcceptor { let ca_file = File::open(ca_path); let ca_file = ca_file.map_err(|_| Error::CaFileNotFound(ca_path.clone()))?; let ca_file = &mut BufReader::new(ca_file); - let ca_certs = rustls_pemfile::certs(ca_file)?; - let ca_cert = ca_certs - .first() - .map(|c| Certificate(c.to_owned())) - .ok_or_else(|| Error::InvalidCACert(ca_path.to_string()))?; + let ca_cert = rustls_pemfile::certs(ca_file) + .next() + .ok_or_else(|| Error::InvalidCACert(ca_path.to_string()))??; let mut store = RootCertStore::empty(); store - .add(&ca_cert) + .add(ca_cert) .map_err(|_| Error::InvalidCACert(ca_path.to_string()))?; - builder.with_client_cert_verifier(Arc::new(AllowAnyAuthenticatedClient::new(store))) + // This will only return an error if no trust anchors are provided or invalid CRLs are + // provided. We always provide a trust anchor, and don't provide any CRLs, so it is safe + // to unwrap. + let verifier = WebPkiClientVerifier::builder(Arc::new(store)) + .build() + .unwrap(); + builder.with_client_cert_verifier(verifier) }; #[cfg(not(feature = "verify-client-cert"))] @@ -247,7 +248,7 @@ impl TLSAcceptor { #[cfg(feature = "use-rustls")] /// Get the first private key in a PEM file -fn first_private_key_in_pemfile(key_path: &String) -> Result { +fn first_private_key_in_pemfile(key_path: &String) -> Result, Error> { // Get private key let key_file = File::open(key_path); let key_file = key_file.map_err(|_| Error::ServerKeyNotFound(key_path.clone()))?; @@ -262,8 +263,14 @@ fn first_private_key_in_pemfile(key_path: &String) -> Result })?; match item { - Some(Item::ECKey(key) | Item::RSAKey(key) | Item::PKCS8Key(key)) => { - return Ok(PrivateKey(key)); + Some(Item::Sec1Key(key)) => { + return Ok(key.into()); + } + Some(Item::Pkcs1Key(key)) => { + return Ok(key.into()); + } + Some(Item::Pkcs8Key(key)) => { + return Ok(key.into()); } None => { error!("No private key found in {:?}", key_path); From 09fd7632ab4a68a98f87cce4fc08d30a99ebd52f Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Thu, 15 Feb 2024 05:10:17 +0000 Subject: [PATCH 6/9] chore(rumqttc): update rustls and friends (#790) --- Cargo.lock | 170 ++++++++++++++++++++++------------------ rumqttc/CHANGELOG.md | 4 + rumqttc/Cargo.toml | 16 ++-- rumqttc/examples/tls.rs | 7 +- rumqttc/src/lib.rs | 6 +- rumqttc/src/tls.rs | 47 +++++------ rumqttc/src/v5/mod.rs | 1 - 7 files changed, 129 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9522b1b68..bb1c9d545 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,15 +177,30 @@ name = "async-tungstenite" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1e9efbe14612da0a19fb983059a0b621e9cf6225d7018ecab4f9988215540dc" +dependencies = [ + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "tokio", + "tungstenite 0.20.1", +] + +[[package]] +name = "async-tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" dependencies = [ "futures-io", "futures-util", "log", "pin-project-lite", "rustls-native-certs", + "rustls-pki-types", "tokio", - "tokio-rustls 0.24.1", - "tungstenite", + "tokio-rustls", + "tungstenite 0.21.0", ] [[package]] @@ -217,7 +232,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", + "http 0.2.11", "http-body", "hyper", "itoa", @@ -247,7 +262,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.11", "http-body", "mime", "rustversion", @@ -861,6 +876,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -868,7 +894,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] @@ -900,7 +926,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http", + "http 0.2.11", "http-body", "httparse", "httpdate", @@ -1822,35 +1848,35 @@ name = "rumqttc" version = "0.23.0" dependencies = [ "async-http-proxy", - "async-tungstenite", + "async-tungstenite 0.24.0", "bincode", "bytes", "color-backtrace", "flume", "futures-util", - "http", + "http 1.0.0", "log", "matches", "native-tls", "pretty_assertions", "pretty_env_logger", "rustls-native-certs", - "rustls-pemfile 1.0.4", - "rustls-webpki 0.101.7", + "rustls-pemfile", + "rustls-webpki", "serde", "thiserror", "tokio", "tokio-native-tls", - "tokio-rustls 0.24.1", + "tokio-rustls", "url", - "ws_stream_tungstenite", + "ws_stream_tungstenite 0.12.0", ] [[package]] name = "rumqttd" version = "0.19.0" dependencies = [ - "async-tungstenite", + "async-tungstenite 0.23.0", "axum", "bytes", "clap", @@ -1863,19 +1889,19 @@ dependencies = [ "pretty_assertions", "pretty_env_logger", "rand", - "rustls-pemfile 2.0.0", - "rustls-webpki 0.102.2", + "rustls-pemfile", + "rustls-webpki", "serde", "serde_json", "slab", "thiserror", "tokio", "tokio-native-tls", - "tokio-rustls 0.25.0", + "tokio-rustls", "tokio-util", "tracing", "tracing-subscriber", - "ws_stream_tungstenite", + "ws_stream_tungstenite 0.11.0", "x509-parser", ] @@ -1926,18 +1952,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.21.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.7", - "sct", -] - [[package]] name = "rustls" version = "0.22.2" @@ -1947,32 +1961,24 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki", "subtle", "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.4", + "rustls-pemfile", + "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.5", -] - [[package]] name = "rustls-pemfile" version = "2.0.0" @@ -1989,16 +1995,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf" -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustls-webpki" version = "0.102.2" @@ -2037,16 +2033,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "security-framework" version = "2.9.2" @@ -2453,23 +2439,13 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.10", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.2", + "rustls", "rustls-pki-types", "tokio", ] @@ -2602,11 +2578,31 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.11", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.0.0", "httparse", "log", "rand", - "rustls 0.21.10", + "rustls", + "rustls-pki-types", "sha1", "thiserror", "url", @@ -2965,7 +2961,27 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e283cc794a890f5bdc01e358ad7c34535025f79ba83c1b5c7e01e5d6c60b336d" dependencies = [ - "async-tungstenite", + "async-tungstenite 0.23.0", + "async_io_stream", + "bitflags 2.4.1", + "futures-core", + "futures-io", + "futures-sink", + "futures-util", + "pharos", + "rustc_version", + "tokio", + "tracing", + "tungstenite 0.20.1", +] + +[[package]] +name = "ws_stream_tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2792b148f4aabd04af007bf0fc6f89a8d69980d083c296dfbd7b0d99bbdcfeb8" +dependencies = [ + "async-tungstenite 0.24.0", "async_io_stream", "bitflags 2.4.1", "futures-core", @@ -2976,7 +2992,7 @@ dependencies = [ "rustc_version", "tokio", "tracing", - "tungstenite", + "tungstenite 0.21.0", ] [[package]] diff --git a/rumqttc/CHANGELOG.md b/rumqttc/CHANGELOG.md index b9c6f73b8..c6fd3a88f 100644 --- a/rumqttc/CHANGELOG.md +++ b/rumqttc/CHANGELOG.md @@ -25,6 +25,10 @@ To update your code simply remove `Key::ECC()` or `Key::RSA()` from the initiali - Make v5 `RetainForwardRule` public, in order to allow setting it when constructing `Filter` values. - Use `VecDeque` instead of `IntoIter` to fix unintentional drop of pending requests on `EventLoop::clean` (#780) - `StateError::IncommingPacketTooLarge` is now `StateError::IncomingPacketTooLarge`. +- Update `tokio-rustls` to `0.25.0`, `rustls-native-certs` to `0.7.0`, `rustls-webpki` to `0.102.1`, + `rusttls-pemfile` to `2.0.0`, `async-tungstenite` to `0.24.0`, `ws_stream_tungstenite` to `0.12.0` + and `http` to `1.0.0`. This is a breaking change as types from some of these crates are part of + the public API. ### Deprecated diff --git a/rumqttc/Cargo.toml b/rumqttc/Cargo.toml index 483f9de7b..834b1984c 100644 --- a/rumqttc/Cargo.toml +++ b/rumqttc/Cargo.toml @@ -27,19 +27,19 @@ futures-util = { version = "0.3", default_features = false, features = ["std"] } tokio = { version = "1.33", features = ["rt", "macros", "io-util", "net", "time"] } bytes = "1.5" log = "0.4" -flume = { version = "0.11", default-features = false, features = ["async"]} +flume = { version = "0.11", default-features = false, features = ["async"] } thiserror = "1" # Optional # rustls -tokio-rustls = { version = "0.24", optional = true } -rustls-webpki = { version = "0.101.6", optional = true } -rustls-pemfile = { version = "1", optional = true } -rustls-native-certs = { version = "0.6", optional = true } +tokio-rustls = { version = "0.25.0", optional = true } +rustls-webpki = { version = "0.102.1", optional = true } +rustls-pemfile = { version = "2.0.0", optional = true } +rustls-native-certs = { version = "0.7.0", optional = true } # websockets -async-tungstenite = { version = "0.23", default-features = false, features = ["tokio-rustls-native-certs"], optional = true } -ws_stream_tungstenite = { version= "0.11", default-features = false, features = ["tokio_io"], optional = true } -http = { version = "0.2", optional = true } +async-tungstenite = { version = "0.24.0", default-features = false, features = ["tokio-rustls-native-certs"], optional = true } +ws_stream_tungstenite = { version= "0.12.0", default-features = false, features = ["tokio_io"], optional = true } +http = { version = "1.0.0", optional = true } # native-tls tokio-native-tls = { version = "0.3.1", optional = true } native-tls = { version = "0.2.11", optional = true } diff --git a/rumqttc/examples/tls.rs b/rumqttc/examples/tls.rs index 1f57b829e..dc08636f1 100644 --- a/rumqttc/examples/tls.rs +++ b/rumqttc/examples/tls.rs @@ -15,12 +15,11 @@ async fn main() -> Result<(), Box> { // Use rustls-native-certs to load root certificates from the operating system. let mut root_cert_store = tokio_rustls::rustls::RootCertStore::empty(); - for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") { - root_cert_store.add(&tokio_rustls::rustls::Certificate(cert.0))?; - } + root_cert_store.add_parsable_certificates( + rustls_native_certs::load_native_certs().expect("could not load platform certs"), + ); let client_config = ClientConfig::builder() - .with_safe_defaults() .with_root_certificates(root_cert_store) .with_no_client_auth(); diff --git a/rumqttc/src/lib.rs b/rumqttc/src/lib.rs index ce52b452a..43dbb3bed 100644 --- a/rumqttc/src/lib.rs +++ b/rumqttc/src/lib.rs @@ -148,7 +148,7 @@ pub use tls::Error as TlsError; #[cfg(feature = "use-rustls")] pub use tokio_rustls; #[cfg(feature = "use-rustls")] -use tokio_rustls::rustls::{Certificate, ClientConfig, RootCertStore}; +use tokio_rustls::rustls::{ClientConfig, RootCertStore}; #[cfg(feature = "proxy")] pub use proxy::{Proxy, ProxyAuth, ProxyType}; @@ -366,10 +366,9 @@ impl Default for TlsConfiguration { fn default() -> Self { let mut root_cert_store = RootCertStore::empty(); for cert in load_native_certs().expect("could not load platform certs") { - root_cert_store.add(&Certificate(cert.0)).unwrap(); + root_cert_store.add(cert).unwrap(); } let tls_config = ClientConfig::builder() - .with_safe_defaults() .with_root_certificates(root_cert_store) .with_no_client_auth(); @@ -536,7 +535,6 @@ impl MqttOptions { /// # use tokio_rustls::rustls::ClientConfig; /// # let root_cert_store = rustls::RootCertStore::empty(); /// # let client_config = ClientConfig::builder() - /// # .with_safe_defaults() /// # .with_root_certificates(root_cert_store) /// # .with_no_client_auth(); /// let mut options = MqttOptions::parse_url("mqtts://example.com?client_id=123").unwrap(); diff --git a/rumqttc/src/tls.rs b/rumqttc/src/tls.rs index 88fd103f9..c8e775712 100644 --- a/rumqttc/src/tls.rs +++ b/rumqttc/src/tls.rs @@ -1,12 +1,10 @@ #[cfg(feature = "use-rustls")] use rustls_pemfile::Item; #[cfg(feature = "use-rustls")] -use tokio_rustls::rustls; -#[cfg(feature = "use-rustls")] -use tokio_rustls::rustls::client::InvalidDnsNameError; -#[cfg(feature = "use-rustls")] use tokio_rustls::rustls::{ - Certificate, ClientConfig, OwnedTrustAnchor, PrivateKey, RootCertStore, ServerName, + self, + pki_types::{InvalidDnsNameError, ServerName}, + ClientConfig, RootCertStore, }; #[cfg(feature = "use-rustls")] use tokio_rustls::TlsConnector as RustlsConnector; @@ -77,34 +75,22 @@ pub async fn rustls_connector(tls_config: &TlsConfiguration) -> Result { // Add ca to root store if the connection is TLS let mut root_cert_store = RootCertStore::empty(); - let certs = rustls_pemfile::certs(&mut BufReader::new(Cursor::new(ca)))?; - - let trust_anchors = certs.iter().map_while(|cert| { - if let Ok(ta) = webpki::TrustAnchor::try_from_cert_der(&cert[..]) { - Some(OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - )) - } else { - None - } - }); + let certs = rustls_pemfile::certs(&mut BufReader::new(Cursor::new(ca))) + .collect::, _>>()?; - root_cert_store.add_trust_anchors(trust_anchors); + root_cert_store.add_parsable_certificates(certs); if root_cert_store.is_empty() { return Err(Error::NoValidCertInChain); } - let config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(root_cert_store); + let config = ClientConfig::builder().with_root_certificates(root_cert_store); // Add der encoded client cert and key let mut config = if let Some(client) = client_auth.as_ref() { let certs = - rustls_pemfile::certs(&mut BufReader::new(Cursor::new(client.0.clone())))?; + rustls_pemfile::certs(&mut BufReader::new(Cursor::new(client.0.clone()))) + .collect::, _>>()?; if certs.is_empty() { return Err(Error::NoValidClientCertInChain); } @@ -116,16 +102,21 @@ pub async fn rustls_connector(tls_config: &TlsConfiguration) -> Result { - break key; + Some(Item::Sec1Key(key)) => { + break key.into(); + } + Some(Item::Pkcs1Key(key)) => { + break key.into(); + } + Some(Item::Pkcs8Key(key)) => { + break key.into(); } None => return Err(Error::NoValidKeyInChain), _ => {} } }; - let certs = certs.into_iter().map(Certificate).collect(); - config.with_client_auth_cert(certs, PrivateKey(key))? + config.with_client_auth_cert(certs, key)? } else { config.with_no_client_auth() }; @@ -181,7 +172,7 @@ pub async fn tls_connect( #[cfg(feature = "use-rustls")] TlsConfiguration::Simple { .. } | TlsConfiguration::Rustls(_) => { let connector = rustls_connector(tls_config).await?; - let domain = ServerName::try_from(addr)?; + let domain = ServerName::try_from(addr)?.to_owned(); Box::new(connector.connect(domain, tcp).await?) } #[cfg(feature = "use-native-tls")] diff --git a/rumqttc/src/v5/mod.rs b/rumqttc/src/v5/mod.rs index 04a50a4c2..663cfd278 100644 --- a/rumqttc/src/v5/mod.rs +++ b/rumqttc/src/v5/mod.rs @@ -163,7 +163,6 @@ impl MqttOptions { /// # use tokio_rustls::rustls::ClientConfig; /// # let root_cert_store = rustls::RootCertStore::empty(); /// # let client_config = ClientConfig::builder() - /// # .with_safe_defaults() /// # .with_root_certificates(root_cert_store) /// # .with_no_client_auth(); /// let mut options = MqttOptions::parse_url("mqtts://example.com?client_id=123").unwrap(); From 12595e811023463b49e95a7441f718a8ef94d780 Mon Sep 17 00:00:00 2001 From: Swanand Mulay <73115739+swanandx@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:23:59 +0530 Subject: [PATCH 7/9] chore: update dependencies (#799) --- Cargo.lock | 880 +++++++++++++++++++---------------- rumqttc/Cargo.toml | 12 +- rumqttd/Cargo.toml | 30 +- rumqttd/src/link/console.rs | 12 +- rumqttd/src/server/broker.rs | 8 +- 5 files changed, 517 insertions(+), 425 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb1c9d545..37b054a96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,20 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.7" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "getrandom", @@ -52,9 +41,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -66,9 +55,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -100,9 +89,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "arrayvec" @@ -163,34 +152,20 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "async-tungstenite" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e9efbe14612da0a19fb983059a0b621e9cf6225d7018ecab4f9988215540dc" -dependencies = [ - "futures-io", - "futures-util", - "log", - "pin-project-lite", - "tokio", - "tungstenite 0.20.1", -] - -[[package]] -name = "async-tungstenite" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" +checksum = "ef0f8d64ef9351752fbe5462f242c625d9c4910d2bc3f7ec44c43857ca123f5d" dependencies = [ "futures-io", "futures-util", @@ -200,7 +175,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite 0.21.0", + "tungstenite", ] [[package]] @@ -209,12 +184,23 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ - "futures 0.3.29", + "futures 0.3.30", "pharos", "rustc_version", "tokio", ] +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -223,18 +209,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.11", - "http-body", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -251,23 +238,28 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.11", - "http-body", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -293,16 +285,16 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "benchmarks" version = "0.4.0" dependencies = [ "bytes", - "futures 0.3.29", + "futures 0.3.30", "itoa", "pprof", "pretty_env_logger", @@ -330,9 +322,12 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] [[package]] name = "block-buffer" @@ -345,15 +340,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -387,9 +382,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.11" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -397,9 +392,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", @@ -409,28 +404,29 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "color-backtrace" -version = "0.6.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150fd80a270c0671379f388c8204deb6a746bb4eac8a6c03fe2460b2c0127ea0" +checksum = "cd6c04463c99389fff045d2b90ce84f5131332712c7ffbede020f5e9ad1ed685" dependencies = [ + "atty", "backtrace", "termcolor", ] @@ -443,11 +439,12 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "config" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ "async-trait", + "convert_case", "json5", "lazy_static", "nom", @@ -460,6 +457,35 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "const-random" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -487,34 +513,33 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" @@ -557,9 +582,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] @@ -588,26 +613,29 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "dlv-list" -version = "0.3.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -705,9 +733,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -720,9 +748,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -730,15 +758,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -747,38 +775,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures 0.1.31", "futures-channel", @@ -805,9 +833,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -821,28 +849,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] -name = "hashbrown" -version = "0.12.3" +name = "h2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" dependencies = [ - "ahash 0.7.7", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] name = "hashbrown" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" -dependencies = [ - "ahash 0.8.6", -] +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", +] [[package]] name = "heck" @@ -852,17 +890,26 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -898,6 +945,29 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.8.0" @@ -918,21 +988,21 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", "http 0.2.11", - "http-body", + "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", @@ -940,30 +1010,68 @@ dependencies = [ ] [[package]] -name = "idna" +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "hyper-tls" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "bytes", + "hyper 0.14.28", + "native-tls", + "tokio", + "tokio-native-tls", ] [[package]] -name = "indexmap" -version = "1.9.3" +name = "hyper-util" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2", + "tokio", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", ] [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -975,8 +1083,8 @@ version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" dependencies = [ - "ahash 0.8.6", - "indexmap 2.1.0", + "ahash", + "indexmap", "is-terminal", "itoa", "log", @@ -995,13 +1103,13 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "hermit-abi 0.3.6", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -1021,9 +1129,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1047,9 +1155,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linked-hash-map" @@ -1059,9 +1167,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -1079,15 +1187,6 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "mach2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0d1830bcd151a6fc4aea1369af235b36c1528fe976b8ff678683c9995eade8" -dependencies = [ - "libc", -] - [[package]] name = "matchers" version = "0.1.0" @@ -1111,48 +1210,39 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" -version = "0.9.0" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "metrics" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5" +checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4" dependencies = [ - "ahash 0.8.6", - "metrics-macros", + "ahash", "portable-atomic", ] [[package]] name = "metrics-exporter-prometheus" -version = "0.12.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a4964177ddfdab1e3a2b37aec7cf320e14169abb0ed73999f558136409178d5" +checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" dependencies = [ - "base64 0.21.5", - "hyper", - "indexmap 1.9.3", + "base64 0.21.7", + "hyper 0.14.28", + "hyper-tls", + "indexmap", "ipnet", "metrics", "metrics-util", @@ -1162,26 +1252,15 @@ dependencies = [ "tracing", ] -[[package]] -name = "metrics-macros" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddece26afd34c31585c74a4db0630c376df271c285d682d1e55012197830b6df" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.40", -] - [[package]] name = "metrics-util" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" +checksum = "ece71ab046dcf45604e573329966ec1db5ff4b81cfa170a924ff4c959ab5451a" dependencies = [ "crossbeam-epoch", "crossbeam-utils", - "hashbrown 0.13.1", + "hashbrown 0.14.3", "metrics", "num_cpus", "quanta", @@ -1202,9 +1281,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -1286,6 +1365,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" @@ -1298,19 +1383,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -1321,15 +1405,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.6", "libc", ] [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1351,11 +1435,11 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.61" +version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -1372,7 +1456,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -1383,9 +1467,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.97" +version = "0.9.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", @@ -1395,12 +1479,12 @@ dependencies = [ [[package]] name = "ordered-multimap" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" dependencies = [ "dlv-list", - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -1446,9 +1530,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -1457,9 +1541,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -1467,22 +1551,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -1496,7 +1580,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap", ] [[package]] @@ -1505,28 +1589,28 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ - "futures 0.3.29", + "futures 0.3.30", "rustc_version", ] [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -1543,9 +1627,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "portable-atomic" @@ -1612,19 +1696,19 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1656,7 +1740,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.40", + "syn 2.0.49", "tempfile", "which", ] @@ -1671,7 +1755,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -1685,13 +1769,12 @@ dependencies = [ [[package]] name = "quanta" -version = "0.11.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab" +checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" dependencies = [ "crossbeam-utils", "libc", - "mach2", "once_cell", "raw-cpuid", "wasi", @@ -1710,9 +1793,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1749,11 +1832,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "10.7.0" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", ] [[package]] @@ -1767,13 +1850,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -1788,9 +1871,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -1834,13 +1917,14 @@ dependencies = [ [[package]] name = "ron" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", + "bitflags 2.4.2", "serde", + "serde_derive", ] [[package]] @@ -1848,7 +1932,7 @@ name = "rumqttc" version = "0.23.0" dependencies = [ "async-http-proxy", - "async-tungstenite 0.24.0", + "async-tungstenite", "bincode", "bytes", "color-backtrace", @@ -1869,14 +1953,14 @@ dependencies = [ "tokio-native-tls", "tokio-rustls", "url", - "ws_stream_tungstenite 0.12.0", + "ws_stream_tungstenite", ] [[package]] name = "rumqttd" version = "0.19.0" dependencies = [ - "async-tungstenite 0.23.0", + "async-tungstenite", "axum", "bytes", "clap", @@ -1901,15 +1985,15 @@ dependencies = [ "tokio-util", "tracing", "tracing-subscriber", - "ws_stream_tungstenite 0.11.0", + "ws_stream_tungstenite", "x509-parser", ] [[package]] name = "rust-ini" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ "cfg-if", "ordered-multimap", @@ -1941,11 +2025,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -1981,19 +2065,19 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +checksum = "3c333bb734fcdedcea57de1602543590f545f127dc8b533324318fd492c5c70b" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf" +checksum = "048a63e5b3ac996d78d402940b5fa47973d2d080c6c6fffa1d0f19c4445310b7" [[package]] name = "rustls-webpki" @@ -2020,11 +2104,11 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2058,35 +2142,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -2095,14 +2179,23 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" dependencies = [ "itoa", "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2168,9 +2261,9 @@ dependencies = [ [[package]] name = "sketches-ddsketch" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1" +checksum = "85636c14b73d81f541e525f585c0a2109e6744e1565b5c1668e31c70c10ed65c" [[package]] name = "slab" @@ -2183,19 +2276,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - -[[package]] -name = "socket2" -version = "0.4.10" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -2230,9 +2313,9 @@ checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "subtle" @@ -2276,9 +2359,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.40" +version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fa70a4ee923979ffb522cacce59d34421ebdea5625e1073c4326ef9d2dd42e" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", @@ -2305,44 +2388,43 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -2357,12 +2439,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -2377,13 +2460,23 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2401,9 +2494,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -2413,7 +2506,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -2426,7 +2519,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -2466,11 +2559,36 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" dependencies = [ + "indexmap", "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] @@ -2521,7 +2639,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] @@ -2569,25 +2687,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 0.2.11", - "httparse", - "log", - "rand", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.21.0" @@ -2623,9 +2722,9 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -2642,6 +2741,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -2679,9 +2784,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" [[package]] name = "valuable" @@ -2718,9 +2823,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2728,24 +2833,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2753,28 +2858,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -2956,34 +3061,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] -name = "ws_stream_tungstenite" -version = "0.11.0" +name = "winnow" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e283cc794a890f5bdc01e358ad7c34535025f79ba83c1b5c7e01e5d6c60b336d" +checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" dependencies = [ - "async-tungstenite 0.23.0", - "async_io_stream", - "bitflags 2.4.1", - "futures-core", - "futures-io", - "futures-sink", - "futures-util", - "pharos", - "rustc_version", - "tokio", - "tracing", - "tungstenite 0.20.1", + "memchr", ] [[package]] name = "ws_stream_tungstenite" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2792b148f4aabd04af007bf0fc6f89a8d69980d083c296dfbd7b0d99bbdcfeb8" +checksum = "a198f414f083fb19fcc1bffcb0fa0cf46d33ccfa229adf248cac12c180e91609" dependencies = [ - "async-tungstenite 0.24.0", + "async-tungstenite", "async_io_stream", - "bitflags 2.4.1", + "bitflags 2.4.2", "futures-core", "futures-io", "futures-sink", @@ -2992,7 +3086,7 @@ dependencies = [ "rustc_version", "tokio", "tracing", - "tungstenite 0.21.0", + "tungstenite", ] [[package]] @@ -3029,22 +3123,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.40", + "syn 2.0.49", ] [[package]] diff --git a/rumqttc/Cargo.toml b/rumqttc/Cargo.toml index 834b1984c..8c5fa31ff 100644 --- a/rumqttc/Cargo.toml +++ b/rumqttc/Cargo.toml @@ -24,7 +24,7 @@ proxy = ["dep:async-http-proxy"] [dependencies] futures-util = { version = "0.3", default_features = false, features = ["std"] } -tokio = { version = "1.33", features = ["rt", "macros", "io-util", "net", "time"] } +tokio = { version = "1.36", features = ["rt", "macros", "io-util", "net", "time"] } bytes = "1.5" log = "0.4" flume = { version = "0.11", default-features = false, features = ["async"] } @@ -33,12 +33,12 @@ thiserror = "1" # Optional # rustls tokio-rustls = { version = "0.25.0", optional = true } -rustls-webpki = { version = "0.102.1", optional = true } -rustls-pemfile = { version = "2.0.0", optional = true } +rustls-webpki = { version = "0.102.2", optional = true } +rustls-pemfile = { version = "2.1.0", optional = true } rustls-native-certs = { version = "0.7.0", optional = true } # websockets -async-tungstenite = { version = "0.24.0", default-features = false, features = ["tokio-rustls-native-certs"], optional = true } -ws_stream_tungstenite = { version= "0.12.0", default-features = false, features = ["tokio_io"], optional = true } +async-tungstenite = { version = "0.25.0", default-features = false, features = ["tokio-rustls-native-certs"], optional = true } +ws_stream_tungstenite = { version= "0.13.0", default-features = false, features = ["tokio_io"], optional = true } http = { version = "1.0.0", optional = true } # native-tls tokio-native-tls = { version = "0.3.1", optional = true } @@ -50,7 +50,7 @@ async-http-proxy = { version = "1.2.5", features = ["runtime-tokio", "basic-auth [dev-dependencies] bincode = "1.3.3" -color-backtrace = "0.6" +color-backtrace = "0.5" matches = "0.1" pretty_assertions = "1" pretty_env_logger = "0.5" diff --git a/rumqttd/Cargo.toml b/rumqttd/Cargo.toml index 62c9f5f51..f1eb419e6 100644 --- a/rumqttd/Cargo.toml +++ b/rumqttd/Cargo.toml @@ -12,30 +12,30 @@ license.workspace = true authors.workspace = true [dependencies] -tokio = { version = "1.33", features = ["rt", "time", "net", "io-util", "macros"]} -serde = { version = "1.0.188", features = ["derive"] } -serde_json = "1.0.107" +tokio = { version = "1.36", features = ["rt", "time", "net", "io-util", "macros"]} +serde = { version = "1.0.196", features = ["derive"] } +serde_json = "1.0.113" bytes = { version = "1", features = ["serde"] } flume = { version = "0.11.0", default-features = false, features = ["async"]} slab = "0.4.9" -thiserror = "1.0.49" +thiserror = "1.0.57" tokio-util = { version = "0.7", features = ["codec"], optional = true } tokio-rustls = { version = "0.25.0", optional = true } -rustls-webpki = { version = "0.102.1", optional = true } +rustls-webpki = { version = "0.102.2", optional = true } tokio-native-tls = { version = "0.3.1", optional = true } -rustls-pemfile = { version = "2.0.0", optional = true } -async-tungstenite = { version = "0.23", default-features = false, features = ["tokio-runtime"], optional = true } -ws_stream_tungstenite = { version= "0.11", default-features = false, features = ["tokio_io"], optional = true } +rustls-pemfile = { version = "2.1.0", optional = true } +async-tungstenite = { version = "0.25", default-features = false, features = ["tokio-runtime"], optional = true } +ws_stream_tungstenite = { version= "0.13", default-features = false, features = ["tokio_io"], optional = true } x509-parser = {version= "0.15.1", optional = true} -futures-util = { version = "0.3.28", optional = true} +futures-util = { version = "0.3.30", optional = true} parking_lot = "0.12.1" -config = "0.13" +config = "0.14" tracing = { version="0.1", features=["log"] } -tracing-subscriber = { version="0.3.17", features=["env-filter"] } -metrics = "0.21.1" -metrics-exporter-prometheus = "0.12.1" +tracing-subscriber = { version="0.3.18", features=["env-filter"] } +metrics = "0.22.1" +metrics-exporter-prometheus = "0.13.1" clap = { version = "4.4", features = ["derive"] } -axum = "0.6.20" +axum = "0.7.4" rand = "0.8.5" [features] @@ -49,5 +49,5 @@ allow-duplicate-clientid = [] [dev-dependencies] pretty_env_logger = "0.5.0" -config = "0.13" +config = "0.14" pretty_assertions = "1.4.0" diff --git a/rumqttd/src/link/console.rs b/rumqttd/src/link/console.rs index 776dd827e..9f03f8a1e 100644 --- a/rumqttd/src/link/console.rs +++ b/rumqttd/src/link/console.rs @@ -8,8 +8,8 @@ use axum::routing::post; use axum::Json; use axum::{routing::get, Router}; use flume::Sender; -use std::net::TcpListener; use std::sync::Arc; +use tokio::net::TcpListener; use tracing::info; #[derive(Debug)] @@ -40,7 +40,9 @@ impl ConsoleLink { #[tracing::instrument] pub async fn start(console: Arc) { - let listener = TcpListener::bind(console.config.listen.clone()).unwrap(); + let listener = TcpListener::bind(console.config.listen.clone()) + .await + .unwrap(); let app = Router::new() .route("/", get(root)) @@ -54,11 +56,7 @@ pub async fn start(console: Arc) { .route("/logs", post(logs)) .with_state(console); - axum::Server::from_tcp(listener) - .unwrap() - .serve(app.into_make_service()) - .await - .unwrap(); + axum::serve(listener, app).await.unwrap(); } async fn root(State(console): State>) -> impl IntoResponse { diff --git a/rumqttd/src/server/broker.rs b/rumqttd/src/server/broker.rs index f5137433f..035491894 100644 --- a/rumqttd/src/server/broker.rs +++ b/rumqttd/src/server/broker.rs @@ -27,7 +27,7 @@ use async_tungstenite::tungstenite::http::HeaderValue; #[cfg(feature = "websocket")] use ws_stream_tungstenite::WsStream; -use metrics::register_gauge; +use metrics::gauge; use metrics_exporter_prometheus::PrometheusBuilder; use std::time::Duration; use std::{io, thread}; @@ -282,9 +282,9 @@ impl Broker { let builder = PrometheusBuilder::new().with_http_listener(addr); builder.install().unwrap(); - let total_publishes = register_gauge!("metrics.router.total_publishes"); - let total_connections = register_gauge!("metrics.router.total_connections"); - let failed_publishes = register_gauge!("metrics.router.failed_publishes"); + let total_publishes = gauge!("metrics.router.total_publishes"); + let total_connections = gauge!("metrics.router.total_connections"); + let failed_publishes = gauge!("metrics.router.failed_publishes"); loop { if let Ok(metrics) = meter_link.recv() { for m in metrics { From f7c77930ce11df0b7cffd61708de4b76b41dcb86 Mon Sep 17 00:00:00 2001 From: Swanand Mulay <73115739+swanandx@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:48:03 +0530 Subject: [PATCH 8/9] feat(rumqttd): async auth function (#798) --- rumqttd/CHANGELOG.md | 1 + rumqttd/examples/external_auth.rs | 15 +++++--- rumqttd/src/lib.rs | 35 ++++++++++++++++- rumqttd/src/link/remote.rs | 64 ++++++++++++++++--------------- 4 files changed, 76 insertions(+), 39 deletions(-) diff --git a/rumqttd/CHANGELOG.md b/rumqttd/CHANGELOG.md index e429b0a72..bb77d2e7d 100644 --- a/rumqttd/CHANGELOG.md +++ b/rumqttd/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Public re-export `Strategy` for shared subscriptions - Peer initiated disconnects logged as info rather than error. +- External authentication function must be async - Update `tokio-rustls` to `0.25.0`, `rustls-webpki` to `0.102.1`, `tokio-native-tls` to `0.3.1` and `rust-pemfile` to `2.0.0`. diff --git a/rumqttd/examples/external_auth.rs b/rumqttd/examples/external_auth.rs index 66edeaf6c..f5d7cdfcd 100644 --- a/rumqttd/examples/external_auth.rs +++ b/rumqttd/examples/external_auth.rs @@ -1,7 +1,5 @@ use rumqttd::{Broker, Config}; -use std::sync::Arc; - fn main() { let builder = tracing_subscriber::fmt() .pretty() @@ -23,18 +21,23 @@ fn main() { // for e.g. if you want it for [v4.1] server, you can do something like let server = config.v4.as_mut().and_then(|v4| v4.get_mut("1")).unwrap(); - // set the external_auth field in ConnectionSettings // external_auth function / closure signature must be: - // Fn(ClientId, AuthUser, AuthPass) -> bool + // async fn(ClientId, AuthUser, AuthPass) -> bool // type for ClientId, AuthUser and AuthPass is String - server.connections.external_auth = Some(Arc::new(auth)); + server.set_auth_handler(auth); + + // or you can pass closure + // server.set_auth_handler(|_client_id, _username, _password| async { + // // perform auth + // true + // }); let mut broker = Broker::new(config); broker.start().unwrap(); } -fn auth(_client_id: String, _username: String, _password: String) -> bool { +async fn auth(_client_id: String, _username: String, _password: String) -> bool { // users can fetch data from DB or tokens and use them! // do the verification and return true if verified, else false true diff --git a/rumqttd/src/lib.rs b/rumqttd/src/lib.rs index ac5d4a872..3763bab57 100644 --- a/rumqttd/src/lib.rs +++ b/rumqttd/src/lib.rs @@ -1,6 +1,8 @@ use std::fmt; +use std::future::IntoFuture; use std::net::SocketAddr; use std::path::PathBuf; +use std::pin::Pin; use std::sync::Arc; use std::{collections::HashMap, path::Path}; @@ -43,7 +45,11 @@ pub type Cursor = (u64, u64); pub type ClientId = String; pub type AuthUser = String; pub type AuthPass = String; -pub type AuthHandler = Arc bool + Send + Sync + 'static>; +pub type AuthHandler = Arc< + dyn Fn(ClientId, AuthUser, AuthPass) -> Pin + Send>> + + Send + + Sync, +>; #[derive(Debug, Default, Serialize, Deserialize, Clone)] pub struct Config { @@ -112,6 +118,17 @@ pub struct ServerSettings { pub connections: ConnectionSettings, } +impl ServerSettings { + pub fn set_auth_handler(&mut self, auth_fn: F) + where + F: Fn(ClientId, AuthUser, AuthPass) -> O + Send + Sync + 'static, + O: IntoFuture + 'static, + O::IntoFuture: Send, + { + self.connections.set_auth_handler(auth_fn) + } +} + #[derive(Debug, Serialize, Deserialize, Clone)] pub struct BridgeConfig { pub name: String, @@ -132,11 +149,25 @@ pub struct ConnectionSettings { pub max_inflight_count: usize, pub auth: Option>, #[serde(skip)] - pub external_auth: Option, + external_auth: Option, #[serde(default)] pub dynamic_filters: bool, } +impl ConnectionSettings { + pub fn set_auth_handler(&mut self, auth_fn: F) + where + F: Fn(ClientId, AuthUser, AuthPass) -> O + Send + Sync + 'static, + O: IntoFuture + 'static, + O::IntoFuture: Send, + { + self.external_auth = Some(Arc::new(move |client_id, username, password| { + let auth = auth_fn(client_id, username, password).into_future(); + Box::pin(auth) + })); + } +} + impl fmt::Debug for ConnectionSettings { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ConnectionSettings") diff --git a/rumqttd/src/link/remote.rs b/rumqttd/src/link/remote.rs index 56c75f5cd..7ecbeeab2 100644 --- a/rumqttd/src/link/remote.rs +++ b/rumqttd/src/link/remote.rs @@ -188,7 +188,7 @@ where Span::current().record("client_id", &connect.client_id); - handle_auth(config.clone(), login.as_ref(), &connect.client_id)?; + handle_auth(config.clone(), login.as_ref(), &connect.client_id).await?; // When keep_alive feature is disabled client can live forever, which is not good in // distributed broker context so currenlty we don't allow it. @@ -213,7 +213,7 @@ where Ok(packet) } -fn handle_auth( +async fn handle_auth( config: Arc, login: Option<&Login>, client_id: &str, @@ -236,7 +236,9 @@ fn handle_auth( client_id.to_owned(), username.to_owned(), password.to_owned(), - ) { + ) + .await + { return Err(Error::InvalidAuth); } @@ -284,23 +286,23 @@ mod tests { } } - #[test] - fn no_login_no_auth() { + #[tokio::test] + async fn no_login_no_auth() { let cfg = Arc::new(config()); - let r = handle_auth(cfg, None, ""); + let r = handle_auth(cfg, None, "").await; assert!(r.is_ok()); } - #[test] - fn some_login_no_auth() { + #[tokio::test] + async fn some_login_no_auth() { let cfg = Arc::new(config()); let login = login(); - let r = handle_auth(cfg, Some(&login), ""); + let r = handle_auth(cfg, Some(&login), "").await; assert!(r.is_ok()); } - #[test] - fn login_matches_static_auth() { + #[tokio::test] + async fn login_matches_static_auth() { let login = login(); let mut map = HashMap::::new(); map.insert(login.username.clone(), login.password.clone()); @@ -308,12 +310,12 @@ mod tests { let mut cfg = config(); cfg.auth = Some(map); - let r = handle_auth(Arc::new(cfg), Some(&login), ""); + let r = handle_auth(Arc::new(cfg), Some(&login), "").await; assert!(r.is_ok()); } - #[test] - fn login_fails_static_no_external() { + #[tokio::test] + async fn login_fails_static_no_external() { let login = login(); let mut map = HashMap::::new(); map.insert("wrong".to_owned(), "wrong".to_owned()); @@ -321,53 +323,53 @@ mod tests { let mut cfg = config(); cfg.auth = Some(map); - let r = handle_auth(Arc::new(cfg), Some(&login), ""); + let r = handle_auth(Arc::new(cfg), Some(&login), "").await; assert!(r.is_err()); } - #[test] - fn login_fails_static_matches_external() { + #[tokio::test] + async fn login_fails_static_matches_external() { let login = login(); let mut map = HashMap::::new(); map.insert("wrong".to_owned(), "wrong".to_owned()); - let dynamic = |_: String, _: String, _: String| -> bool { true }; + let dynamic = |_: String, _: String, _: String| async { true }; let mut cfg = config(); cfg.auth = Some(map); - cfg.external_auth = Some(Arc::new(dynamic)); + cfg.set_auth_handler(dynamic); - let r = handle_auth(Arc::new(cfg), Some(&login), ""); + let r = handle_auth(Arc::new(cfg), Some(&login), "").await; assert!(r.is_ok()); } - #[test] - fn login_fails_static_fails_external() { + #[tokio::test] + async fn login_fails_static_fails_external() { let login = login(); let mut map = HashMap::::new(); map.insert("wrong".to_owned(), "wrong".to_owned()); - let dynamic = |_: String, _: String, _: String| -> bool { false }; + let dynamic = |_: String, _: String, _: String| async { false }; let mut cfg = config(); cfg.auth = Some(map); - cfg.external_auth = Some(Arc::new(dynamic)); + cfg.set_auth_handler(dynamic); - let r = handle_auth(Arc::new(cfg), Some(&login), ""); + let r = handle_auth(Arc::new(cfg), Some(&login), "").await; assert!(r.is_err()); } - #[test] - fn external_auth_clousre_or_fnptr_type_check_or_fail_compile() { - let closure = |_: String, _: String, _: String| -> bool { false }; - fn fnptr(_: String, _: String, _: String) -> bool { + #[tokio::test] + async fn external_auth_clousre_or_fnptr_type_check_or_fail_compile() { + let closure = |_: String, _: String, _: String| async { false }; + async fn fnptr(_: String, _: String, _: String) -> bool { true } let mut cfg = config(); - cfg.external_auth = Some(Arc::new(closure)); - cfg.external_auth = Some(Arc::new(fnptr)); + cfg.set_auth_handler(closure); + cfg.set_auth_handler(fnptr); } } From baa9341061b96935f1f76c7f6c77c1cfd0dfe077 Mon Sep 17 00:00:00 2001 From: Arunanshu Biswas <48434243+arunanshub@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:03:02 +0530 Subject: [PATCH 9/9] ci(actions): implement code coverage (#800) * ci(actions): implement code coverage * ci(actions): use coveralls to upload lcov files * ci(actions): remove duplicate workflow and run job when pushed to main * ci(actions): test docs as an additional step * docs(readme): add coverage badge to readme * ci(actions): rename workflow to `CI` and include it in README --- .github/workflows/{build.yml => ci.yml} | 45 ++++++++++++-- .github/workflows/main.yml | 80 ------------------------- README.md | 9 ++- 3 files changed, 45 insertions(+), 89 deletions(-) rename .github/workflows/{build.yml => ci.yml} (54%) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build.yml b/.github/workflows/ci.yml similarity index 54% rename from .github/workflows/build.yml rename to .github/workflows/ci.yml index 4d7de6a02..13d2b2c98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/ci.yml @@ -7,15 +7,23 @@ on: - '**.rs' - 'Cargo.*' - '*/Cargo.*' + - '.github/workflows/*' + push: + branches: + - main -name: Build and Test +name: CI env: RUSTFLAGS: "-D warnings" +defaults: + run: + shell: bash + jobs: test: - name: Build and test on ${{ matrix.os }} with ${{ matrix.features }} + name: Build and test on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -25,7 +33,7 @@ jobs: - macOS-latest - windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: @@ -35,9 +43,9 @@ jobs: with: shared-key: ${{ runner.os }}-cargo - - uses: taiki-e/install-action@v1 + - uses: taiki-e/install-action@v2 with: - tool: cargo-hack + tool: cargo-hack,cargo-llvm-cov,nextest # - name: Check benchmarks # uses: actions-rs/cargo@v1 @@ -56,5 +64,30 @@ jobs: if: ${{ matrix.os != 'windows-latest' }} run: cargo hack doc --verbose --no-deps --each-feature --no-dev-deps --optional-deps url -p rumqttc -p rumqttd + - name: Doctests + run: cargo hack --each-feature --optional-deps url test --doc -p rumqttc -p rumqttd + - name: Test rumqttc and rumqttd - run: cargo hack test --verbose --each-feature --optional-deps url -p rumqttc -p rumqttd + run: | + cargo hack --each-feature --optional-deps url llvm-cov -p rumqttc -p rumqttd --no-report nextest + + - name: Combine coverage + run: cargo llvm-cov report --lcov --output-path coverage.lcov + + - name: Upload Coverage Report + uses: coverallsapp/github-action@v2.2.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: ./coverage.lcov + parallel: true + flag-name: run-${{ matrix.os }}-cargo + + finish-coverage: + needs: [test] + runs-on: ubuntu-latest + steps: + - name: Finish Coverage Report + uses: coverallsapp/github-action@v2.2.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index fd63b1c22..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,80 +0,0 @@ -on: - push: - branches: - - main - -name: main - -env: - PROJECT_ID: ${{ secrets.GCE_PROJECT }} - GCE_INSTANCE: ${{ secrets.GCE_INSTANCE }} - GCE_INSTANCE_ZONE: ${{ secrets.GCE_INSTANCE_ZONE }} - -jobs: - test: - name: Source test - # runs-on: [self-hosted, linux, X64, rumqtt] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - run: cargo test --all-features - - # deploy: - # name: Source build, docker build and deploy - # runs-on: [self-hosted, linux, X64, rumqtt] - - # steps: - # - uses: actions/checkout@v2 - - # # Install cargo - # - uses: actions-rs/toolchain@v1 - # with: - # toolchain: stable - - # # Build - # - name: Release build rumqtt - # uses: actions-rs/cargo@v1 - # with: - # command: build - # args: --release --all-features - - # # Setup gcloud CLI - # - name: Gcloud commandline setup - # uses: GoogleCloudPlatform/github-actions/setup-gcloud@master - # with: - # version: '290.0.1' - # service_account_key: ${{ secrets.GCE_SA_KEY }} - # project_id: ${{ secrets.GCE_PROJECT }} - - # # Configure Docker to use the gcloud command-line tool as a credential - # helper for authentication - # - name: Docker google cloud registry auth - # run: |- - # gcloud --quiet auth configure-docker - - # # Copy rumqttd and config files - # - name: Prepare config and binary - # run: |- - # cp -r target/release/rumqttd docker/stage/ - # cp -r rumqttd/config docker/stage/ - - # # Build the Docker image - # - name: Docker build - # working-directory: docker - # run: |- - # docker build --tag "asia.gcr.io/$PROJECT_ID/$GCE_INSTANCE-image:$GITHUB_SHA" . - - # # Push the Docker image to Google Container Registry - # - name: Docker image publish - # run: |- - # docker push "asia.gcr.io/$PROJECT_ID/$GCE_INSTANCE-image:$GITHUB_SHA" - - # # Deploy the container - # - name: Deploy to google cloud - # run: |- - # gcloud compute instances update-container "$GCE_INSTANCE" \ - # --zone "$GCE_INSTANCE_ZONE" \ - # --container-image "asia.gcr.io/$PROJECT_ID/$GCE_INSTANCE-image:$GITHUB_SHA" diff --git a/README.md b/README.md index c3a81b773..92cc0c97d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@
- rumqtt Logo + rumqtt Logo