mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Replace the apparently unmaintained hex crate with data-encoding
data-encoding was already a transitive dependency via tungstenite
This commit is contained in:
parent
886617e41c
commit
ba314b63e4
5 changed files with 19 additions and 15 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -389,9 +389,9 @@ checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
|
|||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.4.0"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
|
||||
checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
|
@ -1331,10 +1331,10 @@ dependencies = [
|
|||
name = "librespot"
|
||||
version = "0.5.0-dev"
|
||||
dependencies = [
|
||||
"data-encoding",
|
||||
"env_logger",
|
||||
"futures-util",
|
||||
"getopts",
|
||||
"hex",
|
||||
"librespot-audio",
|
||||
"librespot-connect",
|
||||
"librespot-core",
|
||||
|
@ -1398,13 +1398,13 @@ dependencies = [
|
|||
"base64 0.21.5",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"data-encoding",
|
||||
"dns-sd",
|
||||
"env_logger",
|
||||
"form_urlencoded",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"governor",
|
||||
"hex",
|
||||
"hmac",
|
||||
"http",
|
||||
"httparse",
|
||||
|
|
|
@ -50,10 +50,10 @@ path = "protocol"
|
|||
version = "0.5.0-dev"
|
||||
|
||||
[dependencies]
|
||||
data-encoding = "2.5"
|
||||
env_logger = { version = "0.10", default-features = false, features = ["color", "humantime", "auto-color"] }
|
||||
futures-util = { version = "0.3", default_features = false }
|
||||
getopts = "0.2"
|
||||
hex = "0.4"
|
||||
log = "0.4"
|
||||
rpassword = "7.0"
|
||||
sha1 = "0.10"
|
||||
|
|
|
@ -23,7 +23,6 @@ form_urlencoded = "1.0"
|
|||
futures-core = "0.3"
|
||||
futures-util = { version = "0.3", features = ["alloc", "bilock", "sink", "unstable"] }
|
||||
governor = { version = "0.6", default-features = false, features = ["std", "jitter"] }
|
||||
hex = "0.4"
|
||||
hmac = "0.12"
|
||||
httparse = "1.7"
|
||||
http = "0.2"
|
||||
|
@ -57,6 +56,7 @@ tokio-tungstenite = { version = "*", default-features = false, features = ["rust
|
|||
tokio-util = { version = "0.7", features = ["codec"] }
|
||||
url = "2"
|
||||
uuid = { version = "1", default-features = false, features = ["fast-rng", "v4"] }
|
||||
data-encoding = "2.5"
|
||||
|
||||
[build-dependencies]
|
||||
rand = "0.8"
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
|||
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use bytes::Bytes;
|
||||
use data_encoding::HEXUPPER_PERMISSIVE;
|
||||
use futures_util::future::IntoStream;
|
||||
use http::header::HeaderValue;
|
||||
use hyper::{
|
||||
|
@ -279,20 +280,22 @@ impl SpClient {
|
|||
let hash_cash_challenge = challenge.evaluate_hashcash_parameters();
|
||||
|
||||
let ctx = vec![];
|
||||
let prefix = hex::decode(&hash_cash_challenge.prefix).map_err(|e| {
|
||||
let prefix = HEXUPPER_PERMISSIVE
|
||||
.decode(hash_cash_challenge.prefix.as_bytes())
|
||||
.map_err(|e| {
|
||||
Error::failed_precondition(format!(
|
||||
"Unable to decode hash cash challenge: {e}"
|
||||
))
|
||||
})?;
|
||||
let length = hash_cash_challenge.length;
|
||||
|
||||
let mut suffix = vec![0; 0x10];
|
||||
let mut suffix = [0u8; 0x10];
|
||||
let answer = Self::solve_hash_cash(&ctx, &prefix, length, &mut suffix);
|
||||
|
||||
match answer {
|
||||
Ok(_) => {
|
||||
// the suffix must be in uppercase
|
||||
let suffix = hex::encode(suffix).to_uppercase();
|
||||
let suffix = HEXUPPER_PERMISSIVE.encode(&suffix);
|
||||
|
||||
let mut answer_message = ClientTokenRequest::new();
|
||||
answer_message.request_type =
|
||||
|
@ -302,7 +305,7 @@ impl SpClient {
|
|||
let challenge_answers = answer_message.mut_challenge_answers();
|
||||
|
||||
let mut challenge_answer = ChallengeAnswer::new();
|
||||
challenge_answer.mut_hash_cash().suffix = suffix.to_string();
|
||||
challenge_answer.mut_hash_cash().suffix = suffix;
|
||||
challenge_answer.ChallengeType =
|
||||
ChallengeType::CHALLENGE_HASH_CASH.into();
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use data_encoding::HEXLOWER;
|
||||
use futures_util::StreamExt;
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use sha1::{Digest, Sha1};
|
||||
|
@ -39,7 +40,7 @@ mod player_event_handler;
|
|||
use player_event_handler::{run_program_on_sink_events, EventHandler};
|
||||
|
||||
fn device_id(name: &str) -> String {
|
||||
hex::encode(Sha1::digest(name.as_bytes()))
|
||||
HEXLOWER.encode(&Sha1::digest(name.as_bytes()))
|
||||
}
|
||||
|
||||
fn usage(program: &str, opts: &getopts::Options) -> String {
|
||||
|
|
Loading…
Reference in a new issue