Prepare for releasing 8.1.0

This commit is contained in:
Igor Katson 2025-06-05 11:38:50 +01:00
parent 3fa55bdc14
commit 28332fd4b9
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
21 changed files with 1387 additions and 978 deletions

View file

@ -47,11 +47,7 @@ impl Blocklist {
anyhow::bail!("Failed to fetch blocklist: HTTP {}", response.status());
}
let reader = StreamReader::new(
response
.bytes_stream()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)),
);
let reader = StreamReader::new(response.bytes_stream().map_err(std::io::Error::other));
Self::create_from_stream(reader).await
}

View file

@ -13,6 +13,7 @@ use crate::{
use librqbit_core::hash_id::Id20;
#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
pub enum ReadMetainfoResult<Rx> {
Found {
info: TorrentMetaV1Info<ByteBufOwned>,

View file

@ -358,17 +358,17 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
use crate::tests::test_util::TestPeerMetadata;
let tpm = TestPeerMetadata::from_peer_id(self.peer_id);
use rand::Rng;
if rand::thread_rng().gen_bool(tpm.disconnect_probability()) {
if rand::rng().random_bool(tpm.disconnect_probability()) {
bail!("disconnecting, to simulate failure in tests");
}
#[allow(clippy::cast_possible_truncation)]
let sleep_ms = (rand::thread_rng().gen::<f64>()
let sleep_ms = (rand::rng().random::<f64>()
* (tpm.max_random_sleep_ms as f64))
as u64;
tokio::time::sleep(Duration::from_millis(sleep_ms)).await;
if rand::thread_rng().gen_bool(tpm.bad_data_probability()) {
if rand::rng().random_bool(tpm.bad_data_probability()) {
warn!("will NOT actually read the data to simulate a malicious peer that sends garbage");
write_buf.fill(0);
skip_reading_for_e2e_tests = true;

View file

@ -998,11 +998,8 @@ impl Session {
return Ok(None);
}
fn check_valid(pb: &PathBuf) -> anyhow::Result<()> {
if pb.components().into_iter().any(|x| match x {
Component::Normal(_) => false,
_ => true,
}) {
fn check_valid(pb: &Path) -> anyhow::Result<()> {
if pb.components().any(|x| !matches!(x, Component::Normal(_))) {
bail!("path traversal in torrent name detected")
}
Ok(())

View file

@ -87,7 +87,7 @@ async fn _test_e2e_download(drop_checks: &DropChecks) {
async move {
let peer_id = TestPeerMetadata {
server_id: i,
max_random_sleep_ms: rand::thread_rng().gen_range(0u8..16),
max_random_sleep_ms: rand::rng().random_range(0u8..16),
}
.as_peer_id();
let listen_range_start = 15100u16 + i as u16;

View file

@ -8,7 +8,7 @@ use std::{
use anyhow::bail;
use librqbit_core::Id20;
use parking_lot::RwLock;
use rand::{thread_rng, Rng, RngCore, SeedableRng};
use rand::{rng, Rng, RngCore, SeedableRng};
use tempfile::TempDir;
use tracing::{info, trace};
@ -29,7 +29,7 @@ pub fn create_new_file_with_random_content(path: &Path, mut size: usize) {
trace!(?path, "creating temp file");
const BUF_SIZE: usize = 8192 * 16;
let mut rng = rand::rngs::SmallRng::from_entropy();
let mut rng = rand::rngs::SmallRng::from_os_rng();
let mut write_buf = [0; BUF_SIZE];
while size > 0 {
rng.fill_bytes(&mut write_buf[..]);
@ -67,7 +67,7 @@ impl TestPeerMetadata {
pub fn as_peer_id(&self) -> Id20 {
let mut peer_id = Id20::default();
thread_rng().fill(&mut peer_id.0);
rng().fill(&mut peer_id.0);
peer_id.0[0] = self.server_id;
peer_id.0[1] = self.max_random_sleep_ms;
peer_id

View file

@ -127,10 +127,10 @@ impl TorrentStateInitializing {
// For all the remaining pieces we claim we have, validate them with decreasing probability.
let mut queue = queue.iter_ones().collect_vec();
queue.shuffle(&mut rand::thread_rng());
queue.shuffle(&mut rand::rng());
for (tmp_id, piece_id) in queue.into_iter().enumerate() {
let denom: u32 = (tmp_id + 1).min(50).try_into().unwrap();
if rand::thread_rng().gen_ratio(1, denom) {
if rand::rng().random_ratio(1, denom) {
to_validate.set(piece_id, true);
}
}

View file

@ -94,7 +94,7 @@ impl TorrentStreams {
// Shuffle to decrease determinism and make queueing fairer.
use rand::seq::SliceRandom;
all.shuffle(&mut rand::thread_rng());
all.shuffle(&mut rand::rng());
Interleave { all: all.into() }
}