mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Merge pull request #302 from kingosticks/fix/discover-bad-mac-panic
Don't panic when the computed MAC doesn't match the client's expected MAC
This commit is contained in:
commit
ef28df6301
2 changed files with 14 additions and 2 deletions
|
@ -132,7 +132,17 @@ impl Discovery {
|
|||
h.result().code().to_owned()
|
||||
};
|
||||
|
||||
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 = vec![0u8; encrypted.len()];
|
||||
|
@ -221,7 +231,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,
|
||||
|
@ -230,6 +239,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();
|
||||
|
|
|
@ -445,6 +445,8 @@ impl Future for Main {
|
|||
if !self.shutdown {
|
||||
if let Some(ref spirc) = self.spirc {
|
||||
spirc.shutdown();
|
||||
} else {
|
||||
return Ok(Async::Ready(()));
|
||||
}
|
||||
self.shutdown = true;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue