New class for SSH tunnel

As you may have seen, we got SSH tunnel function for Xojo to run a SSH tunnel from within your application. That works nice, if you like to connect and provide data right in the app. But it does not help if some other class needs to connect.

Our new SSH2TunnelMBS class allows you to create a tunnel and run it on a preemptive thread in the background. This way we can forward a connection for use with a database to the target server. You can use our SQLConnectionMBS or SQLDatabaseMBS classes to connect to MySQL, PostgreSQL, Oracle and other databases through the tunnel. This works also using the built-in Xojo database classes. With our CURLSMBS class, you can connect through this tunnel and do your FTP/HTTP requests tunneled. As you can have several SSH2TunnelMBS instances running, nothing stops you to tunnel a connection through another tunnel if needed.

Here is some code from the example project:

[code]//* Open tunnel */
dim tunnel as new SSH2TunnelMBS(session)
tunnel.LocalAddress = “127.0.0.1”
tunnel.LocalPort = 3307
tunnel.RemoteAddress = “127.0.0.1”
tunnel.RemotePort = 3306

// run it
// while it runs, connect to database server
// don’t alter session while tunnel runs

tunnel.Run

// now use it, e.g. with MySQL via Xojo’s plugin

dim db as new MySQLCommunityServer
db.Host = “127.0.0.1”
db.DatabaseName = “xxx”
db.UserName = “xxx”
db.Password = “xxx”
db.Port = 3307

if db.Connect then
print “Connected”
else
print "Failed to connect: "+db.ErrorMessage
end if

// shutdown
db = nil
tunnel.Cancel = true

// wait for shutdown
do
app.DoEvents 10
loop until not tunnel.Running

print tunnel.Messages[/code]

The SSH2TunnelMBS class will be available for next version of our MBS Xojo Network Plugin. Currently we have a first version with IPv4 only, but we’ll soon upgrade it for IPv6.

If you like to try, email me.

for now, I have plugin and examples here to try:
https://www.dropbox.com/sh/5g6v54qsp9q3j4b/AADXPhTU8KJVDNb5q5hZaPSva?dl=0

This is great. A couple of years ago a client asked me if I could do this with my desktop app to help him do backups and I had to say I couldn’t do it.

You could have asked years ago :wink:

Christian I already have 2 products of Monkey Bread like LibXL. Now I use the plugin for connect via ssh tunnel and work fine but when I build the project I saw a error that say I need to pay a license for the plugIN. If I have MB Product I need to pay for plugin too??

You can email us of course if you have a license question.
And if you did not yet buy our MBS Xojo Complete Plugin Set or MBS Xojo Network Plugin, you may do so now.

Can you send to me a link for buy the MBS Xojo Network Plugin, Thanks a lot

Christian I just buy the network license hope I can receive today I need to install tomorrow Thanks

No problem. We are quick :slight_smile:

Thanks

Where I can download the network plugin thanks a lot

go here:
https://www.monkeybreadsoftware.de/xojo/download.shtml