@@ -9,6 +9,7 @@ use tracing::{debug, error, trace};
99use tungstenite:: client:: IntoClientRequest ;
1010use url:: Url ;
1111
12+ use super :: error:: CableTunnelError ;
1213use super :: known_devices:: CableKnownDeviceId ;
1314use super :: protocol:: CableTunnelConnectionType ;
1415use crate :: proto:: ctap2:: cbor;
@@ -102,9 +103,9 @@ fn resolve_redirect_target(base: &str, location: &str) -> Result<String, Transpo
102103/// Maps a non-101 tunnel handshake status to a transport error, distinguishing 410 Gone.
103104fn tunnel_status_error ( status : StatusCode ) -> TransportError {
104105 if status == StatusCode :: GONE {
105- TransportError :: TunnelServerGone
106+ CableTunnelError :: Gone . into ( )
106107 } else {
107- TransportError :: ConnectionFailed
108+ CableTunnelError :: UnexpectedStatus ( status . as_u16 ( ) ) . into ( )
108109 }
109110}
110111
@@ -115,7 +116,7 @@ pub(crate) fn known_device_id_to_forget(
115116) -> Option < CableKnownDeviceId > {
116117 match ( error, connection_type) {
117118 (
118- TransportError :: TunnelServerGone ,
119+ TransportError :: CableTunnel ( CableTunnelError :: Gone ) ,
119120 CableTunnelConnectionType :: KnownDevice {
120121 authenticator_public_key,
121122 ..
@@ -188,7 +189,7 @@ pub(crate) async fn connect(
188189 }
189190
190191 error ! ( "Exceeded the maximum number of tunnel redirects" ) ;
191- Err ( TransportError :: ConnectionFailed )
192+ Err ( CableTunnelError :: TooManyRedirects . into ( ) )
192193}
193194
194195#[ cfg( test) ]
@@ -289,7 +290,10 @@ mod tests {
289290 let public_key = vec ! [ 7u8 ; 65 ] ;
290291 let connection_type = known_device_connection_type ( public_key. clone ( ) ) ;
291292 assert_eq ! (
292- known_device_id_to_forget( & TransportError :: TunnelServerGone , & connection_type) ,
293+ known_device_id_to_forget(
294+ & TransportError :: CableTunnel ( CableTunnelError :: Gone ) ,
295+ & connection_type
296+ ) ,
293297 Some ( hex:: encode( & public_key) )
294298 ) ;
295299 }
@@ -298,7 +302,10 @@ mod tests {
298302 fn gone_does_not_forget_qr_code ( ) {
299303 let connection_type = qr_connection_type ( ) ;
300304 assert_eq ! (
301- known_device_id_to_forget( & TransportError :: TunnelServerGone , & connection_type) ,
305+ known_device_id_to_forget(
306+ & TransportError :: CableTunnel ( CableTunnelError :: Gone ) ,
307+ & connection_type
308+ ) ,
302309 None
303310 ) ;
304311 }
@@ -316,11 +323,11 @@ mod tests {
316323 fn gone_status_maps_to_distinct_error ( ) {
317324 assert_eq ! (
318325 tunnel_status_error( StatusCode :: GONE ) ,
319- TransportError :: TunnelServerGone
326+ TransportError :: CableTunnel ( CableTunnelError :: Gone )
320327 ) ;
321328 assert_eq ! (
322329 tunnel_status_error( StatusCode :: BAD_GATEWAY ) ,
323- TransportError :: ConnectionFailed
330+ TransportError :: CableTunnel ( CableTunnelError :: UnexpectedStatus ( 502 ) )
324331 ) ;
325332 }
326333}
0 commit comments