@@ -202,7 +202,7 @@ impl std::fmt::Debug for CableTunnelConnectionType {
202202pub ( crate ) async fn connect < ' d > (
203203 tunnel_domain : & str ,
204204 connection_type : & CableTunnelConnectionType ,
205- ) -> Result < WebSocketStream < MaybeTlsStream < TcpStream > > , Error > {
205+ ) -> Result < WebSocketStream < MaybeTlsStream < TcpStream > > , TransportError > {
206206 ensure_rustls_crypto_provider ( ) ;
207207
208208 let connect_url = match connection_type {
@@ -221,22 +221,22 @@ pub(crate) async fn connect<'d>(
221221 debug ! ( ?connect_url, "Connecting to tunnel server" ) ;
222222 let mut request = connect_url
223223 . into_client_request ( )
224- . or ( Err ( Error :: Transport ( TransportError :: InvalidEndpoint ) ) ) ?;
224+ . or ( Err ( TransportError :: InvalidEndpoint ) ) ?;
225225 request. headers_mut ( ) . insert (
226226 "Sec-WebSocket-Protocol" ,
227227 "fido.cable"
228228 . parse ( )
229- . or ( Err ( Error :: Transport ( TransportError :: InvalidEndpoint ) ) ) ?,
229+ . or ( Err ( TransportError :: InvalidEndpoint ) ) ?,
230230 ) ;
231231
232232 if let CableTunnelConnectionType :: KnownDevice { client_payload, .. } = connection_type {
233- let client_payload = cbor :: to_vec ( client_payload )
234- . or ( Err ( Error :: Transport ( TransportError :: InvalidEndpoint ) ) ) ?;
233+ let client_payload =
234+ cbor :: to_vec ( client_payload ) . or ( Err ( TransportError :: InvalidEndpoint ) ) ?;
235235 request. headers_mut ( ) . insert (
236236 "X-caBLE-Client-Payload" ,
237237 hex:: encode ( & client_payload)
238238 . parse ( )
239- . or ( Err ( Error :: Transport ( TransportError :: InvalidEndpoint ) ) ) ?,
239+ . or ( Err ( TransportError :: InvalidEndpoint ) ) ?,
240240 ) ;
241241 }
242242 trace ! ( ?request) ;
@@ -245,14 +245,14 @@ pub(crate) async fn connect<'d>(
245245 Ok ( ( ws_stream, response) ) => ( ws_stream, response) ,
246246 Err ( e) => {
247247 error ! ( ?e, "Failed to connect to tunnel server" ) ;
248- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
248+ return Err ( TransportError :: ConnectionFailed ) ;
249249 }
250250 } ;
251251 debug ! ( ?response, "Connected to tunnel server" ) ;
252252
253253 if response. status ( ) != StatusCode :: SWITCHING_PROTOCOLS {
254254 error ! ( ?response, "Failed to switch to websocket protocol" ) ;
255- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
255+ return Err ( TransportError :: ConnectionFailed ) ;
256256 }
257257 debug ! ( "Tunnel server returned success" ) ;
258258
@@ -269,7 +269,7 @@ pub(crate) async fn do_handshake(
269269 ws_stream : & mut WebSocketStream < MaybeTlsStream < TcpStream > > ,
270270 psk : [ u8 ; 32 ] ,
271271 connection_type : & CableTunnelConnectionType ,
272- ) -> Result < TunnelNoiseState , Error > {
272+ ) -> Result < TunnelNoiseState , TransportError > {
273273 let noise_handshake = match connection_type {
274274 CableTunnelConnectionType :: QrCode { private_key, .. } => {
275275 let local_private_key = private_key. to_owned ( ) . to_bytes ( ) ;
@@ -294,7 +294,7 @@ pub(crate) async fn do_handshake(
294294 Ok ( handshake) => handshake,
295295 Err ( e) => {
296296 error ! ( ?e, "Failed to build Noise handshake" ) ;
297- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
297+ return Err ( TransportError :: ConnectionFailed ) ;
298298 }
299299 } ;
300300
@@ -303,7 +303,7 @@ pub(crate) async fn do_handshake(
303303 Ok ( msg_len) => msg_len,
304304 Err ( e) => {
305305 error ! ( ?e, "Failed to write initial handshake message" ) ;
306- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
306+ return Err ( TransportError :: ConnectionFailed ) ;
307307 }
308308 } ;
309309
@@ -315,7 +315,7 @@ pub(crate) async fn do_handshake(
315315
316316 if let Err ( e) = ws_stream. send ( Message :: Binary ( initial_msg. into ( ) ) ) . await {
317317 error ! ( ?e, "Failed to send initial handshake message" ) ;
318- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
318+ return Err ( TransportError :: ConnectionFailed ) ;
319319 }
320320 debug ! ( "Sent initial handshake message" ) ;
321321
@@ -329,15 +329,15 @@ pub(crate) async fn do_handshake(
329329
330330 Some ( Ok ( msg) ) => {
331331 error ! ( ?msg, "Unexpected message type received" ) ;
332- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
332+ return Err ( TransportError :: ConnectionFailed ) ;
333333 }
334334 Some ( Err ( e) ) => {
335335 error ! ( ?e, "Failed to read handshake response" ) ;
336- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
336+ return Err ( TransportError :: ConnectionFailed ) ;
337337 }
338338 None => {
339339 error ! ( "Connection was closed before handshake was complete" ) ;
340- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
340+ return Err ( TransportError :: ConnectionFailed ) ;
341341 }
342342 } ;
343343
@@ -350,7 +350,7 @@ pub(crate) async fn do_handshake(
350350 { len = response. len( ) } ,
351351 "Peer handshake message is too short"
352352 ) ;
353- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
353+ return Err ( TransportError :: ConnectionFailed ) ;
354354 }
355355
356356 let mut payload = [ 0u8 ; 1024 ] ;
@@ -365,7 +365,7 @@ pub(crate) async fn do_handshake(
365365
366366 if !noise_handshake. is_handshake_finished ( ) {
367367 error ! ( "Handshake did not complete" ) ;
368- return Err ( Error :: Transport ( TransportError :: ConnectionFailed ) ) ;
368+ return Err ( TransportError :: ConnectionFailed ) ;
369369 }
370370
371371 Ok ( TunnelNoiseState {
0 commit comments