File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use rsa::BigUint;
9
9
use sha1:: Sha1 ;
10
10
#[ cfg( windows) ]
11
11
use ssh_agent_lib:: agent:: NamedPipeListener as Listener ;
12
- use ssh_agent_lib:: agent:: Session ;
12
+ use ssh_agent_lib:: agent:: { ListeningSocket , Session } ;
13
13
use ssh_agent_lib:: error:: AgentError ;
14
14
use ssh_agent_lib:: proto:: extension:: { QueryResponse , RestrictDestination , SessionBind } ;
15
15
use ssh_agent_lib:: proto:: {
@@ -238,7 +238,10 @@ impl KeyStorageAgent {
238
238
}
239
239
240
240
impl Agent for KeyStorageAgent {
241
- fn new_session ( & mut self ) -> impl Session {
241
+ fn new_session < S > ( & mut self , _socket : & S :: Stream ) -> impl Session
242
+ where
243
+ S : ListeningSocket + std:: fmt:: Debug + Send ,
244
+ {
242
245
KeyStorage {
243
246
identities : Arc :: clone ( & self . identities ) ,
244
247
}
Original file line number Diff line number Diff line change @@ -253,7 +253,9 @@ where
253
253
#[ async_trait]
254
254
pub trait Agent : ' static + Sync + Send + Sized {
255
255
/// Create new session object when a new socket is accepted.
256
- fn new_session ( & mut self ) -> impl Session ;
256
+ fn new_session < S > ( & mut self , socket : & S :: Stream ) -> impl Session
257
+ where
258
+ S : ListeningSocket + fmt:: Debug + Send ;
257
259
258
260
/// Listen on a socket waiting for client connections.
259
261
async fn listen < S > ( mut self , mut socket : S ) -> Result < ( ) , AgentError >
@@ -264,7 +266,7 @@ pub trait Agent: 'static + Sync + Send + Sized {
264
266
loop {
265
267
match socket. accept ( ) . await {
266
268
Ok ( socket) => {
267
- let session = self . new_session ( ) ;
269
+ let session = self . new_session :: < S > ( & socket ) ;
268
270
tokio:: spawn ( async move {
269
271
let adapter = Framed :: new ( socket, Codec :: < Request , Response > :: default ( ) ) ;
270
272
if let Err ( e) = handle_socket :: < S > ( session, adapter) . await {
@@ -306,7 +308,10 @@ impl<T> Agent for T
306
308
where
307
309
T : Default + Session ,
308
310
{
309
- fn new_session ( & mut self ) -> impl Session {
311
+ fn new_session < S > ( & mut self , _socket : & S :: Stream ) -> impl Session
312
+ where
313
+ S : ListeningSocket + fmt:: Debug + Send ,
314
+ {
310
315
Self :: default ( )
311
316
}
312
317
}
You can’t perform that action at this time.
0 commit comments