Skip to content

Commit 981cf7b

Browse files
authored
Derive Debug where possible (#374)
1 parent e088945 commit 981cf7b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

russh/src/client/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ mod session;
8080
/// It is in charge of multiplexing and keeping track of various channels
8181
/// that may get opened and closed during the lifetime of an SSH session and
8282
/// allows sending messages to the server.
83+
#[derive(Debug)]
8384
pub struct Session {
8485
common: CommonSession<Arc<Config>>,
8586
receiver: Receiver<Msg>,

russh/src/server/mod.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ mod session;
5757
pub use self::session::*;
5858
mod encrypted;
5959

60-
#[derive(Debug)]
6160
/// Configuration of a server.
6261
pub struct Config {
6362
/// The server ID string sent at the beginning of the protocol.
@@ -120,6 +119,32 @@ impl Default for Config {
120119
}
121120
}
122121

122+
impl Debug for Config {
123+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
124+
// display everything except the private keys
125+
f.debug_struct("Config")
126+
.field("server_id", &self.server_id)
127+
.field("methods", &self.methods)
128+
.field("auth_banner", &self.auth_banner)
129+
.field("auth_rejection_time", &self.auth_rejection_time)
130+
.field(
131+
"auth_rejection_time_initial",
132+
&self.auth_rejection_time_initial,
133+
)
134+
.field("keys", &"***")
135+
.field("window_size", &self.window_size)
136+
.field("maximum_packet_size", &self.maximum_packet_size)
137+
.field("event_buffer_size", &self.event_buffer_size)
138+
.field("limits", &self.limits)
139+
.field("preferred", &self.preferred)
140+
.field("max_auth_attempts", &self.max_auth_attempts)
141+
.field("inactivity_timeout", &self.inactivity_timeout)
142+
.field("keepalive_interval", &self.keepalive_interval)
143+
.field("keepalive_max", &self.keepalive_max)
144+
.finish()
145+
}
146+
}
147+
123148
/// A client's response in a challenge-response authentication.
124149
///
125150
/// You should iterate it to get `&[u8]` response slices.

russh/src/server/session.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::kex::EXTENSION_SUPPORT_AS_CLIENT;
1515
use crate::msg;
1616

1717
/// A connected server session. This type is unique to a client.
18+
#[derive(Debug)]
1819
pub struct Session {
1920
pub(crate) common: CommonSession<Arc<Config>>,
2021
pub(crate) sender: Handle,
@@ -25,6 +26,7 @@ pub struct Session {
2526
pub(crate) channels: HashMap<ChannelId, ChannelRef>,
2627
pub(crate) open_global_requests: VecDeque<GlobalRequestResponse>,
2728
}
29+
2830
#[derive(Debug)]
2931
pub enum Msg {
3032
ChannelOpenAgent {
@@ -82,7 +84,7 @@ impl From<(ChannelId, ChannelMsg)> for Msg {
8284
}
8385
}
8486

85-
#[derive(Clone)]
87+
#[derive(Clone, Debug)]
8688
/// Handle to a session, used to send messages to a client outside of
8789
/// the request/response cycle.
8890
pub struct Handle {

russh/src/session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub(crate) struct Encrypted {
5353
pub compress_buffer: CryptoVec,
5454
}
5555

56+
#[derive(Debug)]
5657
pub(crate) struct CommonSession<Config> {
5758
pub auth_user: String,
5859
pub remote_sshid: Vec<u8>,
@@ -655,6 +656,7 @@ pub(crate) struct NewKeys {
655656
pub sent: bool,
656657
}
657658

659+
#[derive(Debug)]
658660
pub(crate) enum GlobalRequestResponse {
659661
/// request was for Keepalive, ignore result
660662
Keepalive,

0 commit comments

Comments
 (0)