summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Harris <harmic@gmail.com>2021-02-02 03:58:47 +1100
committerGitHub <noreply@github.com>2021-02-01 16:58:47 +0000
commit459296d0e21fbbfd77a60a8341194e5c39a66d6f (patch)
tree8e80ceedede29c28af819fe18bb2a2e15879c657 /src
parent1fcf8d38d401b230561863d1e40fd41d76e8601c (diff)
downloadssh2-rs-459296d0e21fbbfd77a60a8341194e5c39a66d6f.zip
Expose libssh2_trace function (#209)
* Expose libssh2_trace function and associated constants, to allow enabling libssh2 trace output. * set LIBSSH2_WIN32 on windows build so that gettimeofday replacement will be compiled. * libssh2_trace actually returns int, even though the documentation says it returns void. This was causing systest to fail. Changed the FFI to match the C function. Co-authored-by: eharmic <michael.harris@ericsson.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs2
-rw-r--r--src/session.rs32
2 files changed, 33 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 47467c7..45f8e6b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -233,7 +233,7 @@ pub use error::{Error, ErrorCode};
pub use knownhosts::{Host, KnownHosts};
pub use listener::Listener;
use session::SessionInner;
-pub use session::{BlockDirections, KeyboardInteractivePrompt, Prompt, ScpFileStat, Session};
+pub use session::{BlockDirections, KeyboardInteractivePrompt, Prompt, ScpFileStat, Session, TraceFlags};
pub use sftp::{File, FileStat, FileType, OpenType};
pub use sftp::{OpenFlags, RenameFlags, Sftp};
pub use DisconnectCode::{AuthCancelledByUser, TooManyConnections};
diff --git a/src/session.rs b/src/session.rs
index 33bb619..a1fa674 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -18,6 +18,31 @@ use util;
use {raw, ByApplication, DisconnectCode, Error, ErrorCode, HostKeyType};
use {Agent, Channel, HashType, KnownHosts, Listener, MethodType, Sftp};
+bitflags! {
+ /// Flags which can be used with the session trace method to set
+ /// the trace level.
+ pub struct TraceFlags: c_int {
+ /// Authentication debugging
+ const AUTH = raw::LIBSSH2_TRACE_AUTH;
+ /// Connection layer debugging
+ const CONN = raw::LIBSSH2_TRACE_CONN;
+ /// Error debugging
+ const ERROR = raw::LIBSSH2_TRACE_ERROR;
+ /// Key exchange debugging
+ const KEX = raw::LIBSSH2_TRACE_KEX;
+ /// Public Key Debugging
+ const PUBLICKEY = raw::LIBSSH2_TRACE_PUBLICKEY;
+ /// SCP debugging
+ const SCP = raw::LIBSSH2_TRACE_SCP;
+ /// SFTP debugging
+ const SFTP = raw::LIBSSH2_TRACE_SFTP;
+ /// Socket low-level debugging
+ const SOCKET = raw::LIBSSH2_TRACE_SOCKET;
+ /// Transport layer debugging
+ const TRANS = raw::LIBSSH2_TRACE_TRANS;
+ }
+}
+
/// Called by libssh2 to respond to some number of challenges as part of
/// keyboard interactive authentication.
pub trait KeyboardInteractivePrompt {
@@ -1002,6 +1027,13 @@ impl Session {
fn inner(&self) -> MutexGuard<SessionInner> {
self.inner.lock()
}
+
+ /// Sets the trace level for the session.
+ ///
+ pub fn trace(&self, bitmask: TraceFlags) {
+ let inner = self.inner();
+ unsafe { let _ = raw::libssh2_trace(inner.raw, bitmask.bits() as c_int); }
+ }
}
#[cfg(unix)]