the clueless rename

This commit is contained in:
nora 2024-08-24 00:51:47 +02:00
parent ea28daca0c
commit 9ce60280b1
46 changed files with 264 additions and 262 deletions

View file

@ -1,10 +1,10 @@
[package]
name = "ssh-agent-client"
name = "cluelessh-agent-client"
version = "0.1.0"
edition = "2021"
[dependencies]
eyre = "0.6.12"
ssh-transport = { path = "../ssh-transport" }
cluelessh-transport = { path = "../cluelessh-transport" }
tokio = { version = "1.39.3", features = ["net"] }
tracing.workspace = true

View file

@ -1,5 +1,5 @@
use eyre::{bail, eyre, Context};
use ssh_transport::{
use cluelessh_transport::{
packet::PacketParser,
parse::{Parser, Writer},
SshStatus,

View file

@ -1,10 +1,10 @@
[package]
name = "ssh-connection"
name = "cluelessh-connection"
version = "0.1.0"
edition = "2021"
[dependencies]
ssh-transport = { path = "../ssh-transport" }
cluelessh-transport = { path = "../cluelessh-transport" }
tracing.workspace = true
[dev-dependencies]

View file

@ -1,4 +1,4 @@
# ssh-connection
# cluelessh-connection
Connection layer for SSH. This crate takes care of channel multiplexing.

View file

@ -2,9 +2,9 @@ use std::cmp;
use std::collections::{HashMap, VecDeque};
use tracing::{debug, info, trace, warn};
use ssh_transport::packet::Packet;
use ssh_transport::Result;
use ssh_transport::{numbers, peer_error};
use cluelessh_transport::packet::Packet;
use cluelessh_transport::Result;
use cluelessh_transport::{numbers, peer_error};
/// A channel number (on our side).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -728,7 +728,7 @@ impl ChannelOperation {
#[cfg(test)]
mod tests {
use ssh_transport::{numbers, packet::Packet};
use cluelessh_transport::{numbers, packet::Packet};
use crate::{ChannelNumber, ChannelOperation, ChannelOperationKind, ChannelsState};

View file

@ -1,5 +1,5 @@
[package]
name = "ssh-keys"
name = "cluelessh-keys"
version = "0.1.0"
edition = "2021"
@ -10,4 +10,4 @@ ctr = "0.9.2"
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
pem = "3.0.4"
rand = "0.8.5"
ssh-transport = { path = "../ssh-transport" }
cluelessh-transport = { path = "../cluelessh-transport" }

View file

@ -1,7 +1,7 @@
use std::str::FromStr;
use aes::cipher::{KeySizeUser, StreamCipher};
use ssh_transport::parse::{self, Parser, Writer};
use cluelessh_transport::parse::{self, Parser, Writer};
use crate::PrivateKeyType;

View file

@ -1,7 +1,7 @@
mod crypto;
use crypto::{Cipher, Kdf};
use ssh_transport::{
use cluelessh_transport::{
key::PublicKey,
parse::{self, Parser, Writer},
};

View file

@ -0,0 +1,11 @@
[package]
name = "cluelessh-protocol"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"
cluelessh-connection = { path = "../cluelessh-connection" }
cluelessh-transport = { path = "../cluelessh-transport" }
tracing.workspace = true

View file

@ -1,5 +1,5 @@
# ssh-protocol
# cluelessh-protocol
Combines `ssh-connection` and `ssh-transport` into a higher level interface.
Combines `cluelessh-connection` and `cluelessh-transport` into a higher level interface.
Also implements authentication based on [RFC 4252 The Secure Shell (SSH) Authentication Protocol](https://datatracker.ietf.org/doc/html/rfc4252).

View file

@ -1,10 +1,10 @@
use std::mem;
pub use ssh_connection as connection;
use ssh_connection::ChannelOperation;
pub use ssh_connection::{ChannelUpdate, ChannelUpdateKind};
pub use ssh_transport as transport;
pub use ssh_transport::{Result, SshStatus};
pub use cluelessh_connection as connection;
use cluelessh_connection::ChannelOperation;
pub use cluelessh_connection::{ChannelUpdate, ChannelUpdateKind};
pub use cluelessh_transport as transport;
pub use cluelessh_transport::{Result, SshStatus};
use tracing::debug;
pub struct ThreadRngRand;
@ -16,17 +16,17 @@ impl transport::SshRng for ThreadRngRand {
}
pub struct ServerConnection {
transport: ssh_transport::server::ServerConnection,
transport: cluelessh_transport::server::ServerConnection,
state: ServerConnectionState,
}
enum ServerConnectionState {
Auth(auth::BadAuth),
Open(ssh_connection::ChannelsState),
Open(cluelessh_connection::ChannelsState),
}
impl ServerConnection {
pub fn new(transport: ssh_transport::server::ServerConnection) -> Self {
pub fn new(transport: cluelessh_transport::server::ServerConnection) -> Self {
Self {
transport,
state: ServerConnectionState::Auth(auth::BadAuth::new()),
@ -45,7 +45,7 @@ impl ServerConnection {
}
if auth.is_authenticated() {
self.state =
ServerConnectionState::Open(ssh_connection::ChannelsState::new(true));
ServerConnectionState::Open(cluelessh_connection::ChannelsState::new(true));
}
}
ServerConnectionState::Open(con) => {
@ -59,11 +59,11 @@ impl ServerConnection {
Ok(())
}
pub fn next_msg_to_send(&mut self) -> Option<ssh_transport::Msg> {
pub fn next_msg_to_send(&mut self) -> Option<cluelessh_transport::Msg> {
self.transport.next_msg_to_send()
}
pub fn next_channel_update(&mut self) -> Option<ssh_connection::ChannelUpdate> {
pub fn next_channel_update(&mut self) -> Option<cluelessh_connection::ChannelUpdate> {
match &mut self.state {
ServerConnectionState::Auth(_) => None,
ServerConnectionState::Open(con) => con.next_channel_update(),
@ -97,18 +97,18 @@ impl ServerConnection {
}
pub struct ClientConnection {
transport: ssh_transport::client::ClientConnection,
transport: cluelessh_transport::client::ClientConnection,
state: ClientConnectionState,
}
enum ClientConnectionState {
Setup(Option<auth::ClientAuth>),
Auth(auth::ClientAuth),
Open(ssh_connection::ChannelsState),
Open(cluelessh_connection::ChannelsState),
}
impl ClientConnection {
pub fn new(transport: ssh_transport::client::ClientConnection, auth: auth::ClientAuth) -> Self {
pub fn new(transport: cluelessh_transport::client::ClientConnection, auth: auth::ClientAuth) -> Self {
Self {
transport,
state: ClientConnectionState::Setup(Some(auth)),
@ -140,7 +140,7 @@ impl ClientConnection {
}
if auth.is_authenticated() {
self.state =
ClientConnectionState::Open(ssh_connection::ChannelsState::new(false));
ClientConnectionState::Open(cluelessh_connection::ChannelsState::new(false));
}
}
ClientConnectionState::Open(con) => {
@ -162,7 +162,7 @@ impl ClientConnection {
}
}
pub fn channels(&mut self) -> Option<&mut ssh_connection::ChannelsState> {
pub fn channels(&mut self) -> Option<&mut cluelessh_connection::ChannelsState> {
match &mut self.state {
ClientConnectionState::Open(channels) => Some(channels),
_ => None,
@ -173,11 +173,11 @@ impl ClientConnection {
matches!(self.state, ClientConnectionState::Open(_))
}
pub fn next_msg_to_send(&mut self) -> Option<ssh_transport::Msg> {
pub fn next_msg_to_send(&mut self) -> Option<cluelessh_transport::Msg> {
self.transport.next_msg_to_send()
}
pub fn next_channel_update(&mut self) -> Option<ssh_connection::ChannelUpdate> {
pub fn next_channel_update(&mut self) -> Option<cluelessh_connection::ChannelUpdate> {
match &mut self.state {
ClientConnectionState::Setup(_) => None,
ClientConnectionState::Auth(_) => None,
@ -218,7 +218,7 @@ impl ClientConnection {
pub mod auth {
use std::collections::VecDeque;
use ssh_transport::{numbers, packet::Packet, parse::NameList, peer_error, Result};
use cluelessh_transport::{numbers, packet::Packet, parse::NameList, peer_error, Result};
use tracing::{debug, info};
pub struct BadAuth {

View file

@ -0,0 +1,13 @@
[package]
name = "cluelessh-tokio"
version = "0.1.0"
edition = "2021"
[dependencies]
eyre = "0.6.12"
cluelessh-transport = { path = "../cluelessh-transport" }
cluelessh-connection = { path = "../cluelessh-connection" }
cluelessh-protocol = { path = "../cluelessh-protocol" }
tokio = { version = "1.39.3", features = ["net"] }
tracing.workspace = true
futures = "0.3.30"

View file

@ -1,10 +1,10 @@
use ssh_connection::{ChannelNumber, ChannelOpen, ChannelOperation, ChannelOperationKind};
use cluelessh_connection::{ChannelNumber, ChannelOpen, ChannelOperation, ChannelOperationKind};
use std::{collections::HashMap, pin::Pin, sync::Arc};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use eyre::{bail, ContextCompat, OptionExt, Result, WrapErr};
use futures::future::BoxFuture;
use ssh_protocol::{ChannelUpdateKind, SshStatus};
use cluelessh_protocol::{ChannelUpdateKind, SshStatus};
use tokio::io::{AsyncRead, AsyncWrite};
use tracing::{debug, info, warn};
@ -12,7 +12,7 @@ pub struct ClientConnection<S> {
stream: Pin<Box<S>>,
buf: [u8; 1024],
proto: ssh_protocol::ClientConnection,
proto: cluelessh_protocol::ClientConnection,
operations_send: tokio::sync::mpsc::Sender<Operation>,
operations_recv: tokio::sync::mpsc::Receiver<Operation>,
@ -74,9 +74,9 @@ impl<S: AsyncRead + AsyncWrite> ClientConnection<S> {
channel_ops_send,
channel_ops_recv,
channels: HashMap::new(),
proto: ssh_protocol::ClientConnection::new(
ssh_transport::client::ClientConnection::new(ssh_protocol::ThreadRngRand),
ssh_protocol::auth::ClientAuth::new(auth.username.as_bytes().to_vec()),
proto: cluelessh_protocol::ClientConnection::new(
cluelessh_transport::client::ClientConnection::new(cluelessh_protocol::ThreadRngRand),
cluelessh_protocol::auth::ClientAuth::new(auth.username.as_bytes().to_vec()),
),
auth,
};
@ -94,7 +94,7 @@ impl<S: AsyncRead + AsyncWrite> ClientConnection<S> {
if let Some(auth) = self.proto.auth() {
for req in auth.user_requests() {
match req {
ssh_protocol::auth::ClientUserRequest::Password => {
cluelessh_protocol::auth::ClientUserRequest::Password => {
let send = self.operations_send.clone();
let prompt_password = self.auth.prompt_password.clone();
tokio::spawn(async move {
@ -102,7 +102,7 @@ impl<S: AsyncRead + AsyncWrite> ClientConnection<S> {
let _ = send.send(Operation::PasswordEntered(password)).await;
});
}
ssh_protocol::auth::ClientUserRequest::PrivateKeySign {
cluelessh_protocol::auth::ClientUserRequest::PrivateKeySign {
session_identifier,
} => {
let send = self.operations_send.clone();
@ -112,7 +112,7 @@ impl<S: AsyncRead + AsyncWrite> ClientConnection<S> {
let _ = send.send(Operation::Signature(signature_result)).await;
});
}
ssh_protocol::auth::ClientUserRequest::Banner(_) => {
cluelessh_protocol::auth::ClientUserRequest::Banner(_) => {
warn!("ignoring banner as it's not implemented...");
}
}

View file

@ -1,5 +1,5 @@
[package]
name = "ssh-transport"
name = "cluelessh-transport"
version = "0.1.0"
edition = "2021"

View file

@ -1,4 +1,4 @@
# ssh-transport
# cluelessh-transport
Transport layer of SSH.

View file

@ -1,11 +0,0 @@
[package]
name = "ssh-protocol"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"
ssh-connection = { path = "../ssh-connection" }
ssh-transport = { path = "../ssh-transport" }
tracing.workspace = true

View file

@ -1,13 +0,0 @@
[package]
name = "ssh-tokio"
version = "0.1.0"
edition = "2021"
[dependencies]
eyre = "0.6.12"
ssh-transport = { path = "../ssh-transport" }
ssh-connection = { path = "../ssh-connection" }
ssh-protocol = { path = "../ssh-protocol" }
tokio = { version = "1.39.3", features = ["net"] }
tracing.workspace = true
futures = "0.3.30"