File tree Expand file tree Collapse file tree 7 files changed +21
-14
lines changed Expand file tree Collapse file tree 7 files changed +21
-14
lines changed Original file line number Diff line number Diff line change 960960 fn test_decode_encode_symmetry ( key : & str ) {
961961 let original_key_bytes = data_encoding:: BASE64_MIME
962962 . decode (
963- & key. lines ( )
963+ key. lines ( )
964964 . filter ( |line| !line. starts_with ( "-----" ) )
965965 . collect :: < Vec < & str > > ( )
966966 . join ( "" )
@@ -1013,7 +1013,7 @@ ocyR
10131013 sig. extend_ssh_string ( & [ 0 ] ) ;
10141014 sig. extend_ssh_string ( & [ 0 ] ) ;
10151015 let public = key. clone_public_key ( ) . unwrap ( ) ;
1016- assert_eq ! ( false , public. verify_detached( buf, & sig) ) ;
1016+ assert ! ( ! public. verify_detached( buf, & sig) ) ;
10171017 }
10181018 }
10191019
@@ -1369,12 +1369,9 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13691369 let ( _, buf) = client. sign_request ( & public, buf) . await ;
13701370 let buf = buf?;
13711371 let ( a, b) = buf. split_at ( len) ;
1372- match key {
1373- key:: KeyPair :: Ed25519 { .. } => {
1374- let sig = & b[ b. len ( ) - 64 ..] ;
1375- assert ! ( public. verify_detached( a, sig) ) ;
1376- }
1377- _ => { }
1372+ if let key:: KeyPair :: Ed25519 { .. } = key {
1373+ let sig = & b[ b. len ( ) - 64 ..] ;
1374+ assert ! ( public. verify_detached( a, sig) ) ;
13781375 }
13791376 Ok :: < ( ) , Error > ( ( ) )
13801377 } )
Original file line number Diff line number Diff line change @@ -52,11 +52,14 @@ impl server::Server for Server {
5252 self . id += 1 ;
5353 s
5454 }
55+ fn handle_session_error ( & mut self , _error : <Self :: Handler as russh:: server:: Handler >:: Error ) {
56+ eprintln ! ( "Session error: {:#?}" , _error) ;
57+ }
5558}
5659
5760#[ async_trait]
5861impl server:: Handler for Server {
59- type Error = anyhow :: Error ;
62+ type Error = russh :: Error ;
6063
6164 async fn channel_open_session (
6265 & mut self ,
@@ -84,6 +87,11 @@ impl server::Handler for Server {
8487 data : & [ u8 ] ,
8588 session : & mut Session ,
8689 ) -> Result < ( ) , Self :: Error > {
90+ // Sending Ctrl+C ends the session and disconnects the client
91+ if data == [ 3 ] {
92+ return Err ( russh:: Error :: Disconnect ) ;
93+ }
94+
8795 let data = CryptoVec :: from ( format ! ( "Got data: {}\r \n " , String :: from_utf8_lossy( data) ) ) ;
8896 self . post ( data. clone ( ) ) . await ;
8997 session. data ( channel, data) ;
Original file line number Diff line number Diff line change @@ -137,7 +137,9 @@ pub struct AuthRequest {
137137#[ derive( Debug ) ]
138138pub enum CurrentRequest {
139139 PublicKey {
140+ #[ allow( dead_code) ]
140141 key : CryptoVec ,
142+ #[ allow( dead_code) ]
141143 algo : CryptoVec ,
142144 sent_pk_ok : bool ,
143145 } ,
Original file line number Diff line number Diff line change @@ -208,10 +208,10 @@ pub(crate) trait SealingKey {
208208
209209 // Maximum packet length:
210210 // https://tools.ietf.org/html/rfc4253#section-6.1
211- assert ! ( packet_length <= std :: u32 :: MAX as usize ) ;
211+ assert ! ( packet_length <= u32 :: MAX as usize ) ;
212212 buffer. buffer . push_u32_be ( packet_length as u32 ) ;
213213
214- assert ! ( padding_length <= std :: u8 :: MAX as usize ) ;
214+ assert ! ( padding_length <= u8 :: MAX as usize ) ;
215215 buffer. buffer . push ( padding_length as u8 ) ;
216216 buffer. buffer . extend ( payload) ;
217217 self . fill_padding ( buffer. buffer . resize_mut ( padding_length) ) ;
Original file line number Diff line number Diff line change @@ -300,7 +300,7 @@ impl<H: Handler> Handle<H> {
300300 /// complete Keyboard-Interactive based SSH authentication.
301301 ///
302302 /// * `responses` - The responses to each prompt. The number of responses must match the number
303- /// of prompts. If a prompt has an empty string, then the response should be an empty string.
303+ /// of prompts. If a prompt has an empty string, then the response should be an empty string.
304304 pub async fn authenticate_keyboard_interactive_respond (
305305 & mut self ,
306306 responses : Vec < String > ,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ impl SshId {
3030 pub ( crate ) fn as_kex_hash_bytes ( & self ) -> & [ u8 ] {
3131 match self {
3232 Self :: Standard ( s) => s. as_bytes ( ) ,
33- Self :: Raw ( s) => s. trim_end_matches ( |c| c == '\n' || c == '\r' ) . as_bytes ( ) ,
33+ Self :: Raw ( s) => s. trim_end_matches ( [ '\n' , '\r' ] ) . as_bytes ( ) ,
3434 }
3535 }
3636
Original file line number Diff line number Diff line change 11[toolchain ]
2- channel = " 1.76 .0"
2+ channel = " 1.81 .0"
You can’t perform that action at this time.
0 commit comments