Chilkat VB.NET SshTunnel Class Reference

SshTunnel

A software API that makes it possible to create self-managed SSH tunnels in a background thread of an application. Each SSH tunnel object manages two background threads: a thread for accepting new connections, and a tunnel-pool thread for existing (running) SSH tunnels. This API eliminates the need for separate, standalone SSH tunnel processes (such as PUtty). Your application may use SSH tunneling on any computer where it's installed, without the need for additional SSH tunneling software/infrastructure.

Object Creation

(C#)
Chilkat.SshTunnel obj = new Chilkat.SshTunnel();
(VB.NET)
Dim obj As New Chilkat.SshTunnel()

Properties

AcceptThreadSessionLogPath As String

To be documented soon...

ConnectLog As String

Contains log text detailing the establishment of each SSH server connection. This log will continue to grow as new connections are accepted. This property may be cleared by setting it to an empty string.

ConnectTimeoutMs As Integer

Maximum number of milliseconds to wait when connecting to an SSH server. The default value is 10000 (i.e. 10 seconds).

DestHostname As String

The destination hostname or IP address (in dotted decimal notation) of the service (such as a database server). Data sent through the SSH tunnel is forwarded by the SSH server to this destination. Data received from the destination (by the SSH server) is forwarded back to the client through the SSH tunnel.

DestPort As Integer

The destination port of the service (such as a database server).

HttpProxyAuthMethod As String

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

HttpProxyHostname As String

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

HttpProxyPassword As String

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

HttpProxyPort As Integer

If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)

HttpProxyUsername As String

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

IsAccepting As Boolean (ReadOnly)

True if a background thread is running and accepting connections.

LastErrorHtml As String (ReadOnly)

Error information in HTML format for the last method called.

LastErrorText As String (ReadOnly)

Error information in plain-text format for the last method called.

LastErrorXml As String (ReadOnly)

Error information in XML format for the last method called.

ListenBindIpAddress As String

In most cases, this property does not need to be set. It is provided for cases where it is required to bind the listen socket to a specific IP address (usually for computers with multiple network interfaces or IP addresses). For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.

ListenPort As Integer (ReadOnly)

If a port number equal to 0 is passed to BeginAccepting, then this property will contain the actual allocated port number used. Otherwise it is equal to the port number passed to BeginAccepting, or 0 if BeginAccepting was never called.

MaxPacketSize As Integer

The maximum packet length to be used in the SSH transport protocol. The default value is 32768.

OutboundBindIpAddress As String

In most cases, this property does not need to be set. It is provided for cases where it is required to bind the socket that is to connect to the SSH server (in the background thread) to a specific IP address (usually for computers with multiple network interfaces or IP addresses). For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.

OutboundBindPort As Integer

Unless there is a specific requirement for binding to a specific port, leave this unset (at the default value of 0). (99.9% of all users should never need to set this property.)

SocksHostname As String

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

SocksPassword As String

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

SocksPort As Integer

The SOCKS4/SOCKS5 proxy port. The default value is 1080. This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).

SocksUsername As String

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

SocksVersion As Integer

SocksVersion May be set to one of the following integer values:

0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.

SshHostname As String

The SSH server's hostname or IP address (in dotted-decimal notation).

SshLogin As String

The SSH server login. Authentication is typically required to establish the SSH tunnel in the background thread.

SshPassword As String

The SSH server password.

SshPort As Integer

The SSH server's port. The default is 22, and this typically won't change.

TcpNoDelay As Boolean

Controls whether the TCP_NODELAY socket option is used for the underlying TCP/IP socket. The default value is False. Setting this property equal to True disables the Nagle algorithm and allows for better performance when small amounts of data are sent.

TunnelErrors As String (ReadOnly)

Contains the accumulated errors, if any, of the background thread.

TunnelThreadSessionLogPath As String

To be documented soon...

Methods

Function BeginAccepting(ByVal listenPort As Integer) As Boolean

Starts a background thread for listening on listenPort. A new SSH tunnel is created and managed for each accepted connection. SSH tunnels are managed in a 2nd background thread: the SSH tunnel pool thread.

BeginAccepting starts a background thread that creates a socket, binds to the port, and begins listening. If the bind fails (meaning something else may have already bound to the same port), then the background thread exits. You may check to see if BeginAccepting succeeds by waiting a short time (perhaps 50 millisec) and then examine the IsAccepting property. If it is False, then BeginAccepting failed.

Returns true for success, false for failure.

(VB.NET) SSH Tunnel for Database Connection (such as ADO, ODBC, etc.)

Function GetTunnelsXml() As String

Returns information about the current set of running SSH tunnels. This is a snapshot of the tunnels at a single point in time. The XML has this format:

<tunnels>
	<t>
		<uniqueId>...</uniqueId>
		<clientIp>...</clientIp>
		<clientPort>...</clientPort>
		<serverIp>...</serverIp>
		<serverPort>...</serverPort>
		<tunnelType>...</tunnelType>
		<login>...</login>
		<password>...</password>
	</t>
	<t>
	...
	</t>
	...
</tunnels>

Returns Nothing on failure

Function SaveLastError(ByVal filename As String) As Boolean

Saves the last error information to an XML formatted file.

Function SetSshAuthenticationKey(ByVal key As SshKey) As Boolean

Sets the key to be used for public-key SSH authentication. NOTE: The private key is required for authentication. The public-part of the key is installed on the server, and the client must present the private key.

Returns true for success, false for failure.

Function StopAccepting() As Boolean

Stops the listen background thread. It is possible to continue accepting connections by re-calling BeginAccepting.

Returns true for success, false for failure.

Function StopAllTunnels(ByVal maxWaitMs As Integer) As Boolean

Stops all currently running tunnels in the SSH tunnel pool background thread.

Returns true for success, false for failure.

Function UnlockComponent(ByVal unlockCode As String) As Boolean

Unlocks the component. This must be called once prior to calling any other method. A fully-functional 30-day trial is automatically started when an arbitrary string is passed to this method. For example, passing "Hello", or "abc123" will unlock the component for the 1st thirty days after the initial install.

Returns true for success, false for failure.