Chore: Bump rand->0.9, tokio-tungstenite->0.26
This commit is contained in:
@@ -423,7 +423,7 @@ impl CryptoState {
|
||||
|
||||
match self {
|
||||
Self::Suffix => {
|
||||
rand::thread_rng().fill(&mut packet.payload_mut()[startpoint..endpoint]);
|
||||
rand::rng().fill(&mut packet.payload_mut()[startpoint..endpoint]);
|
||||
},
|
||||
Self::Lite(ref mut i)
|
||||
| Self::Aes256Gcm(ref mut i)
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::{
|
||||
ConnectionInfo,
|
||||
};
|
||||
use flume::Receiver;
|
||||
use rand::{distributions::Uniform, Rng};
|
||||
use rand::{distr::Uniform, Rng};
|
||||
#[cfg(feature = "receive")]
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -181,8 +181,9 @@ impl AuxNetwork {
|
||||
// Discord have suddenly, mysteriously, started rejecting
|
||||
// ints-as-strings. Keep JS happy here, I suppose...
|
||||
const JS_MAX_INT: u64 = (1u64 << 53) - 1;
|
||||
let nonce_range = Uniform::from(0..JS_MAX_INT);
|
||||
let nonce = rand::thread_rng().sample(nonce_range);
|
||||
let nonce_range =
|
||||
Uniform::new(0, JS_MAX_INT).expect("uniform range is finite and nonempty");
|
||||
let nonce = rand::rng().sample(nonce_range);
|
||||
self.last_heartbeat_nonce = Some(nonce);
|
||||
|
||||
trace!("Sent heartbeat {:?}", self.speaking);
|
||||
|
||||
@@ -140,7 +140,7 @@ impl<'a> YoutubeDl<'a> {
|
||||
"--no-playlist",
|
||||
];
|
||||
|
||||
let mut output = Command::new(self.program)
|
||||
let output = Command::new(self.program)
|
||||
.args(self.user_args.clone())
|
||||
.args(ytdl_args)
|
||||
.output()
|
||||
|
||||
26
src/ws.rs
26
src/ws.rs
@@ -1,5 +1,6 @@
|
||||
use crate::{error::JsonError, model::Event};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::{SinkExt, StreamExt, TryStreamExt};
|
||||
use tokio::{
|
||||
net::TcpStream,
|
||||
@@ -27,12 +28,6 @@ use tokio_websockets::{
|
||||
use tracing::{debug, instrument};
|
||||
use url::Url;
|
||||
|
||||
#[cfg(any(
|
||||
all(feature = "tws", feature = "tungstenite"),
|
||||
all(not(feature = "tws"), not(feature = "tungstenite"))
|
||||
))]
|
||||
compile_error!("specify one of `features = [\"tungstenite\"]` (recommended w/ serenity) or `features = [\"tws\"]` (recommended w/ twilight)");
|
||||
|
||||
pub struct WsStream(WebSocketStream<MaybeTlsStream<TcpStream>>);
|
||||
|
||||
impl WsStream {
|
||||
@@ -41,11 +36,11 @@ impl WsStream {
|
||||
#[cfg(feature = "tungstenite")]
|
||||
let (stream, _) = tokio_tungstenite::connect_async_with_config::<Url>(
|
||||
url,
|
||||
Some(Config {
|
||||
max_message_size: None,
|
||||
max_frame_size: None,
|
||||
..Default::default()
|
||||
}),
|
||||
Some(
|
||||
Config::default()
|
||||
.max_message_size(None)
|
||||
.max_frame_size(None),
|
||||
),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
@@ -78,9 +73,6 @@ impl WsStream {
|
||||
|
||||
pub(crate) async fn send_json(&mut self, value: &Event) -> Result<()> {
|
||||
let res = crate::json::to_string(value);
|
||||
#[cfg(feature = "tungstenite")]
|
||||
let res = res.map(Message::Text);
|
||||
#[cfg(feature = "tws")]
|
||||
let res = res.map(Message::text);
|
||||
Ok(res.map_err(Error::from).map(|m| self.0.send(m))?.await?)
|
||||
}
|
||||
@@ -94,7 +86,7 @@ pub enum Error {
|
||||
|
||||
/// The discord voice gateway does not support or offer zlib compression.
|
||||
/// As a result, only text messages are expected.
|
||||
UnexpectedBinaryMessage(Vec<u8>),
|
||||
UnexpectedBinaryMessage(Bytes),
|
||||
|
||||
#[cfg(feature = "tungstenite")]
|
||||
Ws(TungsteniteError),
|
||||
@@ -102,7 +94,7 @@ pub enum Error {
|
||||
Ws(TwsError),
|
||||
|
||||
#[cfg(feature = "tungstenite")]
|
||||
WsClosed(Option<CloseFrame<'static>>),
|
||||
WsClosed(Option<CloseFrame>),
|
||||
#[cfg(feature = "tws")]
|
||||
WsClosed(Option<CloseCode>),
|
||||
}
|
||||
@@ -151,7 +143,7 @@ pub(crate) fn convert_ws_message(message: Option<Message>) -> Result<Option<Even
|
||||
},
|
||||
Some(message) if message.is_binary() => {
|
||||
return Err(Error::UnexpectedBinaryMessage(
|
||||
message.into_payload().to_vec(),
|
||||
message.into_payload().into(),
|
||||
));
|
||||
},
|
||||
Some(message) if message.is_close() => {
|
||||
|
||||
Reference in New Issue
Block a user