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:
Sasha Hilton 2019-03-14 17:05:15 +01:00 committed by GitHub
commit ef28df6301
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -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();

View file

@ -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 {