Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.SSH.Transport

Feature notes: SSH implementation notes

Classes, interfaces and records

classeSSHTransportError

inherits from Exception

(no public members)

classeSSHTransportRawError

inherits from eSSHTransportError

(no public members)

classeSSHUnimplemented

inherits from eSSHTransportError

constructor Create(aMsgNo: UInt32); property MsgNo: UInt32 read fMsgNo;

classeSSHDisconnect

inherits from eSSHTransportError

constructor Create(aErrorCode : UInt32; const aDescription: string; const aLanguageTag: string); property ErrorCode: UInt32 read fErrorCode; property Description: string read fDescription; property LanguageTag: string read fLanguageTag;

classeSSHIncomingDisconnect

inherits from eSSHDisconnect

(no public members)

classeSSHOutgoingDisconnect

inherits from eSSHDisconnect

(no public members)

classeSSHConnectionLost

inherits from eSSHDisconnect

The connection ended with no SSH_MSG_DISCONNECT read: the peer closed its end, or the connection was reset or aborted. ErrorCode is SSH_DISCONNECT_CONNECTION_LOST. The transport has closed its socket, as it does on reading a DISCONNECT.

(no public members)

interfaceiSSHTransportRawEvents

function RawAccept(aSocket: tSocket): tSocket; function RawConnect(aSocket: tSocket = 0): tSocket; procedure RawClose(aSocket: tSocket); function RawRecvLength(aSocket: tSocket): Integer;
How many octets can be read now. NEGATIVE: none, and the connection has ended (closed by the peer, reset, aborted) - the transport then closes the socket and raises eSSHConnectionLost. 0 only ever means "nothing yet": the transport polls it, and a connection that ended while it read 0 would be polled for ever.
function RawRecv(aSocket: tSocket; const aBuffer: tBytes; aOffset, aCount : Integer) : Integer; function RawSend(aSocket: tSocket; const aBuffer: tBytes; aOffset, aCount : Integer) : Integer;

interfaceiSSHTransport

(no public members)

interfaceiSSHTransportEvents

procedure ServerHelloString(const aStr: string); procedure Debug(aAlwaysDisplay: Boolean; const aMessage : string; const aLanguageTag : string); function ServiceRequest(const aServiceName: string; const aTransport : iSSHTransport): Boolean; procedure Unimplemented(aMsgNo: UInt32);

interfaceiSSHTransport

inherits from iTransport

function GetVersionClient: string; function GetVersionServer: string; function GetKexOptions: iSSHOptionList; function GetServerHostKeyOptions: iSSHOptionList; function GetEncryptionC2SOptions: iSSHOptionList; function GetEncryptionS2COptions: iSSHOptionList; function GetMacC2SOptions: iSSHOptionList; function GetMacS2COptions: iSSHOptionList; function GetCompressionC2SOptions: iSSHOptionList; function GetCompressionS2COptions: iSSHOptionList; function GetSessionID: tBytes; function GetUsername: string; function GetRequestedService: string; function GetRawEvents: iSSHTransportRawEvents; function GetSSHEvents: iSSHTransportEvents; procedure SetVersionClient(const Value: string); procedure SetVersionServer(const Value: string); procedure SetKexOptions(const Value: iSSHOptionList); procedure SetServerHostKeyOptions(const Value: iSSHOptionList); procedure SetEncryptionC2SOptions(const Value: iSSHOptionList); procedure SetEncryptionS2COptions(const Value: iSSHOptionList); procedure SetMacC2SOptions(const Value: iSSHOptionList); procedure SetMacS2COptions(const Value: iSSHOptionList); procedure SetCompressionC2SOptions(const Value: iSSHOptionList); procedure SetCompressionS2COptions(const Value: iSSHOptionList); procedure SetUsername(const Value: string); procedure SetRawEvents(const Value: iSSHTransportRawEvents); procedure SetSSHEvents(const Value: iSSHTransportEvents); procedure InitKeys(const aKeys: iSSHSymmetricKeys); function ReadMessage(const aAllowed: tByteSet; out aMsgCode: Byte; aInclTag: Boolean = False) : tBytes; overload; function ReadMessage(const aAllowed: tByteSet): Byte; overload; function PollMessage(const aAllowed: tByteSet; out aMsgCode: Byte; aInclTag: Boolean = False) : tBytes;
Reads as ReadMessage does, but never waits for a message to arrive: when none has, or each one that has is skipped (IGNORE, DEBUG, one answered with UNIMPLEMENTED), the result is empty. ReadMessage waits for the message after one it skips. A reader that holds the lock, which every Send takes, reads with this, so that its end can send while the peer sends nothing.
procedure ReadNewKeys; procedure Disconnect(aErrorCode: UInt32); procedure CreateLock; procedure FreeLock; procedure Lock; procedure Unlock; property VersionClient: string read GetVersionClient write SetVersionClient; property VersionServer: string read GetVersionServer write SetVersionServer; property KexOptions: iSSHOptionList read GetKexOptions write SetKexOptions; property ServerHostKeyOptions: iSSHOptionList read GetServerHostKeyOptions write SetServerHostKeyOptions; property EncryptionC2SOptions: iSSHOptionList read GetEncryptionC2SOptions write SetEncryptionC2SOptions; property EncryptionS2COptions: iSSHOptionList read GetEncryptionS2COptions write SetEncryptionS2COptions; property MacC2SOptions: iSSHOptionList read GetMacC2SOptions write SetMacC2SOptions; property MacS2COptions: iSSHOptionList read GetMacS2COptions write SetMacS2COptions; property CompressionC2SOptions: iSSHOptionList read GetCompressionC2SOptions write SetCompressionC2SOptions; property CompressionS2COptions: iSSHOptionList read GetCompressionS2COptions write SetCompressionS2COptions; property SessionID: tBytes read GetSessionID; property Username: string read GetUsername write SetUsername; property RequestedService: string read GetRequestedService; property RawEvents: iSSHTransportRawEvents read GetRawEvents write SetRawEvents; property SSHEvents: iSSHTransportEvents read GetSSHEvents write SetSSHEvents;

interfaceiSSHClientTransport

inherits from iSSHTransport

function RequestService(const aServiceName: string): Boolean;

interfaceiSSHServerTransport

inherits from iSSHTransport

function GetSocket: Cardinal; property Socket: Cardinal read GetSocket;

interfaceiSSHServerLogin

A server transport's login, from the connection being taken on until the client has logged in (TstCustomSSHServer.LoginGraceTime). tSSHServerTransport implements it, and the server asks a transport for it with Supports: a transport that does not implement it is waited on during the login as during the rest of the connection.

procedure BeginLogin(aGraceTime: Cardinal);
Between BeginLogin and EndLogin a wait for the client's next message ends the connection (SSH_MSG_DISCONNECT reason 10) once aGraceTime milliseconds have passed since BeginLogin, and not before; with aGraceTime 0 it waits for as long as it takes. Full description »
procedure EndLogin; function CancelLogin: Boolean;
Cancels a login under way. The thread that logs the client in ends the connection, with SSH_MSG_DISCONNECT reason 11 as Close does, the next time it reads or sends - at once while it waits for the client, otherwise when the step under way is done (checking a password or a key, or an event handler... Full description »

interfaceiSSHClientCall

A client transport's calls, which the calling thread makes without the transport's lock: those of TstCustomSSHClient.ConnectToHost, Login and RequestService. tSSHClientTransport implements it, and the client asks a transport for it with Supports.

Between BeginCall and EndCall the connection belongs to the thread that makes the call, so Close then does not close it but cancels the call, as CancelCall does. After EndCall, Close closes the connection again. A wait for the server's next message ends the connection after about 5 s without one, during a call as outside it.

procedure BeginCall;
Begins a call. Raises eSSHTransportError when one is under way already.
function EndCall: Boolean;
Ends the call. True when it was cancelled: the connection is then the calling thread's to end, as Close would end it - the transport has done so already if it read or sent after the cancellation.
function CancelCall: Boolean;
Cancels a call under way. The thread that makes it ends the connection, with SSH_MSG_DISCONNECT reason 11 as Close does, the next time it reads or sends - at once while it waits for the server, otherwise when the step under way is done (an event handler, such as OnSetKey or OnGetClientPassword) -... Full description »

interfaceiSSHLastActivity

function GetLastActivity: Cardinal; property LastActivity: Cardinal read GetLastActivity;

classtSSHTransport

inherits from tObjectMapping

implements iTransport, iSSHTransport, iSSHLastActivity

destructor Destroy; override;

classtSSHClientTransport

inherits from tSSHTransport

implements iSSHClientTransport, iSSHClientCall

constructor Create(const aRawEvents: iSSHTransportRawEvents; const aSocket : UInt32);

classtSSHServerTransport

inherits from tSSHTransport

implements iSSHServerTransport, iSSHServerLogin

constructor Create;

interfaceiSSHWindowedChannel

inherits from iTransport

An SSH channel. Its Send (iTransport.Send) passes the bytes to the peer as far as the peer's window allows, and returns how many it passed: aCount, or fewer when the window shut and stayed shut for about a second, or 0 when it was shut already. SendAllOnChannel below sends all of them.

function GetState: tChannelState; function GetRemoteWindowSize: Integer; function GetRemotePacketSize(const aPrefSize: Integer): Integer; property RemoteWindowSize: Integer read GetRemoteWindowSize; property State: tChannelState read GetState;

Types (enumerations, sets, aliases)

settByteSet

  tByteSet = set of Byte;

enumtChannelState

  tChannelState = (csClosed,csConnecting,csConnected,csClosing);

proctSSHRawSendStallProc

  tSSHRawSendStallProc = procedure of object;

Routines