@@ -5,7 +5,7 @@ use bytes::Bytes;
55use tokio:: io:: { AsyncRead , AsyncReadExt , AsyncWrite } ;
66use ts_capabilityversion:: CapabilityVersion ;
77use ts_http_util:: { BytesBody , ClientExt , EmptyBody , HeaderName , HeaderValue , Http2 , ResponseExt } ;
8- use ts_keys:: { MachineKeyPair , MachinePublicKey } ;
8+ use ts_keys:: { MachineKeyPair , MachinePrivateKey , MachinePublicKey } ;
99use url:: Url ;
1010use zerocopy:: network_endian:: U32 ;
1111
@@ -166,7 +166,14 @@ pub async fn connect(
166166 CapabilityVersion :: CURRENT ,
167167 ) ;
168168
169- let conn = upgrade_ts2021 ( control_url, & init_msg, handshake, h1_client) . await ?;
169+ let conn = upgrade_ts2021 (
170+ control_url,
171+ & init_msg,
172+ handshake,
173+ machine_keys. private ,
174+ h1_client,
175+ )
176+ . await ?;
170177
171178 // The early payload (challenge packet) is optional. The server may send
172179 // the magic prefix [FF FF FF 'T' 'S'] followed by a JSON challenge, or it
@@ -225,7 +232,8 @@ pub async fn fetch_control_key(control_url: &Url) -> Result<MachinePublicKey, Co
225232pub async fn upgrade_ts2021 (
226233 control_url : & Url ,
227234 init_msg : & str ,
228- mut handshake : ts_control_noise:: Handshake ,
235+ handshake : ts_control_noise:: Handshake ,
236+ machine_private_key : MachinePrivateKey ,
229237 h1_client : impl ts_http_util:: Client < EmptyBody > ,
230238) -> Result < impl AsyncRead + AsyncWrite + Unpin + ' static , ConnectionError > {
231239 let ts2021_url = control_url. join ( "/ts2021" ) ?;
@@ -251,7 +259,7 @@ pub async fn upgrade_ts2021(
251259 ConnectionError :: Internal ( InternalErrorKind :: Http )
252260 } ) ?;
253261
254- let conn = handshake. complete ( upgraded) . await ?;
262+ let conn = handshake. complete ( upgraded, & machine_private_key ) . await ?;
255263
256264 tracing:: debug!( "upgraded control connection from HTTP/1.1 to TS2021" ) ;
257265
0 commit comments