Skip to content

Commit

Permalink
Merge #1027: Release Version 3.0.0-beta
Browse files Browse the repository at this point in the history
39ab661 release: version 3.0.0-beta (Jose Celano)
14e672e tracing: add spans to many functions (Cameron Garnham)
3dc75d5 tracing: init tracing-subscriber in intragration tests (Cameron Garnham)
e4aa1db tracing: qualify use of tracing macros (Cameron Garnham)
2c4bdab chore: update to v1 of derive more (Cameron Garnham)
c5a724e chore: update deps (Cameron Garnham)
dcb7770 chore: update contrib bencode (Cameron Garnham)
bef5680 dev: vairous fixups (Cameron Garnham)
9362fa5 dev: use aquatic PeerId instead of local one (Cameron Garnham)
03e88d0 dev: use aquatic number_of_bytes (Cameron Garnham)
00af70f dev: remove announce event wrapper (Cameron Garnham)
325df70 dev: use aquatic_udp_protocol InfoHash inside our type (Cameron Garnham)
7779fa3 dev: remove announce_request wrapper (Cameron Garnham)
95333f0 chore(deps): update udp cookie consts due the hasher fn udpate (Jose Celano)
33757e0 chore(deps): update dependencies (Jose Celano)
8fcc016 develop: bump to version 3.0.0-beta-develop (Jose Celano)
592c9cc release: version 3.0.0-alpha.12 (Jose Celano)

Pull request description:

  Release Version 3.0.0-beta

ACKs for top commit:
  josecelano:
    ACK 39ab661

Tree-SHA512: c2943313343e2375d5910d65c6f5a076866652a7e320bae8ffb77fb82cb0a6629a817554fe03816536e7019ba29717f3f88ee45e6a25beda32b3de58445e0f77
  • Loading branch information
josecelano committed Sep 3, 2024
2 parents 05b6cc8 + 39ab661 commit e254e76
Show file tree
Hide file tree
Showing 110 changed files with 1,639 additions and 1,145 deletions.
401 changes: 235 additions & 166 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ license = "AGPL-3.0-only"
publish = true
repository = "https://github.com/torrust/torrust-tracker"
rust-version = "1.72"
version = "3.0.0-alpha.12-develop"
version = "3.0.0-beta"

[dependencies]
anyhow = "1"
Expand All @@ -41,7 +41,7 @@ chrono = { version = "0", default-features = false, features = ["clock"] }
clap = { version = "4", features = ["derive", "env"] }
crossbeam-skiplist = "0"
dashmap = "6"
derive_more = "0"
derive_more = { version = "1", features = ["as_ref", "constructor", "from"] }
figment = "0"
futures = "0"
futures-util = "0"
Expand All @@ -66,15 +66,15 @@ serde_bencode = "0"
serde_bytes = "0"
serde_json = { version = "1", features = ["preserve_order"] }
serde_repr = "0"
serde_with = { version = "3.9.0", features = ["json"] }
serde_with = { version = "3", features = ["json"] }
thiserror = "1"
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
torrust-tracker-clock = { version = "3.0.0-alpha.12-develop", path = "packages/clock" }
torrust-tracker-configuration = { version = "3.0.0-alpha.12-develop", path = "packages/configuration" }
torrust-tracker-contrib-bencode = { version = "3.0.0-alpha.12-develop", path = "contrib/bencode" }
torrust-tracker-located-error = { version = "3.0.0-alpha.12-develop", path = "packages/located-error" }
torrust-tracker-primitives = { version = "3.0.0-alpha.12-develop", path = "packages/primitives" }
torrust-tracker-torrent-repository = { version = "3.0.0-alpha.12-develop", path = "packages/torrent-repository" }
torrust-tracker-clock = { version = "3.0.0-beta", path = "packages/clock" }
torrust-tracker-configuration = { version = "3.0.0-beta", path = "packages/configuration" }
torrust-tracker-contrib-bencode = { version = "3.0.0-beta", path = "contrib/bencode" }
torrust-tracker-located-error = { version = "3.0.0-beta", path = "packages/located-error" }
torrust-tracker-primitives = { version = "3.0.0-beta", path = "packages/primitives" }
torrust-tracker-torrent-repository = { version = "3.0.0-beta", path = "packages/torrent-repository" }
tower = { version = "0", features = ["timeout"] }
tower-http = { version = "0", features = ["compression-full", "cors", "propagate-header", "request-id", "trace"] }
trace = "0"
Expand All @@ -90,7 +90,7 @@ ignored = ["crossbeam-skiplist", "dashmap", "figment", "parking_lot", "serde_byt
[dev-dependencies]
local-ip-address = "0"
mockall = "0"
torrust-tracker-test-helpers = { version = "3.0.0-alpha.12-develop", path = "packages/test-helpers" }
torrust-tracker-test-helpers = { version = "3.0.0-beta", path = "packages/test-helpers" }

[workspace]
members = [
Expand Down
6 changes: 1 addition & 5 deletions contrib/bencode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
error-chain = "0"
thiserror = "1"

[dev-dependencies]
criterion = "0"

[[test]]
name = "test"
path = "test/mod.rs"

[[bench]]
harness = false
name = "bencode_benchmark"
78 changes: 30 additions & 48 deletions contrib/bencode/src/access/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::access::bencode::{BRefAccess, BRefAccessExt};
use crate::access::dict::BDictAccess;
use crate::access::list::BListAccess;
use crate::{BencodeConvertError, BencodeConvertErrorKind};
use crate::BencodeConvertError;

/// Trait for extended casting of bencode objects and converting conversion errors into application specific errors.
pub trait BConvertExt: BConvert {
Expand All @@ -12,12 +12,10 @@ pub trait BConvertExt: BConvert {
B: BRefAccessExt<'a>,
E: AsRef<[u8]>,
{
bencode.bytes_ext().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Bytes".to_owned(),
})),
)
bencode.bytes_ext().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Bytes".to_owned(),
}))
}

/// See `BConvert::convert_str`.
Expand All @@ -26,12 +24,10 @@ pub trait BConvertExt: BConvert {
B: BRefAccessExt<'a>,
E: AsRef<[u8]>,
{
bencode.str_ext().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "UTF-8 Bytes".to_owned(),
})),
)
bencode.str_ext().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "UTF-8 Bytes".to_owned(),
}))
}

/// See `BConvert::lookup_and_convert_bytes`.
Expand Down Expand Up @@ -77,12 +73,10 @@ pub trait BConvert {
B: BRefAccess,
E: AsRef<[u8]>,
{
bencode.int().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Integer".to_owned(),
})),
)
bencode.int().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Integer".to_owned(),
}))
}

/// Attempt to convert the given bencode value into bytes.
Expand All @@ -93,12 +87,10 @@ pub trait BConvert {
B: BRefAccess,
E: AsRef<[u8]>,
{
bencode.bytes().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Bytes".to_owned(),
})),
)
bencode.bytes().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Bytes".to_owned(),
}))
}

/// Attempt to convert the given bencode value into a UTF-8 string.
Expand All @@ -109,12 +101,10 @@ pub trait BConvert {
B: BRefAccess,
E: AsRef<[u8]>,
{
bencode.str().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "UTF-8 Bytes".to_owned(),
})),
)
bencode.str().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "UTF-8 Bytes".to_owned(),
}))
}

/// Attempt to convert the given bencode value into a list.
Expand All @@ -125,12 +115,10 @@ pub trait BConvert {
B: BRefAccess,
E: AsRef<[u8]>,
{
bencode.list().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "List".to_owned(),
})),
)
bencode.list().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "List".to_owned(),
}))
}

/// Attempt to convert the given bencode value into a dictionary.
Expand All @@ -141,12 +129,10 @@ pub trait BConvert {
B: BRefAccess,
E: AsRef<[u8]>,
{
bencode.dict().ok_or(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Dictionary".to_owned(),
})),
)
bencode.dict().ok_or(self.handle_error(BencodeConvertError::WrongType {
key: error_key.as_ref().to_owned(),
expected_type: "Dictionary".to_owned(),
}))
}

/// Look up a value in a dictionary of bencoded values using the given key.
Expand All @@ -159,11 +145,7 @@ pub trait BConvert {

match dictionary.lookup(key_ref) {
Some(n) => Ok(n),
None => Err(
self.handle_error(BencodeConvertError::from_kind(BencodeConvertErrorKind::MissingKey {
key: key_ref.to_owned(),
})),
),
None => Err(self.handle_error(BencodeConvertError::MissingKey { key: key_ref.to_owned() })),
}
}

Expand Down
6 changes: 2 additions & 4 deletions contrib/bencode/src/access/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub trait BDictAccess<K, V> {

impl<'a, V> BDictAccess<&'a [u8], V> for BTreeMap<&'a [u8], V> {
fn to_list(&self) -> Vec<(&&'a [u8], &V)> {
#[allow(clippy::map_identity)]
self.iter().map(|(k, v)| (k, v)).collect()
self.iter().collect()
}

fn lookup(&self, key: &[u8]) -> Option<&V> {
Expand All @@ -44,8 +43,7 @@ impl<'a, V> BDictAccess<&'a [u8], V> for BTreeMap<&'a [u8], V> {

impl<'a, V> BDictAccess<Cow<'a, [u8]>, V> for BTreeMap<Cow<'a, [u8]>, V> {
fn to_list(&self) -> Vec<(&Cow<'a, [u8]>, &V)> {
#[allow(clippy::map_identity)]
self.iter().map(|(k, v)| (k, v)).collect()
self.iter().collect()
}

fn lookup(&self, key: &[u8]) -> Option<&V> {
Expand Down
8 changes: 0 additions & 8 deletions contrib/bencode/src/access/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ impl<'a, V: 'a> IndexMut<usize> for &'a mut dyn BListAccess<V> {
}
}

impl<'a, V: 'a> dyn BListAccess<V> {
pub fn iter(&'a self) -> impl Iterator<Item = &'a V> {
self.into_iter()
}
}

#[allow(unknown_lints)]
#[allow(clippy::into_iter_without_iter)]
impl<'a, V: 'a> IntoIterator for &'a dyn BListAccess<V> {
type Item = &'a V;
type IntoIter = BListIter<'a, V>;
Expand Down
143 changes: 46 additions & 97 deletions contrib/bencode/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,103 +1,52 @@
#![allow(unknown_lints)]
#![allow(clippy::iter_without_into_iter)]
use error_chain::error_chain;
use thiserror::Error;

error_chain! {
types {
BencodeParseError, BencodeParseErrorKind, BencodeParseResultExt, BencodeParseResult;
}
#[allow(clippy::module_name_repetitions)]
#[derive(Error, Debug)]
pub enum BencodeParseError {
#[error("Incomplete Number Of Bytes At {pos}")]
BytesEmpty { pos: usize },

errors {
BytesEmpty {
pos: usize
} {
description("Incomplete Number Of Bytes")
display("Incomplete Number Of Bytes At {:?}", pos)
}
InvalidByte {
pos: usize
} {
description("Invalid Byte Found")
display("Invalid Byte Found At {:?}", pos)
}
InvalidIntNoDelimiter {
pos: usize
} {
description("Invalid Integer Found With No Delimiter")
display("Invalid Integer Found With No Delimiter At {:?}", pos)
}
InvalidIntNegativeZero {
pos: usize
} {
description("Invalid Integer Found As Negative Zero")
display("Invalid Integer Found As Negative Zero At {:?}", pos)
}
InvalidIntZeroPadding {
pos: usize
} {
description("Invalid Integer Found With Zero Padding")
display("Invalid Integer Found With Zero Padding At {:?}", pos)
}
InvalidIntParseError {
pos: usize
} {
description("Invalid Integer Found To Fail Parsing")
display("Invalid Integer Found To Fail Parsing At {:?}", pos)
}
InvalidKeyOrdering {
pos: usize,
key: Vec<u8>
} {
description("Invalid Dictionary Key Ordering Found")
display("Invalid Dictionary Key Ordering Found At {:?} For Key {:?}", pos, key)
}
InvalidKeyDuplicates {
pos: usize,
key: Vec<u8>
} {
description("Invalid Dictionary Duplicate Keys Found")
display("Invalid Dictionary Key Found At {:?} For Key {:?}", pos, key)
}
InvalidLengthNegative {
pos: usize
} {
description("Invalid Byte Length Found As Negative")
display("Invalid Byte Length Found As Negative At {:?}", pos)
}
InvalidLengthOverflow {
pos: usize
} {
description("Invalid Byte Length Found To Overflow Buffer Length")
display("Invalid Byte Length Found To Overflow Buffer Length At {:?}", pos)
}
InvalidRecursionExceeded {
pos: usize,
max: usize
} {
description("Invalid Recursion Limit Exceeded")
display("Invalid Recursion Limit Exceeded At {:?} For Limit {:?}", pos, max)
}
}
#[error("Invalid Byte Found At {pos}")]
InvalidByte { pos: usize },

#[error("Invalid Integer Found With No Delimiter At {pos}")]
InvalidIntNoDelimiter { pos: usize },

#[error("Invalid Integer Found As Negative Zero At {pos}")]
InvalidIntNegativeZero { pos: usize },

#[error("Invalid Integer Found With Zero Padding At {pos}")]
InvalidIntZeroPadding { pos: usize },

#[error("Invalid Integer Found To Fail Parsing At {pos}")]
InvalidIntParseError { pos: usize },

#[error("Invalid Dictionary Key Ordering Found At {pos} For Key {key:?}")]
InvalidKeyOrdering { pos: usize, key: Vec<u8> },

#[error("Invalid Dictionary Key Found At {pos} For Key {key:?}")]
InvalidKeyDuplicates { pos: usize, key: Vec<u8> },

#[error("Invalid Byte Length Found As Negative At {pos}")]
InvalidLengthNegative { pos: usize },

#[error("Invalid Byte Length Found To Overflow Buffer Length At {pos}")]
InvalidLengthOverflow { pos: usize },

#[error("Invalid Recursion Limit Exceeded At {pos} For Limit {max}")]
InvalidRecursionExceeded { pos: usize, max: usize },
}

error_chain! {
types {
BencodeConvertError, BencodeConvertErrorKind, BencodeConvertResultExt, BencodeConvertResult;
}
pub type BencodeParseResult<T> = Result<T, BencodeParseError>;

errors {
MissingKey {
key: Vec<u8>
} {
description("Missing Key In Bencode")
display("Missing Key In Bencode For {:?}", key)
}
WrongType {
key: Vec<u8>,
expected_type: String
} {
description("Wrong Type In Bencode")
display("Wrong Type In Bencode For {:?} Expected Type {}", key, expected_type)
}
}
#[allow(clippy::module_name_repetitions)]
#[derive(Error, Debug)]
pub enum BencodeConvertError {
#[error("Missing Key In Bencode For {key:?}")]
MissingKey { key: Vec<u8> },

#[error("Wrong Type In Bencode For {key:?} Expected Type {expected_type}")]
WrongType { key: Vec<u8>, expected_type: String },
}

pub type BencodeConvertResult<T> = Result<T, BencodeConvertError>;
Loading

0 comments on commit e254e76

Please sign in to comment.