pidgin: 17e496a1: Added ability to relay over TCP and TLS ...

malu at pidgin.im malu at pidgin.im
Wed Aug 25 15:21:39 EDT 2010


----------------------------------------------------------------------
Revision: 17e496a18cf8462d267f5220dd5f6283662eeba7
Parent:   9166d0ffe82472b17cee09aabbef61d8ec6e3e44
Author:   malu at pidgin.im
Date:     08/25/10 15:11:38
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/17e496a18cf8462d267f5220dd5f6283662eeba7

Changelog: 

Added ability to relay over TCP and TLS for TURN for media.

Changes against parent 9166d0ffe82472b17cee09aabbef61d8ec6e3e44

  patched  ChangeLog
  patched  libpurple/media/backend-fs2.c
  patched  libpurple/network.c
  patched  pidgin/gtkprefs.c

-------------- next part --------------
============================================================
--- ChangeLog	3aeab0b919d2d169ce511a4656988c84fc3eb2cb
+++ ChangeLog	0b5e196a4c304d0a9d5bc67df78998011f1412b8
@@ -3,6 +3,10 @@ version 2.7.4 (MM/DD/YYYY):
 version 2.7.4 (MM/DD/YYYY):
 	General:
 	* Fix search path for Tk when compiling on Debian Squeeze. (#12465)
+	
+	libpurple:
+	* Added ability to use TURN relaying via TCP and TLS (including preference
+	  settings for these).
 
 version 2.7.3 (08/10/2010):
 	General:
============================================================
--- pidgin/gtkprefs.c	50a681ee823dc0a92c262459a9c66aeca4cb07ee
+++ pidgin/gtkprefs.c	67ddbe590e997263e49a6a6303213dc12b32a20c
@@ -1809,9 +1809,13 @@ network_page(void)
 
 	hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_TURN server:"),
 			sg, entry, TRUE, NULL);
-
-	pidgin_prefs_labeled_spin_button(hbox, _("_Port:"),
+	
+	pidgin_prefs_labeled_spin_button(hbox, _("_UDP:"),
 		"/purple/network/turn_port", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TCP:"),
+		"/purple/network/turn_port_tcp", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TLS:"),
+		"/purple/network/turn_port_tls", 0, 65535, NULL);
 	hbox = pidgin_prefs_labeled_entry(vbox, _("Use_rname:"),
 		"/purple/network/turn_username", sg);
 	pidgin_prefs_labeled_password(hbox, _("Pass_word:"),
============================================================
--- libpurple/network.c	8c70d2a63b2c464b174ff8cc768e43a6bff9c4cb
+++ libpurple/network.c	dd5f660150e108f3da403edf2b772ca49930d6f9
@@ -1140,6 +1140,8 @@ purple_network_init(void)
 	purple_prefs_add_string("/purple/network/stun_server", "");
 	purple_prefs_add_string("/purple/network/turn_server", "");
 	purple_prefs_add_int   ("/purple/network/turn_port", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tcp", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tls", 443);
 	purple_prefs_add_string("/purple/network/turn_username", "");
 	purple_prefs_add_string("/purple/network/turn_password", "");
 	purple_prefs_add_bool  ("/purple/network/auto_ip", TRUE);
============================================================
--- libpurple/media/backend-fs2.c	f7a35c8d2a85fb0992e84bc4d0e348d44c510205
+++ libpurple/media/backend-fs2.c	6e0592c8aafab90eea77f9f9e0b5bda9c6e792f2
@@ -1564,6 +1564,30 @@ src_pad_added_cb(FsStream *fsstream, Gst
 			(GSourceFunc)src_pad_added_cb_cb, stream);
 }
 
+static GValueArray *
+append_relay_info(GValueArray *relay_info, const gchar *ip, gint port,
+	const gchar *username, const gchar *password, const gchar *type)
+{
+	GValue value;
+	GstStructure *turn_setup = gst_structure_new("relay-info",
+				"ip", G_TYPE_STRING, ip, 
+				"port", G_TYPE_UINT, port,
+				"username", G_TYPE_STRING, username,
+				"password", G_TYPE_STRING, password,
+	            "relay-type", G_TYPE_STRING, type,
+				NULL);
+
+	if (turn_setup) {
+		memset(&value, 0, sizeof(GValue));
+		g_value_init(&value, GST_TYPE_STRUCTURE);
+		gst_value_set_structure(&value, turn_setup);
+		relay_info = g_value_array_append(relay_info, &value);
+		gst_structure_free(turn_setup);
+	}
+
+	return relay_info;
+}
+                        
 static gboolean
 create_stream(PurpleMediaBackendFs2 *self,
 		const gchar *sess_id, const gchar *who,
@@ -1605,32 +1629,33 @@ create_stream(PurpleMediaBackendFs2 *sel
 
 	if (turn_ip && !strcmp("nice", transmitter)) {
 		GValueArray *relay_info = g_value_array_new(0);
-		GValue value;
-		gint turn_port = purple_prefs_get_int(
-				"/purple/network/turn_port");
+		gint port;
 		const gchar *username =	purple_prefs_get_string(
 				"/purple/network/turn_username");
 		const gchar *password = purple_prefs_get_string(
 				"/purple/network/turn_password");
-		GstStructure *turn_setup = gst_structure_new("relay-info",
-				"ip", G_TYPE_STRING, turn_ip, 
-				"port", G_TYPE_UINT, turn_port,
-				"username", G_TYPE_STRING, username,
-				"password", G_TYPE_STRING, password,
-				NULL);
 
-		if (!turn_setup) {
-			purple_debug_error("backend-fs2",
-					"Error creating relay info structure");
-			return FALSE;
+		/* UDP */
+		port = purple_prefs_get_int("/purple/network/turn_port");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "udp");
 		}
 
-		memset(&value, 0, sizeof(GValue));
-		g_value_init(&value, GST_TYPE_STRUCTURE);
-		gst_value_set_structure(&value, turn_setup);
-		relay_info = g_value_array_append(relay_info, &value);
-		gst_structure_free(turn_setup);
+		/* TCP */
+		port = purple_prefs_get_int("/purple/network/turn_port_tcp");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tcp");
+		}
 
+		/* TLS */
+		port = purple_prefs_get_int("/purple/network/turn_port_tls");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tls");
+		}
+
 		purple_debug_info("backend-fs2",
 			"Setting relay-info on new stream\n");
 		_params[_num_params].name = "relay-info";


More information about the Commits mailing list