Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Debug where possible #374

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading