Эх сурвалжийг харах

Merge pull request #138 from librespot-org/authpanic

Add error message to auth failure case
Sasha Hilton 7 жил өмнө
parent
commit
874cc541de

+ 6 - 1
core/src/connection/mod.rs

@@ -34,6 +34,7 @@ pub fn authenticate(
     device_id: String,
 ) -> Box<Future<Item = (Transport, Credentials), Error = io::Error>> {
     use protocol::authentication::{APWelcome, ClientResponseEncrypted, CpuFamily, Os};
+    use protocol::keyexchange::APLoginFailed;
 
     let mut packet = ClientResponseEncrypted::new();
     packet
@@ -79,7 +80,11 @@ pub fn authenticate(
                     Ok((transport, reusable_credentials))
                 }
 
-                Some((0xad, _)) => panic!("Authentication failed"),
+                Some((0xad, data)) => {
+                    let error_data: APLoginFailed = protobuf::parse_from_bytes(data.as_ref()).unwrap();
+                    panic!("Authentication failed with reason: {:?}", error_data.get_error_code())
+                }
+
                 Some((cmd, _)) => panic!("Unexpected packet {:?}", cmd),
                 None => panic!("EOF"),
             }),