mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
Merge pull request #140 from greatest-ape/work-2023-06-03
Update dependencies
This commit is contained in:
commit
73a903ed44
10 changed files with 412 additions and 251 deletions
509
Cargo.lock
generated
509
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -36,8 +36,8 @@ glommio = "0.8"
|
||||||
itoa = "1"
|
itoa = "1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
metrics = { version = "0.20", optional = true }
|
metrics = { version = "0.21", optional = true }
|
||||||
metrics-exporter-prometheus = { version = "0.11", optional = true, default-features = false, features = ["http-listener"] }
|
metrics-exporter-prometheus = { version = "0.12", optional = true, default-features = false, features = ["http-listener"] }
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
memchr = "2"
|
memchr = "2"
|
||||||
privdrop = "0.5"
|
privdrop = "0.5"
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ hex = "0.4"
|
||||||
io-uring = { version = "0.6", optional = true }
|
io-uring = { version = "0.6", optional = true }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
metrics = { version = "0.20", optional = true }
|
metrics = { version = "0.21", optional = true }
|
||||||
metrics-exporter-prometheus = { version = "0.11", optional = true, default-features = false, features = ["http-listener"] }
|
metrics-exporter-prometheus = { version = "0.12", optional = true, default-features = false, features = ["http-listener"] }
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
mio = { version = "0.8", features = ["net", "os-poll"] }
|
mio = { version = "0.8", features = ["net", "os-poll"] }
|
||||||
num-format = "0.4"
|
num-format = "0.4"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ aquatic_toml_config.workspace = true
|
||||||
aquatic_ws_protocol.workspace = true
|
aquatic_ws_protocol.workspace = true
|
||||||
|
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
async-tungstenite = "0.20"
|
async-tungstenite = "0.22"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-lite = "1"
|
futures-lite = "1"
|
||||||
|
|
@ -36,8 +36,8 @@ glommio = "0.8"
|
||||||
hashbrown = { version = "0.13", features = ["serde"] }
|
hashbrown = { version = "0.13", features = ["serde"] }
|
||||||
httparse = "1"
|
httparse = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
metrics = { version = "0.20", optional = true }
|
metrics = { version = "0.21", optional = true }
|
||||||
metrics-exporter-prometheus = { version = "0.11", optional = true, default-features = false, features = ["http-listener"] }
|
metrics-exporter-prometheus = { version = "0.12", optional = true, default-features = false, features = ["http-listener"] }
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
privdrop = "0.5"
|
privdrop = "0.5"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
|
|
@ -47,7 +47,7 @@ serde = { version = "1", features = ["derive"] }
|
||||||
signal-hook = { version = "0.3" }
|
signal-hook = { version = "0.3" }
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
socket2 = { version = "0.5", features = ["all"] }
|
socket2 = { version = "0.5", features = ["all"] }
|
||||||
tungstenite = "0.18"
|
tungstenite = "0.19"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "1"
|
quickcheck = "1"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ aquatic_toml_config.workspace = true
|
||||||
aquatic_ws_protocol.workspace = true
|
aquatic_ws_protocol.workspace = true
|
||||||
|
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
async-tungstenite = "0.20"
|
async-tungstenite = "0.22"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-rustls = "0.24"
|
futures-rustls = "0.24"
|
||||||
glommio = "0.8"
|
glommio = "0.8"
|
||||||
|
|
@ -30,7 +30,7 @@ rand_distr = "0.4"
|
||||||
rustls = { version = "0.21", default-features = false, features = ["dangerous_configuration"] }
|
rustls = { version = "0.21", default-features = false, features = ["dangerous_configuration"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tungstenite = "0.18"
|
tungstenite = "0.19"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "1"
|
quickcheck = "1"
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,10 @@ anyhow = "1"
|
||||||
hashbrown = { version = "0.13", features = ["serde"] }
|
hashbrown = { version = "0.13", features = ["serde"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
# simd-json version 0.7 seems to have bugs in string parsing
|
simd-json = { version = "0.10", features = ["allow-non-simd"] }
|
||||||
# with custom visitor, where it includes quotes in strings
|
tungstenite = "0.19"
|
||||||
simd-json = { version = "0.6", features = ["allow-non-simd"] }
|
|
||||||
tungstenite = "0.18"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.4"
|
criterion = "0.5"
|
||||||
quickcheck = "1"
|
quickcheck = "1"
|
||||||
quickcheck_macros = "1"
|
quickcheck_macros = "1"
|
||||||
|
|
|
||||||
|
|
@ -202,39 +202,50 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_20_bytes() {
|
fn test_deserialize_20_bytes() {
|
||||||
let mut input = r#""aaaabbbbccccddddeeee""#.to_string();
|
unsafe {
|
||||||
|
let mut input = r#""aaaabbbbccccddddeeee""#.to_string();
|
||||||
|
|
||||||
let expected = info_hash_from_bytes(b"aaaabbbbccccddddeeee");
|
let expected = info_hash_from_bytes(b"aaaabbbbccccddddeeee");
|
||||||
let observed: InfoHash = ::simd_json::serde::from_str(&mut input).unwrap();
|
let observed: InfoHash = ::simd_json::serde::from_str(&mut input).unwrap();
|
||||||
|
|
||||||
assert_eq!(observed, expected);
|
assert_eq!(observed, expected);
|
||||||
|
}
|
||||||
|
|
||||||
let mut input = r#""aaaabbbbccccddddeee""#.to_string();
|
unsafe {
|
||||||
let res_info_hash: Result<InfoHash, _> = ::simd_json::serde::from_str(&mut input);
|
let mut input = r#""aaaabbbbccccddddeee""#.to_string();
|
||||||
|
let res_info_hash: Result<InfoHash, _> = ::simd_json::serde::from_str(&mut input);
|
||||||
|
|
||||||
assert!(res_info_hash.is_err());
|
assert!(res_info_hash.is_err());
|
||||||
|
}
|
||||||
|
|
||||||
let mut input = r#""aaaabbbbccccddddeee𝕊""#.to_string();
|
unsafe {
|
||||||
let res_info_hash: Result<InfoHash, _> = ::simd_json::serde::from_str(&mut input);
|
let mut input = r#""aaaabbbbccccddddeee𝕊""#.to_string();
|
||||||
|
let res_info_hash: Result<InfoHash, _> = ::simd_json::serde::from_str(&mut input);
|
||||||
|
|
||||||
assert!(res_info_hash.is_err());
|
assert!(res_info_hash.is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serde_20_bytes() {
|
fn test_serde_20_bytes() {
|
||||||
let info_hash = info_hash_from_bytes(b"aaaabbbbccccddddeeee");
|
let info_hash = info_hash_from_bytes(b"aaaabbbbccccddddeeee");
|
||||||
|
|
||||||
let mut out = ::simd_json::serde::to_string(&info_hash).unwrap();
|
let info_hash_2 = unsafe {
|
||||||
let info_hash_2 = ::simd_json::serde::from_str(&mut out).unwrap();
|
let mut out = ::simd_json::serde::to_string(&info_hash).unwrap();
|
||||||
|
|
||||||
|
::simd_json::serde::from_str(&mut out).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(info_hash, info_hash_2);
|
assert_eq!(info_hash, info_hash_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[quickcheck]
|
#[quickcheck]
|
||||||
fn quickcheck_serde_20_bytes(info_hash: InfoHash) -> bool {
|
fn quickcheck_serde_20_bytes(info_hash: InfoHash) -> bool {
|
||||||
let mut out = ::simd_json::serde::to_string(&info_hash).unwrap();
|
unsafe {
|
||||||
let info_hash_2 = ::simd_json::serde::from_str(&mut out).unwrap();
|
let mut out = ::simd_json::serde::to_string(&info_hash).unwrap();
|
||||||
|
let info_hash_2 = ::simd_json::serde::from_str(&mut out).unwrap();
|
||||||
|
|
||||||
info_hash == info_hash_2
|
info_hash == info_hash_2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,12 +262,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_info_hashes_vec() {
|
fn test_deserialize_info_hashes_vec() {
|
||||||
let mut input: String = r#"{
|
|
||||||
"action": "scrape",
|
|
||||||
"info_hash": ["aaaabbbbccccddddeeee", "aaaabbbbccccddddeeee"]
|
|
||||||
}"#
|
|
||||||
.into();
|
|
||||||
|
|
||||||
let info_hashes = ScrapeRequestInfoHashes::Multiple(vec![
|
let info_hashes = ScrapeRequestInfoHashes::Multiple(vec![
|
||||||
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
||||||
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
||||||
|
|
@ -278,19 +272,21 @@ mod tests {
|
||||||
info_hashes: Some(info_hashes),
|
info_hashes: Some(info_hashes),
|
||||||
};
|
};
|
||||||
|
|
||||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
let observed: ScrapeRequest = unsafe {
|
||||||
|
let mut input: String = r#"{
|
||||||
|
"action": "scrape",
|
||||||
|
"info_hash": ["aaaabbbbccccddddeeee", "aaaabbbbccccddddeeee"]
|
||||||
|
}"#
|
||||||
|
.into();
|
||||||
|
|
||||||
|
::simd_json::serde::from_str(&mut input).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(expected, observed);
|
assert_eq!(expected, observed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_info_hashes_str() {
|
fn test_deserialize_info_hashes_str() {
|
||||||
let mut input: String = r#"{
|
|
||||||
"action": "scrape",
|
|
||||||
"info_hash": "aaaabbbbccccddddeeee"
|
|
||||||
}"#
|
|
||||||
.into();
|
|
||||||
|
|
||||||
let info_hashes =
|
let info_hashes =
|
||||||
ScrapeRequestInfoHashes::Single(info_hash_from_bytes(b"aaaabbbbccccddddeeee"));
|
ScrapeRequestInfoHashes::Single(info_hash_from_bytes(b"aaaabbbbccccddddeeee"));
|
||||||
|
|
||||||
|
|
@ -299,54 +295,65 @@ mod tests {
|
||||||
info_hashes: Some(info_hashes),
|
info_hashes: Some(info_hashes),
|
||||||
};
|
};
|
||||||
|
|
||||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
let observed: ScrapeRequest = unsafe {
|
||||||
|
let mut input: String = r#"{
|
||||||
|
"action": "scrape",
|
||||||
|
"info_hash": "aaaabbbbccccddddeeee"
|
||||||
|
}"#
|
||||||
|
.into();
|
||||||
|
|
||||||
|
::simd_json::serde::from_str(&mut input).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(expected, observed);
|
assert_eq!(expected, observed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_info_hashes_null() {
|
fn test_deserialize_info_hashes_null() {
|
||||||
let mut input: String = r#"{
|
let observed: ScrapeRequest = unsafe {
|
||||||
"action": "scrape",
|
let mut input: String = r#"{
|
||||||
"info_hash": null
|
"action": "scrape",
|
||||||
}"#
|
"info_hash": null
|
||||||
.into();
|
}"#
|
||||||
|
.into();
|
||||||
|
|
||||||
|
::simd_json::serde::from_str(&mut input).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let expected = ScrapeRequest {
|
let expected = ScrapeRequest {
|
||||||
action: ScrapeAction,
|
action: ScrapeAction,
|
||||||
info_hashes: None,
|
info_hashes: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(expected, observed);
|
assert_eq!(expected, observed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_info_hashes_missing() {
|
fn test_deserialize_info_hashes_missing() {
|
||||||
let mut input: String = r#"{
|
let observed: ScrapeRequest = unsafe {
|
||||||
"action": "scrape"
|
let mut input: String = r#"{
|
||||||
}"#
|
"action": "scrape"
|
||||||
.into();
|
}"#
|
||||||
|
.into();
|
||||||
|
|
||||||
|
::simd_json::serde::from_str(&mut input).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let expected = ScrapeRequest {
|
let expected = ScrapeRequest {
|
||||||
action: ScrapeAction,
|
action: ScrapeAction,
|
||||||
info_hashes: None,
|
info_hashes: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(expected, observed);
|
assert_eq!(expected, observed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[quickcheck]
|
#[quickcheck]
|
||||||
fn quickcheck_serde_identity_info_hashes(info_hashes: ScrapeRequestInfoHashes) -> bool {
|
fn quickcheck_serde_identity_info_hashes(info_hashes: ScrapeRequestInfoHashes) -> bool {
|
||||||
let mut json = ::simd_json::serde::to_string(&info_hashes).unwrap();
|
let deserialized: ScrapeRequestInfoHashes = unsafe {
|
||||||
|
let mut json = ::simd_json::serde::to_string(&info_hashes).unwrap();
|
||||||
|
|
||||||
println!("{}", json);
|
::simd_json::serde::from_str(&mut json).unwrap()
|
||||||
|
};
|
||||||
let deserialized: ScrapeRequestInfoHashes =
|
|
||||||
::simd_json::serde::from_str(&mut json).unwrap();
|
|
||||||
|
|
||||||
let success = info_hashes == deserialized;
|
let success = info_hashes == deserialized;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@ impl InMessage {
|
||||||
use tungstenite::Message;
|
use tungstenite::Message;
|
||||||
|
|
||||||
match ws_message {
|
match ws_message {
|
||||||
Message::Text(mut text) => {
|
Message::Text(text) => {
|
||||||
::simd_json::serde::from_str(&mut text).context("deserialize with serde")
|
let mut text: Vec<u8> = text.into();
|
||||||
|
|
||||||
|
::simd_json::serde::from_slice(&mut text).context("deserialize with serde")
|
||||||
}
|
}
|
||||||
Message::Binary(mut bytes) => {
|
Message::Binary(mut bytes) => {
|
||||||
::simd_json::serde::from_slice(&mut bytes[..]).context("deserialize with serde")
|
::simd_json::serde::from_slice(&mut bytes[..]).context("deserialize with serde")
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,12 @@ impl OutMessage {
|
||||||
pub fn from_ws_message(message: ::tungstenite::Message) -> ::anyhow::Result<Self> {
|
pub fn from_ws_message(message: ::tungstenite::Message) -> ::anyhow::Result<Self> {
|
||||||
use tungstenite::Message::{Binary, Text};
|
use tungstenite::Message::{Binary, Text};
|
||||||
|
|
||||||
let mut text = match message {
|
let mut text: Vec<u8> = match message {
|
||||||
Text(text) => text,
|
Text(text) => text.into(),
|
||||||
Binary(bytes) => String::from_utf8(bytes)?,
|
Binary(bytes) => String::from_utf8(bytes)?.into(),
|
||||||
_ => return Err(anyhow::anyhow!("Message is neither text nor bytes")),
|
_ => return Err(anyhow::anyhow!("Message is neither text nor bytes")),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(::simd_json::serde::from_str(&mut text)?)
|
Ok(::simd_json::serde::from_slice(&mut text)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue