@@ -19,9 +19,8 @@ use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
1919use tracing:: { debug, error, trace, warn} ;
2020use tungstenite:: client:: IntoClientRequest ;
2121
22- use super :: channel:: { CableChannel , CableChannelDevice } ;
22+ use super :: channel:: CableChannel ;
2323use super :: known_devices:: { CableKnownDeviceInfo , CableKnownDeviceInfoStore } ;
24- use super :: qr_code_device:: CableQrCodeDevice ;
2524use crate :: proto:: ctap2:: cbor:: { CborRequest , CborResponse } ;
2625use crate :: proto:: ctap2:: { Ctap2CommandCode , Ctap2GetInfoResponse } ;
2726use crate :: transport:: cable:: known_devices:: CableKnownDeviceId ;
@@ -157,13 +156,13 @@ pub fn decode_tunnel_server_domain(encoded: u16) -> Option<String> {
157156}
158157
159158pub async fn connect < ' d > (
160- device : & ' d CableQrCodeDevice ,
159+ maybe_known_device_store : & Option < Arc < dyn CableKnownDeviceInfoStore > > ,
161160 tunnel_domain : & str ,
162161 routing_id : & str ,
163162 tunnel_id : & str ,
164163 psk : & [ u8 ; 32 ] ,
165164 private_key : & NonZeroScalar ,
166- ) -> Result < ( CableChannel < ' d > , mpsc:: Receiver < UxUpdate > ) , Error > {
165+ ) -> Result < ( CableChannel , mpsc:: Receiver < UxUpdate > ) , Error > {
167166 let connect_url = format ! (
168167 "wss://{}/cable/connect/{}/{}" ,
169168 tunnel_domain, routing_id, tunnel_id
@@ -207,13 +206,16 @@ pub async fn connect<'d>(
207206 // After this, the handshake should be complete and you can start sending/receiving encrypted messages.
208207 // ...
209208
210- let ( cbor_sender, cbor_receiver, handle_connection) =
211- task_connection ( tunnel_domain, device, ws_stream, noise_state) ?;
209+ let ( cbor_sender, cbor_receiver, handle_connection) = task_connection (
210+ tunnel_domain,
211+ maybe_known_device_store,
212+ ws_stream,
213+ noise_state,
214+ ) ?;
212215
213216 let ( send, recv) = mpsc:: channel ( 1 ) ;
214217 Ok ( (
215218 CableChannel {
216- device : CableChannelDevice :: QrCode ( device) ,
217219 handle_connection,
218220 cbor_sender,
219221 cbor_receiver,
@@ -329,15 +331,15 @@ async fn do_handshake(
329331
330332fn task_connection (
331333 tunnel_domain : & str ,
332- device : & CableQrCodeDevice ,
334+ maybe_known_device_store : & Option < Arc < dyn CableKnownDeviceInfoStore > > ,
333335 ws_stream : WebSocketStream < MaybeTlsStream < TcpStream > > ,
334336 transport_state : TransportState ,
335337) -> Result < ( Sender < CborRequest > , Receiver < CborResponse > , JoinHandle < ( ) > ) , Error > {
336338 let ( cbor_tx_send, cbor_tx_recv) = mpsc:: channel ( 16 ) ;
337339 let ( cbor_rx_send, cbor_rx_recv) = mpsc:: channel ( 16 ) ;
338340
339341 let tunnel_domain: String = tunnel_domain. to_string ( ) ;
340- let maybe_known_device_store = device . store . to_owned ( ) ;
342+ let maybe_known_device_store = maybe_known_device_store . clone ( ) ;
341343 let handle_connection = task:: spawn ( async move {
342344 connection (
343345 & tunnel_domain,
0 commit comments