Skip to content

Commit

Permalink
Derive Debug where possible (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
qsantos authored Nov 17, 2024
1 parent e088945 commit 981cf7b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions russh/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod session;
/// It is in charge of multiplexing and keeping track of various channels
/// that may get opened and closed during the lifetime of an SSH session and
/// allows sending messages to the server.
#[derive(Debug)]
pub struct Session {
common: CommonSession<Arc<Config>>,
receiver: Receiver<Msg>,
Expand Down
27 changes: 26 additions & 1 deletion russh/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ mod session;
pub use self::session::*;
mod encrypted;

#[derive(Debug)]
/// Configuration of a server.
pub struct Config {
/// The server ID string sent at the beginning of the protocol.
Expand Down Expand Up @@ -120,6 +119,32 @@ impl Default for Config {
}
}

impl Debug for Config {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// display everything except the private keys
f.debug_struct("Config")
.field("server_id", &self.server_id)
.field("methods", &self.methods)
.field("auth_banner", &self.auth_banner)
.field("auth_rejection_time", &self.auth_rejection_time)
.field(
"auth_rejection_time_initial",
&self.auth_rejection_time_initial,
)
.field("keys", &"***")
.field("window_size", &self.window_size)
.field("maximum_packet_size", &self.maximum_packet_size)
.field("event_buffer_size", &self.event_buffer_size)
.field("limits", &self.limits)
.field("preferred", &self.preferred)
.field("max_auth_attempts", &self.max_auth_attempts)
.field("inactivity_timeout", &self.inactivity_timeout)
.field("keepalive_interval", &self.keepalive_interval)
.field("keepalive_max", &self.keepalive_max)
.finish()
}
}

/// A client's response in a challenge-response authentication.
///
/// You should iterate it to get `&[u8]` response slices.
Expand Down
4 changes: 3 additions & 1 deletion russh/src/server/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::kex::EXTENSION_SUPPORT_AS_CLIENT;
use crate::msg;

/// A connected server session. This type is unique to a client.
#[derive(Debug)]
pub struct Session {
pub(crate) common: CommonSession<Arc<Config>>,
pub(crate) sender: Handle,
Expand All @@ -25,6 +26,7 @@ pub struct Session {
pub(crate) channels: HashMap<ChannelId, ChannelRef>,
pub(crate) open_global_requests: VecDeque<GlobalRequestResponse>,
}

#[derive(Debug)]
pub enum Msg {
ChannelOpenAgent {
Expand Down Expand Up @@ -82,7 +84,7 @@ impl From<(ChannelId, ChannelMsg)> for Msg {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
/// Handle to a session, used to send messages to a client outside of
/// the request/response cycle.
pub struct Handle {
Expand Down
2 changes: 2 additions & 0 deletions russh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(crate) struct Encrypted {
pub compress_buffer: CryptoVec,
}

#[derive(Debug)]
pub(crate) struct CommonSession<Config> {
pub auth_user: String,
pub remote_sshid: Vec<u8>,
Expand Down Expand Up @@ -655,6 +656,7 @@ pub(crate) struct NewKeys {
pub sent: bool,
}

#[derive(Debug)]
pub(crate) enum GlobalRequestResponse {
/// request was for Keepalive, ignore result
Keepalive,
Expand Down

0 comments on commit 981cf7b

Please sign in to comment.