diff libpurple/protocols/msn/slp.c @ 30459:a97d60c15e25

Support old-style Nonce, which should let us use direct connections to aMSN (or msn-pecan?) Refs #247.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 24 Apr 2010 06:41:52 +0000
parents 4e532eedcab4
children 0cc4f8651462
line wrap: on
line diff
--- a/libpurple/protocols/msn/slp.c	Sat Apr 24 02:29:34 2010 +0000
+++ b/libpurple/protocols/msn/slp.c	Sat Apr 24 06:41:52 2010 +0000
@@ -631,6 +631,7 @@
 		/* A direct connection negotiation request */
 		char *bridges;
 		char *nonce;
+		MsnDirectConnNonceType ntype;
 
 		purple_debug_info("msn", "got_invite: transreqbody received\n");
 
@@ -640,6 +641,12 @@
 
 		bridges = get_token(content, "Bridges: ", "\r\n");
 		nonce = get_token(content, "Hashed-Nonce: {", "}\r\n");
+		if (nonce) {
+			ntype = DC_NONCE_SHA1;
+		} else {
+			nonce = get_token(content, "Nonce: {", "}\r\n");
+			ntype = DC_NONCE_PLAIN;
+		}
 		if (nonce && bridges && strstr(bridges, "TCPv1") != NULL) {
 			/*
 			 * Ok, the client supports direct TCP connection
@@ -648,6 +655,7 @@
 			MsnDirectConn *dc;
 
 			dc = msn_dc_new(slpcall);
+			dc->nonce_type = ntype;
 			strncpy(dc->remote_nonce, nonce, 36);
 			dc->remote_nonce[36] = '\0';
 
@@ -663,12 +671,20 @@
 
 				purple_debug_info("msn", "got_invite: listening failed\n");
 
-				msn_slp_send_ok(slpcall, branch,
-					"application/x-msnmsgr-transrespbody",
-					"Bridge: TCPv1\r\n"
-					"Listening: false\r\n"
-					"Hashed-Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
-					"\r\n");
+				if (dc->nonce_type != DC_NONCE_PLAIN)
+					msn_slp_send_ok(slpcall, branch,
+						"application/x-msnmsgr-transrespbody",
+						"Bridge: TCPv1\r\n"
+						"Listening: false\r\n"
+						"Hashed-Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
+						"\r\n");
+				else
+					msn_slp_send_ok(slpcall, branch,
+						"application/x-msnmsgr-transrespbody",
+						"Bridge: TCPv1\r\n"
+						"Listening: false\r\n"
+						"Nonce: {00000000-0000-0000-0000-000000000000}\r\n"
+						"\r\n");
 
 			} else {
 				/*
@@ -750,10 +766,11 @@
 				"Conn-Type: IP-Restrict-NAT\r\n"
 				"UPnPNat: false\r\n"
 				"ICF: false\r\n"
-				"Hashed-Nonce: {%s}\r\n"
+				"%sNonce: {%s}\r\n"
 				"\r\n",
 
 				rand() % G_MAXUINT32,
+				dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "",
 				dc->nonce_hash
 			);
 
@@ -768,9 +785,10 @@
 				"Conn-Type: Direct-Connect\r\n"
 				"UPnPNat: false\r\n"
 				"ICF: false\r\n"
-				"Hashed-Nonce: {%s}\r\n"
+				"%sNonce: {%s}\r\n"
 				"\r\n",
 
+				dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "",
 				dc->nonce_hash
 			);
 		}