[vinagre] Allows using of an alternative ssh port when doing tunnel



commit df27060efc8b98cd605a051062a2a31666eaff15
Author: Jonh Wendell <jwendell gnome org>
Date:   Wed Jun 16 15:22:38 2010 -0300

    Allows using of an alternative ssh port when doing tunnel
    
    Closes #621809

 plugins/vnc/vinagre-vnc-plugin.c |    7 ++++++-
 plugins/vnc/vinagre-vnc-tunnel.c |   31 +++++++++++++++++++++++++++----
 2 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/plugins/vnc/vinagre-vnc-plugin.c b/plugins/vnc/vinagre-vnc-plugin.c
index b43b6eb..11e62e0 100644
--- a/plugins/vnc/vinagre-vnc-plugin.c
+++ b/plugins/vnc/vinagre-vnc-plugin.c
@@ -462,7 +462,12 @@ impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
   gtk_widget_set_sensitive (ssh_host_entry, FALSE);
   g_object_set_data (G_OBJECT (box), "ssh_host", ssh_host_entry);
   /* Translators: This is the tooltip of the SSH tunneling entry */
-  gtk_widget_set_tooltip_text (ssh_host_entry, _("hostname or user hostname"));
+  str = g_strdup_printf ("%s\n%s\n%s",
+			 _("hostname or user hostname"),
+			 _("Supply an alternative port using colon"),
+			 _("For instance: joe domain com:5022"));
+  gtk_widget_set_tooltip_text (ssh_host_entry, str);
+  g_free (str);
   gtk_box_pack_start (GTK_BOX (box2), ssh_host_entry, FALSE, FALSE, 0);
 
   /* Translators: the whole sentence will be: Use host <hostname> as a SSH tunnel*/
diff --git a/plugins/vnc/vinagre-vnc-tunnel.c b/plugins/vnc/vinagre-vnc-tunnel.c
index c0987aa..cb9a6bf 100644
--- a/plugins/vnc/vinagre-vnc-tunnel.c
+++ b/plugins/vnc/vinagre-vnc-tunnel.c
@@ -23,6 +23,7 @@
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <glib/gi18n.h>
 
 #include <vinagre/vinagre-ssh.h>
@@ -58,6 +59,24 @@ find_free_port (void)
   return 0;
 }
 
+static void
+split_gateway (const gchar *gateway, gchar **host, gint *port)
+{
+  if (g_strrstr (gateway, ":") == NULL)
+    {
+      *host = g_strdup (gateway);
+      *port = 22;
+    }
+  else
+    {
+      gchar **server = g_strsplit (gateway, ":", 2);
+      *host = g_strdup (server[0]);
+      *port = server[1] ? atoi (server[1]) : 22;
+      g_strfreev (server);
+    }
+}
+
+
 gboolean
 vinagre_vnc_tunnel_create (GtkWindow *parent,
 			   gchar **original_host,
@@ -65,8 +84,8 @@ vinagre_vnc_tunnel_create (GtkWindow *parent,
 			   gchar *gateway,
 			   GError **error)
 {
-  int local_port;
-  gchar **tunnel_str, **command_str;
+  int local_port, gateway_port;
+  gchar **tunnel_str, **command_str, *gateway_host;
 
   local_port = find_free_port ();
   if (local_port == 0)
@@ -94,9 +113,11 @@ vinagre_vnc_tunnel_create (GtkWindow *parent,
   command_str[3] = g_strdup ("15");
   command_str[4] = NULL;
 
+  split_gateway (gateway, &gateway_host, &gateway_port);
+
   if (!vinagre_ssh_connect (parent,
-			    gateway,
-			    22,
+			    gateway_host,
+			    gateway_port,
 			    NULL,
 			    tunnel_str,
 			    command_str,
@@ -105,11 +126,13 @@ vinagre_vnc_tunnel_create (GtkWindow *parent,
     {
       g_strfreev (tunnel_str);
       g_strfreev (command_str);
+      g_free (gateway_host);
       return FALSE;
     }
 
   g_strfreev (tunnel_str);
   g_strfreev (command_str);
+  g_free (gateway_host);
   g_free (*original_host);
   *original_host = g_strdup ("localhost");
   g_free (*original_port);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]