The main idea behind BEEP is to allow you writing new network application protocols in an easy way reusing as much as possible mechanisms already tested in the past. In the same direction, the TUNNEL profile allows you to provide proxy support, with its all associated security advantages, to any protocol layered on top of BEEP.
The TUNNEL profile design is simple and elegant. You configure a TUNNEL to be created to the remote endpoint, and once establish the link, endpoint-to-endpoint, a new BEEP session is negotiated, allowing to create channels as it were no proxy in the middle.
Here is a simple example creating a connection, using a BEEP proxy:
VortexTunnelSettings * settings; VortexConnection * connection; // create a tunnel settings holder settings = vortex_tunnel_settings_new (); // configure the tunnel vortex_tunnel_settings_add_hop (settings, TUNNEL_IP4, "80.43.98.134" TUNNEL_PORT, "55000", TUNNEL_END_CONF); vortex_tunnel_settings_add_hop (settings, TUNNEL_IP4, "192.168.0.133", TUNNEL_PORT, "604", TUNNEL_END_CONF); // create the connection using tunnel settings connection = vortex_tunnel_new (settings, NULL, NULL); if (! vortex_connection_is_ok (connection, axl_false)) { // manage tunnel creation error } // tunnel created!
Let's see what's happens here:
Once the connection is created, you can use the usual API to create channels and to exchange data over those channels. A connection created by the TUNNEL API works with the same properties: you must close them using vortex_connection_close when no longer needed.
The example also shows that a settings configuration can be reused as many times as required. Once finished, it is also required to call: vortex_tunnel_settings_free.
So, to create a tunnel with the following configuration:
[BEEP PROXY 1] -> [BEEP PROXY 2] -> [ENDPOINT]
You must build the tunnel setting in the inverse order, that is, calling to vortex_tunnel_settings_add_hop with the address of "ENDPOINT", followed by "BEEP PROXY2" and "BEEP PROXY1".