Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Mar 15, 2019
2 parents 54974d8 + ef28df6 commit 391b9c6
Show file tree
Hide file tree
Showing 20 changed files with 399 additions and 2,581 deletions.
2,170 changes: 0 additions & 2,170 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hyper = "0.11.2"
log = "0.3.5"
num-bigint = "0.1.35"
protobuf = "1.1"
rand = "0.3.13"
rand = "0.6"
rpassword = "0.3.0"
serde = "0.9.6"
serde_derive = "0.9.6"
Expand All @@ -55,7 +55,7 @@ sha-1 = "0.8.0"
hex = "0.3.2"

[build-dependencies]
rand = "0.3.13"
rand = "0.6"
vergen = "0.1.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion connect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hyper = "0.11.2"
log = "0.3.5"
num-bigint = "0.1.35"
protobuf = "2.0.5"
rand = "0.3.13"
rand = "0.6"
serde = "0.9.6"
serde_derive = "0.9.6"
serde_json = "0.9.5"
Expand Down
14 changes: 12 additions & 2 deletions connect/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,17 @@ impl Discovery {
h.result().code()
};

assert_eq!(&mac[..], cksum);
if mac != cksum {
warn!("Login error for user {:?}: MAC mismatch", username);
let result = json!({
"status": 102,
"spotifyError": 1,
"statusString": "ERROR-MAC"
});

let body = result.to_string();
return ::futures::finished(Response::new().with_body(body))
}

let decrypted = {
let mut data = encrypted.to_vec();
Expand Down Expand Up @@ -225,7 +235,6 @@ pub fn discovery(

let serve = {
let http = Http::new();
debug!("Zeroconf server listening on 0.0.0.0:{}", port);
http.serve_addr_handle(
&format!("0.0.0.0:{}", port).parse().unwrap(),
&handle,
Expand All @@ -234,6 +243,7 @@ pub fn discovery(
};

let s_port = serve.incoming_ref().local_addr().port();
debug!("Zeroconf server listening on 0.0.0.0:{}", s_port);

let server_future = {
let handle = handle.clone();
Expand Down
8 changes: 5 additions & 3 deletions connect/src/spirc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use playback::mixer::Mixer;
use playback::player::Player;

use rand;
use rand::Rng;
use rand::seq::SliceRandom;
use std;
use std::time::{SystemTime, UNIX_EPOCH};

Expand Down Expand Up @@ -214,7 +214,8 @@ impl Spirc {

let ident = session.device_id().to_owned();

let uri = format!("hm://remote/3/user/{}/", session.username());
// Uri updated in response to issue #288
let uri = format!("hm://remote/user/{}/", session.username());

let subscription = session.mercury().subscribe(&uri as &str);
let subscription = subscription
Expand Down Expand Up @@ -508,7 +509,8 @@ impl SpircTask {
let tracks = self.state.mut_track();
tracks.swap(0, current_index as usize);
if let Some((_, rest)) = tracks.split_first_mut() {
rand::thread_rng().shuffle(rest);
let mut rng = rand::thread_rng();
rest.shuffle(&mut rng);
}
}
self.state.set_playing_track_index(0);
Expand Down
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ num-bigint = "0.1.35"
num-integer = "0.1.32"
num-traits = "0.1.36"
protobuf = "2.0.5"
rand = "0.3.13"
rand = "0.6"
rpassword = "0.3.0"
serde = "0.9.6"
serde_derive = "0.9.6"
Expand All @@ -40,5 +40,5 @@ aes = "0.3.0"
block-modes = "0.2.0"

[build-dependencies]
rand = "0.3.13"
rand = "0.6"
vergen = "0.1.0"
4 changes: 3 additions & 1 deletion core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extern crate rand;
extern crate vergen;

use rand::Rng;
use rand::distributions::Alphanumeric;
use std::env;
use std::fs::OpenOptions;
use std::io::Write;
Expand All @@ -12,7 +13,8 @@ fn main() {

vergen::vergen(vergen::OutputFns::all()).unwrap();

let build_id: String = rand::thread_rng().gen_ascii_chars().take(8).collect();
let mut rng = rand::thread_rng();
let build_id: String = ::std::iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();

let mut version_file = OpenOptions::new()
.write(true)
Expand Down
2 changes: 1 addition & 1 deletion core/src/connection/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn client_hello<T: AsyncWrite>(connection: T, gc: Vec<u8>) -> WriteAll<T, Vec<u8
packet
.mut_build_info()
.set_platform(protocol::keyexchange::Platform::PLATFORM_LINUX_X86);
packet.mut_build_info().set_version(0x10800000000);
packet.mut_build_info().set_version(109800078);
packet
.mut_cryptosuites_supported()
.push(protocol::keyexchange::Cryptosuite::CRYPTO_SUITE_SHANNON);
Expand Down
6 changes: 3 additions & 3 deletions core/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use num_bigint::BigUint;
use num_integer::Integer;
use num_traits::{One, Zero};
use rand::{Rand, Rng};
use rand::Rng;
use std::mem;
use std::ops::{Mul, Rem, Shr};

pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
rng.gen_iter().take(size).collect()
pub fn rand_vec<G: Rng>(rng: &mut G, size: usize) -> Vec<u8> {
::std::iter::repeat(()).map(|()| rng.gen()).take(size).collect()
}

pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
Expand Down
16 changes: 9 additions & 7 deletions playback/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,12 @@ impl PlayerInternal {
let key = self
.session
.audio_key()
.request(track.id, file_id)
.wait()
.unwrap();
.request(track.id, file_id);
let encrypted_file = AudioFile::open(&self.session, file_id);

let encrypted_file = AudioFile::open(&self.session, file_id).wait().unwrap();

let encrypted_file = encrypted_file.wait().unwrap();
let key = key.wait().unwrap();
let mut decrypted_file = AudioDecrypt::new(key, encrypted_file);

let normalisation_factor = match NormalisationData::parse_from_file(&mut decrypted_file) {
Expand All @@ -580,9 +580,11 @@ impl PlayerInternal {

let mut decoder = VorbisDecoder::new(audio_file).unwrap();

match decoder.seek(position) {
Ok(_) => (),
Err(err) => error!("Vorbis error: {:?}", err),
if position != 0 {
match decoder.seek(position) {
Ok(_) => (),
Err(err) => error!("Vorbis error: {:?}", err),
}
}

info!("Track \"{}\" loaded", track.name);
Expand Down
2 changes: 1 addition & 1 deletion protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build = "build.rs"
protobuf = "2.0.5"

[build-dependencies]
protoc-rust = "2.0.5"
protobuf-codegen-pure = "2.0.5"
7 changes: 3 additions & 4 deletions protocol/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate protoc_rust;
use protoc_rust::Customize;
extern crate protobuf_codegen_pure;
use protobuf_codegen_pure::Customize;
use std::fs::File;
use std::io::prelude::*;

Expand All @@ -14,7 +14,7 @@ fn main() {
for &(path, expected_checksum) in files::FILES {
let actual = cksum_file(path).unwrap();
if expected_checksum != actual {
protoc_rust::run(protoc_rust::Args {
protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
out_dir: "src",
input: &[path],
includes: &["proto"],
Expand All @@ -28,7 +28,6 @@ fn main() {
if changed {
// Write new checksums to file
let mut file = File::create("files.rs").unwrap();
println!("f_str: {:?}",f_str);
file.write_all(f_str.as_bytes()).unwrap();
}
}
Expand Down
29 changes: 0 additions & 29 deletions protocol/build.sh

This file was deleted.

Loading

0 comments on commit 391b9c6

Please sign in to comment.