diff --git a/russh-keys/src/lib.rs b/russh-keys/src/lib.rs index 25e65ee9..f7b82b7c 100644 --- a/russh-keys/src/lib.rs +++ b/russh-keys/src/lib.rs @@ -960,7 +960,7 @@ ocyR fn test_decode_encode_symmetry(key: &str) { let original_key_bytes = data_encoding::BASE64_MIME .decode( - &key.lines() + key.lines() .filter(|line| !line.starts_with("-----")) .collect::>() .join("") @@ -1013,7 +1013,7 @@ ocyR sig.extend_ssh_string(&[0]); sig.extend_ssh_string(&[0]); let public = key.clone_public_key().unwrap(); - assert_eq!(false, public.verify_detached(buf, &sig)); + assert!(!public.verify_detached(buf, &sig)); } } @@ -1369,12 +1369,9 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux let (_, buf) = client.sign_request(&public, buf).await; let buf = buf?; let (a, b) = buf.split_at(len); - match key { - key::KeyPair::Ed25519 { .. } => { - let sig = &b[b.len() - 64..]; - assert!(public.verify_detached(a, sig)); - } - _ => {} + if let key::KeyPair::Ed25519 { .. } = key { + let sig = &b[b.len() - 64..]; + assert!(public.verify_detached(a, sig)); } Ok::<(), Error>(()) }) diff --git a/russh/examples/echoserver.rs b/russh/examples/echoserver.rs index 96627af4..0198c845 100644 --- a/russh/examples/echoserver.rs +++ b/russh/examples/echoserver.rs @@ -52,11 +52,14 @@ impl server::Server for Server { self.id += 1; s } + fn handle_session_error(&mut self, _error: ::Error) { + eprintln!("Session error: {:#?}", _error); + } } #[async_trait] impl server::Handler for Server { - type Error = anyhow::Error; + type Error = russh::Error; async fn channel_open_session( &mut self, @@ -84,6 +87,11 @@ impl server::Handler for Server { data: &[u8], session: &mut Session, ) -> Result<(), Self::Error> { + // Sending Ctrl+C ends the session and disconnects the client + if data == [3] { + return Err(russh::Error::Disconnect); + } + let data = CryptoVec::from(format!("Got data: {}\r\n", String::from_utf8_lossy(data))); self.post(data.clone()).await; session.data(channel, data); diff --git a/russh/src/auth.rs b/russh/src/auth.rs index 0f3c3da6..649d5ccd 100644 --- a/russh/src/auth.rs +++ b/russh/src/auth.rs @@ -137,7 +137,9 @@ pub struct AuthRequest { #[derive(Debug)] pub enum CurrentRequest { PublicKey { + #[allow(dead_code)] key: CryptoVec, + #[allow(dead_code)] algo: CryptoVec, sent_pk_ok: bool, }, diff --git a/russh/src/cipher/mod.rs b/russh/src/cipher/mod.rs index a474c2da..76804e84 100644 --- a/russh/src/cipher/mod.rs +++ b/russh/src/cipher/mod.rs @@ -208,10 +208,10 @@ pub(crate) trait SealingKey { // Maximum packet length: // https://tools.ietf.org/html/rfc4253#section-6.1 - assert!(packet_length <= std::u32::MAX as usize); + assert!(packet_length <= u32::MAX as usize); buffer.buffer.push_u32_be(packet_length as u32); - assert!(padding_length <= std::u8::MAX as usize); + assert!(padding_length <= u8::MAX as usize); buffer.buffer.push(padding_length as u8); buffer.buffer.extend(payload); self.fill_padding(buffer.buffer.resize_mut(padding_length)); diff --git a/russh/src/client/mod.rs b/russh/src/client/mod.rs index 38ec04c5..daca7ed9 100644 --- a/russh/src/client/mod.rs +++ b/russh/src/client/mod.rs @@ -300,7 +300,7 @@ impl Handle { /// complete Keyboard-Interactive based SSH authentication. /// /// * `responses` - The responses to each prompt. The number of responses must match the number - /// of prompts. If a prompt has an empty string, then the response should be an empty string. + /// of prompts. If a prompt has an empty string, then the response should be an empty string. pub async fn authenticate_keyboard_interactive_respond( &mut self, responses: Vec, diff --git a/russh/src/sshbuffer.rs b/russh/src/sshbuffer.rs index a57b0982..04f5b568 100644 --- a/russh/src/sshbuffer.rs +++ b/russh/src/sshbuffer.rs @@ -30,7 +30,7 @@ impl SshId { pub(crate) fn as_kex_hash_bytes(&self) -> &[u8] { match self { Self::Standard(s) => s.as_bytes(), - Self::Raw(s) => s.trim_end_matches(|c| c == '\n' || c == '\r').as_bytes(), + Self::Raw(s) => s.trim_end_matches(['\n', '\r']).as_bytes(), } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 624eb0ea..1de01fa4 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.76.0" +channel = "1.81.0"