EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Connecting through a proxy with TElSSHClient

Posted: 05/31/2011 19:21:29
by timn (Standard support level)
Joined: 06/29/2010
Posts: 7

Using C#, Blackbox 8.1, and VS 2008.
We are looking at adding proxy support for connecting through both SOCKS4/5 and HTTP connect proxy servers in our ssh client. In the help section you refer to TElSocket and also proxy support for the simpler libraries but no mention of TElSSHClient. I am unable to see how to proceed.

Is it possible to get access to this code for connecting through proxies?
What is the best way to do this?

This seems much easier in the simple ssh client, but that is not an option for us.

Thanks in advance,
Posted: 06/01/2011 00:45:14
by Ken Ivanov (Team)

Thank you for contacting us.

TElSSHClient is a low-level component with no built-in network support. It gets use of OnSend and OnReceive events and DataAvailable() method to exchange data with a network layer. This gives a sort of flexibility, allowing component user to use any networking library appropriate for their conditions. Particularly, you can use the TElSocket class for doing the network job for you, - and, for instance, the SophisticatedSSHClient sample uses .NET sockets for this. TElSocket includes built-in support for SOCKS and WebTunnel proxies. There is no sample code available at the moment, but the general idea can be expressed via the following statements:

1) TElSSHClient uses OnSend event to pass data [to be sent to the other side] to the network layer, and OnReceive event to get data from the network layer; OnReceive is *only* called in response to the call of the DataAvailable() method.

2) TElSocket implements a blocking socket and therefore in most real-life cases the <TElSSHClient, TElSocket> bundle must run in a dedicated thread. Schematically, the logic can be described in the below way (no error checking):

// SSH negotiation loop
while ((!SSHClient.Active) && (!m_Error))
if (m_Error) return;
// SSH session loop
while ((SSHClient.Active) && (!m_Error))

3) To enable proxy support, you only need to set up the socket object in an appropriate way. This should be done before calling the Connect() method. Please use the UseSocks and Socks* properties (or UseWebTunneling and WebTunnel* ones) to configure the proxy as needed.
Posted: 06/20/2011 19:27:33
by timn (Standard support level)
Joined: 06/29/2010
Posts: 7

Using SSB 8.2, .Net and VS2008.
I have just moved over to using the TElSocket with TElSSHClient.
I find my program gets stuck waiting for the socket.Receive(...) call to finish, meaning that the connection is unresponsive.

It also means that it only checks SSHClient.DataAvailiable() maybe once or twice a minute.

Can I get access to the OnReceive and OnSend event methods that you use for the simple ssh client? I would like to see where I am going wrong.

Posted: 06/20/2011 19:46:51
by Ken Ivanov (Team)

As you are a registered customer, you have access to the source code that corresponds to your package. The link to the source code distribution is available at the My Control Center section of the site.

As an option, you might wish to have a look at the sophisticated SSH sample installed along with the default SBB distribution (Samples\C#\SSHBlackbox\Client\SophisticatedSSHClient\). It illustrates the use of the OnSend/OnReceive/DataAvailable bundle.
Posted: 06/20/2011 20:15:19
by timn (Standard support level)
Joined: 06/29/2010
Posts: 7

I am currently using the SophisticatedSSHClient as a reference for my code (though a much earlier version).
Not sure how to modify it for the TElSocket library

For some reason I am unable to find the source code in the control center.
Could you point me in the right direction?

Thanks for the help,

Edit: Turns out I should try looking with my eyes... Found it

Edit2: Two seconds with the source and I find it...

My problem was that I was not checking CanReceive() on the socket, so it would call DataAvailable when it shouldn't. Thanks for the help.
Posted: 06/21/2011 05:43:57
by Ken Ivanov (Team)

Great, we are glad that your problem is solved now. Feel free to contact us if you need any further assistance.



Topic viewed 2016 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!