About proxy - WeOnlyDo Discussion board

About proxy (wodSSHTunnel)

by wodSupport, Sunday, March 23, 2014, 00:19 (3899 days ago) @ Korcan

Hi. I am not sure if this is what you need, but I created small VB sample that on same PC demonstrates how to do it.

1st instance opens local port forwarding from port 8080 to server's 127.0.0.1:8080 (nothing yet there....) and connects

2nd instance opens remote port forwarding that listens on server's 127.0.0.1:8080 and redirects it to www.google.com port 80

So, when you open 127.0.0.1:8080 on first PC, request is forwarded on server's 127.0.0.1:8080, where 2nd instance is listening, which is forwarded to 2nd instance, which is forwarded to www.google.com

Can you try if this code works for you? Make sure in UserConnecting event to set Allow = true to allow the connection from 2nd instance.

Option Explicit
Dim WithEvents tunnel1 As wodTunnelCom
Dim WithEvents tunnel2 As wodTunnelCom

Private Sub Form_Load()
    Set tunnel2 = New wodTunnelCom
    tunnel2.Hostname = "your.host.com"
    tunnel2.Login = "xxx"
    tunnel2.Password = "xxx"
    tunnel2.Channels.Add(RemoteListen, "www.google.com", 80, "127.0.0.1", 8080).AutoStart = True
    tunnel2.Connect
    
    
    Set tunnel1 = New wodTunnelCom
    tunnel1.Hostname = "your.host.com"
    tunnel1.Login = "xxx"
    tunnel1.Password = "xxx"
    tunnel1.Channels.Add(LocalListen, "127.0.0.1", 8080, "127.0.0.1", 8080).AutoStart = True
    tunnel1.Connect
    
End Sub

Private Sub tunnel2_UserConnecting(ByVal Chan As wodSSHTunnelCOMLib.IChannel, ByVal Hostname As String, ByVal Port As Long, Allow As Boolean)
    Allow = True
End Sub

Complete thread: