How to obtain a valid IP-address?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
Paroxizm
Posts: 5
Joined: Wed 27 May 2009 22:36

How to obtain a valid IP-address?

Post by Paroxizm » Wed 21 Oct 2009 05:30

My server-application listens to a local address 127.0.0.1:3000

I add TScSSHServer and set it to listen to an external address 192.168.1.1:40000

In the client-application I add TScSSHChannel and create a tunnel from the local address 127.0.0.1:20000 to connect to the server-application

(I may have given incomplete descriptions of the actions, but everything works)

How can I determine the actual address of the connected client on the server side in the server-application (get 192.168.1.2 instead of 127.0.0.1:20000)

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 26 Oct 2009 10:39

Try to use the ClientInfo.SockAddr property in the TScSSHServer.AfterClientConnect event handler.

Paroxizm
Posts: 5
Joined: Wed 27 May 2009 22:36

Post by Paroxizm » Mon 26 Oct 2009 17:25

i'll rephrase my question:

== server side ==
i have server application, that contains several threads.

First thread after start creates TScSSHServer object, configured to listen external IP address (192.168.1.1:33000)

Second thread listen incoming connections on local address (127.0.0.1:22000)

Second thread on accepting execute client threads, that do all work i need

== client side ==
On client side i create TScSSHClient and connect it from local address (10.10.10.5:25000) to server address (192.168.1.1:33000). Then I create channel to (127.0.0.1:22000).

Now i creating main client thread, that do all work through created channel.

My question is how to at server side in second thread (or produced client thread) get client address (10.10.10.5:25000).

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 27 Oct 2009 13:03

SSH protocol doesn't allow to get this client address on server side. You can do it on client side by processing the TScSSHChannel.OnSocketConnect event handler.

Paroxizm
Posts: 5
Joined: Wed 27 May 2009 22:36

Post by Paroxizm » Tue 27 Oct 2009 15:55

Dimon wrote:SSH protocol doesn't allow to get this client address on server side.
SSH protocol - Yes, but in my case all server threads owned by one process, so (in theory) I can get access to any TScSSHChannel and get its info. And only question is what criteria can i use to check is my connection transferred with selected channel or not.
Dimon wrote: You can do it on client side by processing the TScSSHChannel.OnSocketConnect event handler.
In my case

Code: Select all

MessageBox(0, inet_ntoa(SockAddr.sin_addr), '', 0);
returns '127.0.0.1'

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 28 Oct 2009 10:13

Paroxizm wrote:SSH protocol - Yes, but in my case all server threads owned by one process, so (in theory) I can get access to any TScSSHChannel and get its info. And only question is what criteria can i use to check is my connection transferred with selected channel or not.
If you use one process try to use the TScSSHChannel.OnSocketConnect and the TScSSHServer.BeforeChannelConnect event handlers interactively with mutex.
Paroxizm wrote:
Dimon wrote:You can do it on client side by processing the TScSSHChannel.OnSocketConnect event handler.
In my case

Code: Select all

MessageBox(0, inet_ntoa(SockAddr.sin_addr), '', 0);
returns '127.0.0.1'
To solve this problem you should specify full computer name, but not "localhost" when you connect to TScSSHChannel tunnel. Also you should set the TScSSHChannel.GatewayPorts property to True.

Post Reply