EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Simple port forwarding classes

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#22628
Posted: 11/23/2012 18:16:59
by Chen-song Qin (Standard support level)
Joined: 11/23/2012
Posts: 4

Hi, I'm evaluating the SecureBlackbox SSH client library for possible purchase, and I have a question about the TElSSHRemotePortForwarding and TElSSHLocalPortForwarding classes that allow you to have simple SSH connections. Is it possible to create multiple port forwardings within the same SSH session? (i.e. without calling Open and Close) From the properties, it seems each class is designed to only accept one set of IP/Port pairs, so do I have to use a more involved class like the Client to achieve this? Also, are there any samples of non-simple port-forwarding code?

Thank you for any information.
#22634
Posted: 11/26/2012 00:48:12
by Ken Ivanov (EldoS Corp.)

Hello Chen-song,

Thank you for your interest in SecureBlackbox.

You can create as many different forwardings within the same SSH session as you need. Please use the *Tunnel() methods (e.g. AddTunnel()), and Tunnels[] and TunnelCount properties to manage the multi-forwarding configuration.

The properties that you were apparently talking about (ForwardedHost, DestHost, DestPort etc.) are there for convenience and actually just map to the first tunnel's (Tunnels[0]) properties.
#22636
Posted: 11/26/2012 20:08:12
by Chen-song Qin (Standard support level)
Joined: 11/23/2012
Posts: 4

Thank you for the quick response.
I'm playing with the sample project for remote port forwarding, and I've tried modifying it to open an SSH session, then open multiple individual port forwardings. I'm running into a problem where if a session is already opened with the TElSSHRemotePortForwarding.Open() function, and then I try to add a tunnel then open it, the OnConnectionOpen() event for the new tunnel is never fired, and the new tunnel seems to not be opened successfully. Does the TElSSHRemotePortForwarding class actually allow this operation? i.e. Open an SSH session, then add and remove tunnels while the SSH session is open, and open and close those tunnels inside the same SSH session?

Quote
Innokentiy Ivanov wrote:
Hello Chen-song,

Thank you for your interest in SecureBlackbox.

You can create as many different forwardings within the same SSH session as you need. Please use the *Tunnel() methods (e.g. AddTunnel()), and Tunnels[] and TunnelCount properties to manage the multi-forwarding configuration.

The properties that you were apparently talking about (ForwardedHost, DestHost, DestPort etc.) are there for convenience and actually just map to the first tunnel's (Tunnels[0]) properties.
#22637
Posted: 11/26/2012 23:37:50
by Ken Ivanov (EldoS Corp.)

Chen-song,

1) Please check that you are doing all of the below when opening the tunnel:
- adding the tunnel to the forwarding component via the AddTunnel() method;
- setting the tunnel's ForwardedPort, DestHost and DestPort properties (ForwardedHost is optional);
- calling the tunnel's Open() method.

2) OnConnectionOpen is invoked if a logical connection is opened *within an established tunnel* (i.e. when a third-party software connects to the opened server-side port). Use OnTunnelOpen to track opening of the tunnel.
#22638
Posted: 11/27/2012 00:52:41
by Chen-song Qin (Standard support level)
Joined: 11/23/2012
Posts: 4

Thank you for the clarification on OnConnectionOpen() versus OnTunnelOpen().

I do have all the steps completed from item 1). In fact, I've gotten things to work when all calls are made in the same function. If I open the session, then add a tunnel, set its addresses and ports, and open it, the connection will open correctly - for example, I can telnet to the forwarded address without any problems.

However, this is only when all operations are done in the same function. I've tried changing the sample project to only open the session, with no tunnel host/port values set, when the Start button is clicked. Then I added another button to start a port forward operation by adding the tunnel, etc., in its button click handler. If I click the button to open the session, I can see that the overall session Open event handler is called. If I click the port forward button after that event, nothing else happens. The port doesn't seem to be forwarded, and I can't telnet to the forwarded address. It looks like the behaviour is different when both the session and the tunnel are opened in the same function (the tunnel open call happens before the overall Open event?) than when the session is opened by one button's click handler, and the tunnel is opened by another button's click handler. Any clarification on this behaviour difference would be greatly appreciated.
#22639
Posted: 11/27/2012 01:01:31
by Ken Ivanov (EldoS Corp.)

Could you send us the modified sample application please? I have created a Helpdesk ticket for you, please upload the sample there and our engineers will have a look into it.
#22646
Posted: 11/27/2012 14:44:38
by Chen-song Qin (Standard support level)
Joined: 11/23/2012
Posts: 4

Thanks again for the quick response; we have identified the problem we had, and there is no defect so the Helpdesk ticket can be closed.
Just FYI, for anyone reading this thread… we had been using netstat to monitor sockets and had expected to see a socket open to our remote port forwarding destination after the tunnel open event and we weren’t seeing one. We didn’t realize that server side port is listening but doesn’t actually open a socket to the destination until something connections to the server side port.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 923 times

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




|

Back to top

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

Got it!