mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
commit
a32d54240c
27 changed files with 462 additions and 417 deletions
647
Cargo.lock
generated
647
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -35,6 +35,9 @@ aquatic_ws_protocol = { path = "aquatic_ws_protocol" }
|
|||
debug = true
|
||||
lto = true
|
||||
|
||||
[profile.test]
|
||||
opt-level = 3
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
opt-level = 3
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -5,12 +5,12 @@ Blazingly fast, multi-threaded BitTorrent tracker written in Rust.
|
|||
Consists of three sub-implementations for different protocols:
|
||||
* `aquatic_udp`: BitTorrent over UDP. Implementation achieves double the throughput
|
||||
of opentracker (see benchmarks below)
|
||||
* `aquatic_http`: BitTorrent over HTTP/TLS (experimental)
|
||||
* `aquatic_http`: BitTorrent over HTTP/TLS (slightly experimental)
|
||||
* `aquatic_ws`: WebTorrent (experimental)
|
||||
|
||||
## Copyright and license
|
||||
|
||||
Copyright (c) 2020 Joakim Frostegård
|
||||
Copyright (c) 2020-2021 Joakim Frostegård
|
||||
|
||||
Distributed under Apache 2.0 license (details in `LICENSE` file.)
|
||||
|
||||
|
|
@ -146,12 +146,14 @@ exceptions:
|
|||
* Doesn't track of the number of torrent downloads (0 is always sent).
|
||||
* Doesn't allow full scrapes, i.e. of all registered info hashes
|
||||
|
||||
`aquatic_ws` is not as well tested as `aquatic_udp`, but has been
|
||||
successfully used as the tracker for a file transfer between two webtorrent
|
||||
peers.
|
||||
For information about running over TLS, please refer to the TLS subsection
|
||||
of the `aquatic_http` section above.
|
||||
|
||||
For information about running over TLS (wss protocol), please refer to
|
||||
the corresponding `aquatic_http` section above.
|
||||
`aquatic_ws` is experimental software. Connections are established
|
||||
successfully when using `aquatic_ws_load_test`, but so far, I haven't been able
|
||||
to implement CI for testing if aquatic_ws works as the tracker for a full
|
||||
file transfer session between two real-world clients. One reason for this
|
||||
is the general lack of high-quality WebTorrent clients.
|
||||
|
||||
## Load testing
|
||||
|
||||
|
|
|
|||
6
TODO.md
6
TODO.md
|
|
@ -40,6 +40,12 @@
|
|||
scrape requests I suppose.
|
||||
|
||||
## aquatic_ws
|
||||
* panic when unwrapping peer_address after peer closes connection:
|
||||
|
||||
```
|
||||
thread 'socket-01' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }', aquatic_ws/src/lib/network/connection.rs:28:59
|
||||
```
|
||||
|
||||
* websocket_max_frame_size should be at least something like 64 * 1024,
|
||||
maybe put it and message size at 128k just to be sure
|
||||
* test transfer, specifically ipv6/ipv4 mapping
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ repository = "https://github.com/greatest-ape/aquatic"
|
|||
[dependencies]
|
||||
anyhow = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
simplelog = "0.8"
|
||||
toml = "0.5"
|
||||
simplelog = "0.9"
|
||||
toml = "0.5"
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ name = "aquatic_common"
|
|||
|
||||
[dependencies]
|
||||
indexmap = "1"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
|
|
@ -57,12 +57,10 @@ pub fn extract_response_peers<K, V, R, F>(
|
|||
let half_peer_map_len = peer_map_len / 2;
|
||||
|
||||
let offset_first_half = rng.gen_range(
|
||||
0,
|
||||
(half_peer_map_len + (peer_map_len % 2)) - half_num_to_take
|
||||
0..(half_peer_map_len + (peer_map_len % 2)) - half_num_to_take
|
||||
);
|
||||
let offset_second_half = rng.gen_range(
|
||||
half_peer_map_len,
|
||||
peer_map_len - half_num_to_take
|
||||
half_peer_map_len..peer_map_len - half_num_to_take
|
||||
);
|
||||
|
||||
let end_first_half = offset_first_half + half_num_to_take;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ anyhow = "1"
|
|||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_common = "0.1.0"
|
||||
aquatic_http_protocol = "0.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
either = "1"
|
||||
hashbrown = "0.9"
|
||||
histogram = "0.6"
|
||||
|
|
@ -32,12 +32,12 @@ memchr = "2"
|
|||
mio = { version = "0.7", features = ["tcp", "os-poll", "os-util"] }
|
||||
native-tls = "0.2"
|
||||
parking_lot = "0.11"
|
||||
privdrop = "0.3"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
privdrop = "0.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
smartstring = "0.2"
|
||||
socket2 = { version = "0.3", features = ["reuseport"] }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ aquatic_http_protocol = "0.1.0"
|
|||
hashbrown = "0.9"
|
||||
mimalloc = { version = "0.1", default-features = false }
|
||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand_distr = "0.3"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand_distr = "0.4"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ httparse = "1"
|
|||
itoa = "0.4"
|
||||
log = "0.4"
|
||||
memchr = "2"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_bencode = "0.2"
|
||||
smartstring = "0.2"
|
||||
|
|
@ -43,5 +43,5 @@ urlencoding = "1"
|
|||
[dev-dependencies]
|
||||
bendy = { version = "0.3", features = ["std", "serde"] }
|
||||
criterion = "0.3"
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
@ -60,7 +60,7 @@ impl FromStr for AnnounceEvent {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for InfoHash {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let mut arr = [b'0'; 20];
|
||||
|
||||
for byte in arr.iter_mut(){
|
||||
|
|
@ -74,7 +74,7 @@ impl quickcheck::Arbitrary for InfoHash {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for PeerId {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let mut arr = [b'0'; 20];
|
||||
|
||||
for byte in arr.iter_mut(){
|
||||
|
|
@ -88,7 +88,7 @@ impl quickcheck::Arbitrary for PeerId {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for AnnounceEvent {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
match (bool::arbitrary(g), bool::arbitrary(g)){
|
||||
(false, false) => Self::Started,
|
||||
(true, false) => Self::Started,
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for AnnounceRequest {
|
||||
fn arbitrary<G: Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
let key: Option<String> = Arbitrary::arbitrary(g);
|
||||
|
||||
AnnounceRequest {
|
||||
|
|
@ -339,7 +339,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for ScrapeRequest {
|
||||
fn arbitrary<G: Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
ScrapeRequest {
|
||||
info_hashes: Arbitrary::arbitrary(g),
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for Request {
|
||||
fn arbitrary<G: Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut Gen) -> Self {
|
||||
if Arbitrary::arbitrary(g){
|
||||
Self::Announce(Arbitrary::arbitrary(g))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ impl Response {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ResponsePeer<Ipv4Addr> {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
ip_address: Ipv4Addr::arbitrary(g),
|
||||
port: u16::arbitrary(g)
|
||||
|
|
@ -203,7 +203,7 @@ impl quickcheck::Arbitrary for ResponsePeer<Ipv4Addr> {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ResponsePeer<Ipv6Addr> {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
ip_address: Ipv6Addr::arbitrary(g),
|
||||
port: u16::arbitrary(g)
|
||||
|
|
@ -214,7 +214,7 @@ impl quickcheck::Arbitrary for ResponsePeer<Ipv6Addr> {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ResponsePeerListV4 {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self(Vec::arbitrary(g))
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ impl quickcheck::Arbitrary for ResponsePeerListV4 {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ResponsePeerListV6 {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self(Vec::arbitrary(g))
|
||||
}
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ impl quickcheck::Arbitrary for ResponsePeerListV6 {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ScrapeStatistics {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
complete: usize::arbitrary(g),
|
||||
incomplete: usize::arbitrary(g),
|
||||
|
|
@ -242,7 +242,7 @@ impl quickcheck::Arbitrary for ScrapeStatistics {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for AnnounceResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
announce_interval: usize::arbitrary(g),
|
||||
complete: usize::arbitrary(g),
|
||||
|
|
@ -256,7 +256,7 @@ impl quickcheck::Arbitrary for AnnounceResponse {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ScrapeResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
files: BTreeMap::arbitrary(g),
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ impl quickcheck::Arbitrary for ScrapeResponse {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for FailureResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
failure_reason: String::arbitrary(g),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ anyhow = "1"
|
|||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_common = "0.1.0"
|
||||
aquatic_udp_protocol = "0.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
hashbrown = "0.9"
|
||||
histogram = "0.6"
|
||||
indexmap = "1"
|
||||
|
|
@ -27,11 +27,11 @@ log = "0.4"
|
|||
mimalloc = { version = "0.1", default-features = false }
|
||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||
parking_lot = "0.11"
|
||||
privdrop = "0.3"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
privdrop = "0.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
socket2 = { version = "0.3", features = ["reuseport"] }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -414,17 +414,19 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_extract_response_peers(){
|
||||
fn prop(data: (u32, u16)) -> TestResult {
|
||||
let gen_num_peers = data.0;
|
||||
fn prop(data: (u16, u16)) -> TestResult {
|
||||
let gen_num_peers = data.0 as u32;
|
||||
let req_num_peers = data.1 as usize;
|
||||
|
||||
let mut peer_map: PeerMap<Ipv4Addr> = IndexMap::new();
|
||||
let mut peer_map: PeerMap<Ipv4Addr> = IndexMap::with_capacity(
|
||||
gen_num_peers as usize
|
||||
);
|
||||
|
||||
let mut opt_sender_key = None;
|
||||
let mut opt_sender_peer = None;
|
||||
|
||||
for i in 0..gen_num_peers {
|
||||
let (key, value) = gen_peer_map_key_and_value(i);
|
||||
let (key, value) = gen_peer_map_key_and_value((i << 16) + i);
|
||||
|
||||
if i == 0 {
|
||||
opt_sender_key = Some(key);
|
||||
|
|
@ -456,7 +458,7 @@ mod tests {
|
|||
// Check that returned peers are unique (no overlap) and that sender
|
||||
// isn't returned
|
||||
|
||||
let mut ip_addresses = HashSet::new();
|
||||
let mut ip_addresses = HashSet::with_capacity(peers.len());
|
||||
|
||||
for peer in peers {
|
||||
if peer == opt_sender_peer.clone().unwrap() || ip_addresses.contains(&peer.ip_address){
|
||||
|
|
@ -471,6 +473,6 @@ mod tests {
|
|||
TestResult::from_bool(success)
|
||||
}
|
||||
|
||||
quickcheck(prop as fn((u32, u16)) -> TestResult);
|
||||
quickcheck(prop as fn((u16, u16)) -> TestResult);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,10 +13,10 @@ name = "aquatic_udp_bench"
|
|||
anyhow = "1"
|
||||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_udp = "0.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
indicatif = "0.15"
|
||||
mimalloc = { version = "0.1", default-features = false }
|
||||
num-format = "0.4"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand_distr = "0.3"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand_distr = "0.4"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ name = "aquatic_udp_load_test"
|
|||
anyhow = "1"
|
||||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_udp_protocol = "0.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
hashbrown = "0.9"
|
||||
mimalloc = { version = "0.1", default-features = false }
|
||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||
parking_lot = "0.11"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand_distr = "0.3"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand_distr = "0.4"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
socket2 = { version = "0.3", features = ["reuseport"] }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use rand_distr::{Standard, Pareto};
|
||||
use rand_distr::Pareto;
|
||||
use rand::prelude::*;
|
||||
|
||||
use aquatic_udp_protocol::*;
|
||||
|
|
@ -15,7 +15,9 @@ pub fn create_torrent_peer(
|
|||
info_hashes: &Arc<Vec<InfoHash>>,
|
||||
connection_id: ConnectionId
|
||||
) -> TorrentPeer {
|
||||
let num_scape_hashes = rng.gen_range(1, config.handler.scrape_max_torrents);
|
||||
let num_scape_hashes = rng.gen_range(
|
||||
1..config.handler.scrape_max_torrents
|
||||
);
|
||||
|
||||
let mut scrape_hash_indeces = Vec::new();
|
||||
|
||||
|
|
@ -82,13 +84,7 @@ pub fn create_connect_request(transaction_id: TransactionId) -> Request {
|
|||
fn random_20_bytes() -> [u8; 20] {
|
||||
let mut bytes = [0; 20];
|
||||
|
||||
for (i, b) in rand::thread_rng()
|
||||
.sample_iter(&Standard)
|
||||
.enumerate()
|
||||
.take(20) {
|
||||
|
||||
bytes[i] = b
|
||||
}
|
||||
thread_rng().fill_bytes(&mut bytes[..]);
|
||||
|
||||
bytes
|
||||
}
|
||||
|
|
@ -11,5 +11,5 @@ repository = "https://github.com/greatest-ape/aquatic"
|
|||
byteorder = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
@ -52,7 +52,7 @@ pub struct ResponsePeer {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for IpVersion {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
if bool::arbitrary(g) {
|
||||
IpVersion::IPv4
|
||||
} else {
|
||||
|
|
@ -64,7 +64,7 @@ impl quickcheck::Arbitrary for IpVersion {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for InfoHash {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let mut bytes = [0u8; 20];
|
||||
|
||||
for byte in bytes.iter_mut() {
|
||||
|
|
@ -78,7 +78,7 @@ impl quickcheck::Arbitrary for InfoHash {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for PeerId {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let mut bytes = [0u8; 20];
|
||||
|
||||
for byte in bytes.iter_mut() {
|
||||
|
|
@ -92,7 +92,7 @@ impl quickcheck::Arbitrary for PeerId {
|
|||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for ResponsePeer {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
ip_address: ::std::net::IpAddr::arbitrary(g),
|
||||
port: Port(u16::arbitrary(g)),
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
impl quickcheck::Arbitrary for AnnounceEvent {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
match (bool::arbitrary(g), bool::arbitrary(g)){
|
||||
(false, false) => Self::Started,
|
||||
(true, false) => Self::Started,
|
||||
|
|
@ -303,7 +303,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for ConnectRequest {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
transaction_id: TransactionId(i32::arbitrary(g)),
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for AnnounceRequest {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
connection_id: ConnectionId(i64::arbitrary(g)),
|
||||
transaction_id: TransactionId(i32::arbitrary(g)),
|
||||
|
|
@ -330,7 +330,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for ScrapeRequest {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let info_hashes = (0..u8::arbitrary(g)).map(|_| {
|
||||
InfoHash::arbitrary(g)
|
||||
}).collect();
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
impl quickcheck::Arbitrary for TorrentScrapeStatistics {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
seeders: NumberOfPeers(i32::arbitrary(g)),
|
||||
completed: NumberOfDownloads(i32::arbitrary(g)),
|
||||
|
|
@ -289,7 +289,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for ConnectResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
connection_id: ConnectionId(i64::arbitrary(g)),
|
||||
transaction_id: TransactionId(i32::arbitrary(g)),
|
||||
|
|
@ -298,7 +298,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for AnnounceResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let peers = (0..u8::arbitrary(g)).map(|_| {
|
||||
ResponsePeer::arbitrary(g)
|
||||
}).collect();
|
||||
|
|
@ -314,7 +314,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl quickcheck::Arbitrary for ScrapeResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let torrent_stats = (0..u8::arbitrary(g)).map(|_| {
|
||||
TorrentScrapeStatistics::arbitrary(g)
|
||||
}).collect();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ anyhow = "1"
|
|||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_common = "0.1.0"
|
||||
aquatic_ws_protocol = "0.1.0"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
either = "1"
|
||||
hashbrown = { version = "0.9", features = ["serde"] }
|
||||
histogram = "0.6"
|
||||
|
|
@ -30,12 +30,12 @@ mimalloc = { version = "0.1", default-features = false }
|
|||
mio = { version = "0.7", features = ["tcp", "os-poll", "os-util"] }
|
||||
native-tls = "0.2"
|
||||
parking_lot = "0.11"
|
||||
privdrop = "0.3"
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
privdrop = "0.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
socket2 = { version = "0.3", features = ["reuseport"] }
|
||||
tungstenite = "0.11"
|
||||
tungstenite = "0.13"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ pub fn run_poll_loop(
|
|||
max_message_size: Some(config.network.websocket_max_message_size),
|
||||
max_frame_size: Some(config.network.websocket_max_frame_size),
|
||||
max_send_queue: None,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut listener = TcpListener::from_std(listener);
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ aquatic_ws_protocol = "0.1.0"
|
|||
hashbrown = { version = "0.9", features = ["serde"] }
|
||||
mimalloc = { version = "0.1", default-features = false }
|
||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||
rand = { version = "0.7", features = ["small_rng"] }
|
||||
rand_distr = "0.3"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand_distr = "0.4"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
slab = "0.4"
|
||||
tungstenite = "0.11"
|
||||
tungstenite = "0.13"
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ hashbrown = { version = "0.9", features = ["serde"] }
|
|||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
simd-json = { version = "0.3", features = ["allow-non-simd"] }
|
||||
tungstenite = "0.11"
|
||||
tungstenite = "0.13"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
quickcheck = "1.0"
|
||||
quickcheck_macros = "1.0"
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
fn arbitrary_20_bytes<G: quickcheck::Gen>(g: &mut G) -> [u8; 20] {
|
||||
fn arbitrary_20_bytes(g: &mut quickcheck::Gen) -> [u8; 20] {
|
||||
let mut bytes = [0u8; 20];
|
||||
|
||||
for byte in bytes.iter_mut() {
|
||||
|
|
@ -335,25 +335,25 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for InfoHash {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self(arbitrary_20_bytes(g))
|
||||
}
|
||||
}
|
||||
|
||||
impl Arbitrary for PeerId {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self(arbitrary_20_bytes(g))
|
||||
}
|
||||
}
|
||||
|
||||
impl Arbitrary for OfferId {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self(arbitrary_20_bytes(g))
|
||||
}
|
||||
}
|
||||
|
||||
impl Arbitrary for AnnounceEvent {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
match (bool::arbitrary(g), bool::arbitrary(g)){
|
||||
(false, false) => Self::Started,
|
||||
(true, false) => Self::Started,
|
||||
|
|
@ -364,7 +364,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for MiddlemanOfferToPeer {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
action: AnnounceAction,
|
||||
peer_id: Arbitrary::arbitrary(g),
|
||||
|
|
@ -376,7 +376,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for MiddlemanAnswerToPeer {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
action: AnnounceAction,
|
||||
peer_id: Arbitrary::arbitrary(g),
|
||||
|
|
@ -388,7 +388,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for AnnounceRequestOffer {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
offer_id: Arbitrary::arbitrary(g),
|
||||
offer: sdp_json_value()
|
||||
|
|
@ -397,7 +397,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for AnnounceRequest {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let has_offers_or_answer_or_neither: Option<bool> = Arbitrary::arbitrary(g);
|
||||
|
||||
let mut offers: Option<Vec<AnnounceRequestOffer>> = None;
|
||||
|
|
@ -436,7 +436,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for AnnounceResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
action: AnnounceAction,
|
||||
info_hash: Arbitrary::arbitrary(g),
|
||||
|
|
@ -448,7 +448,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for ScrapeRequest {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
action: ScrapeAction,
|
||||
info_hashes: Arbitrary::arbitrary(g),
|
||||
|
|
@ -458,7 +458,7 @@ mod tests {
|
|||
|
||||
|
||||
impl Arbitrary for ScrapeRequestInfoHashes {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
if Arbitrary::arbitrary(g) {
|
||||
ScrapeRequestInfoHashes::Multiple(Arbitrary::arbitrary(g))
|
||||
} else {
|
||||
|
|
@ -468,7 +468,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for ScrapeStatistics {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
Self {
|
||||
complete: Arbitrary::arbitrary(g),
|
||||
incomplete: Arbitrary::arbitrary(g),
|
||||
|
|
@ -478,7 +478,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for ScrapeResponse {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let files: Vec<(InfoHash, ScrapeStatistics)> = Arbitrary::arbitrary(g);
|
||||
|
||||
Self {
|
||||
|
|
@ -489,7 +489,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for InMessage {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
if Arbitrary::arbitrary(g){
|
||||
Self::AnnounceRequest(Arbitrary::arbitrary(g))
|
||||
} else {
|
||||
|
|
@ -499,7 +499,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl Arbitrary for OutMessage {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
match (Arbitrary::arbitrary(g), Arbitrary::arbitrary(g)){
|
||||
(false, false) => Self::AnnounceResponse(Arbitrary::arbitrary(g)),
|
||||
(true, false) => Self::ScrapeResponse(Arbitrary::arbitrary(g)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue