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:
//* 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.MessagesThe 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.