Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Ssh

 

class Ssh

This is the base class of SSH2 session and channel related classes. It provides support for time-constrained or blocking operations, polymorphism, RTTI, error management, and logging.

 

Public Method List

 

operator bool() const

Tests whether the object is picked (moved).

 


 

Event<> WhenWait

If this event is defined, it is invoked periodically while the ssh client performs any socket operations, with the default frequency of 100Hz. This is intended to give user feedback in interactive applications. Each ssh object can have a separate WhenWait call. But when left undefined, calls to this method will be redirected to the object's session's WhenWait callback.

 


 

Ssh& WaitStep(int ms)

Sets the periodicity of calling WhenWait in millisecond between calls. Default value is 10ms (100hz). Returns *this for method chaining. Note that ssh subsystems and channels inherit their default waitstep values from their session.

 


 

int GetWaitStep() const

Returns current periodicity of calling WhenWait.

 


 

int GetTimeout() const

Returns the timeout value.

 


 

void Abort()

Aborts the current operation.

 


 

bool InProgress() const

Returns true if a command or data transfer is currently in progress.

 


 

bool IsError() const

Returns true if there was an error.

 


 

int GetError() const

Returns the last error code, if any.

 


 

String GetErrorDesc() const

Returns the last error message, if any.

 


 

int64 GetId() const

Returns the unique id of the object. Each ssh object is assigned a unique id on construction.

 


 

int GetType() const

Returns the ssh object type identifier. Currently it can be one of the following: SESSION, SFTP, SCP, CHANNEL, EXEC, SHELL

 


 

template <class TT& To()

Converts the ssh object to T. T can be one of the Ssh-based classes. Returns a reference to T on success.

 


 

template <class Tbool Is() const

Tests whether the ssh-based object is of type T

 


 

static void Trace(bool b = true)

Enables or disables logging.

 


 

static void TraceVerbose(int level)

Enables or disables verbose logging. This method allows full-level logging of libssh2 diagnostic messages if LIBSSH2TRACE flag is defined. It automatically calls Trace() method. Log level(s) can be selected using one or a combination of the following constants:

 

libssh2 Log Levels

Constant

Level

LIBSSH2_TRACE_SOCKET

Socket layer (low-level)

LIBSSH2_TRACE_TRANS

Transport layer

LIBSSH2_TRACE_KEX

Key exchange layer

LIBSSH2_TRACE_AUTH

Authentication layer

LIBSSH2_TRACE_CONN

Connection layer

LIBSSH2_TRACE_SCP

Secure copy protocol

LIBSSH2_TRACE_SFTP

Secure file transfer protocol

LIBSSH2_TRACE_ERROR

Error messages

LIBSSH2_TRACE_PUBLICKEY

Public key encryption layer

0

Disables logging

 

 

Constructor detail

 

Ssh()

Default constructor.

 

 

Ssh::Error

 

struct Error : public Exc

Type used as Ssh exception. This helper is internally used by the Ssh-based classes, but can also be used externally by client code to halt jobs, and report errors (e.g. in worker threads).

 


 

int code

Error code returned by the halted job.

 


 

Error()

Default constructor. Sets the error code to -1, and error message to Null.

 


 

Error(const String& reason)

Constructor overload. Sets error code to -1, and error message to reason .

 


 

Error(int rc, const String& reason)

Constructor overload. Sets error code to rc and error message to reason .

 

 

Do you want to contribute?