comparison libpurple/protocols/bonjour/bonjour_ft.c @ 21533:178fe7d45700

Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 15 Nov 2007 23:37:36 +0000
parents 07c91ea3da0e
children 41959f031322
comparison
equal deleted inserted replaced
21532:0e9129f83906 21533:178fe7d45700
31 #include "cipher.h" 31 #include "cipher.h"
32 32
33 static void 33 static void
34 bonjour_bytestreams_init(PurpleXfer *xfer); 34 bonjour_bytestreams_init(PurpleXfer *xfer);
35 static void 35 static void
36 bonjour_bytestreams_connect(PurpleXfer *xfer); 36 bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb);
37 static void 37 static void
38 bonjour_xfer_init(PurpleXfer *xfer); 38 bonjour_xfer_init(PurpleXfer *xfer);
39 static void 39 static void
40 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *sid, const char *from, 40 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *sid, const char *from,
41 const int filesize, const char *filename, int option); 41 const int filesize, const char *filename, int option);
544 xf->jid = g_strdup(jid); 544 xf->jid = g_strdup(jid);
545 xf->proxy_host = g_strdup(host); 545 xf->proxy_host = g_strdup(host);
546 xf->proxy_port = portnum; 546 xf->proxy_port = portnum;
547 purple_debug_info("bonjour", "bytestream offer parse" 547 purple_debug_info("bonjour", "bytestream offer parse"
548 "jid=%s host=%s port=%d.\n", jid, host, portnum); 548 "jid=%s host=%s port=%d.\n", jid, host, portnum);
549 bonjour_bytestreams_connect(xfer); 549 bonjour_bytestreams_connect(xfer, pb);
550 found = TRUE; 550 found = TRUE;
551 break; 551 break;
552 } 552 }
553 } else { 553 } else {
554 purple_debug_info("bonjour", "bytestream offer Message parse error.\n"); 554 purple_debug_info("bonjour", "bytestream offer Message parse error.\n");
813 XepXfer *xf = xfer->data; 813 XepXfer *xf = xfer->data;
814 XepIq *iq = NULL; 814 XepIq *iq = NULL;
815 xmlnode *q_node, *tmp_node; 815 xmlnode *q_node, *tmp_node;
816 BonjourData *bd; 816 BonjourData *bd;
817 817
818 if(data == NULL || source < 0) { 818 if(source < 0) {
819 purple_debug_error("bonjour", "Error connecting via SOCKS5 - %s\n",
820 error_message ? error_message : "(null)");
819 xep_ft_si_reject(xf->data, xf->iq_id, xfer->who, "404", "cancel"); 821 xep_ft_si_reject(xf->data, xf->iq_id, xfer->who, "404", "cancel");
820 /* Cancel the connection */ 822 /* Cancel the connection */
821 purple_xfer_cancel_local(xfer); 823 purple_xfer_cancel_local(xfer);
822 return; 824 return;
823 } 825 }
826
827 purple_debug_info("bonjour", "Connected successfully via SOCKS5, starting transfer.\n");
824 828
825 bd = xf->data; 829 bd = xf->data;
826 830
827 purple_proxy_info_destroy(xf->proxy_info); 831 purple_proxy_info_destroy(xf->proxy_info);
828 xf->proxy_connection = NULL; 832 xf->proxy_connection = NULL;
839 843
840 purple_xfer_start(xfer, source, NULL, -1); 844 purple_xfer_start(xfer, source, NULL, -1);
841 } 845 }
842 846
843 static void 847 static void
844 bonjour_bytestreams_connect(PurpleXfer *xfer) 848 bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb)
845 { 849 {
846 XepXfer *xf = NULL; 850 XepXfer *xf = NULL;
847 char dstaddr[41]; 851 char dstaddr[41];
848 unsigned char hashval[20]; 852 unsigned char hashval[20];
849 char *p = NULL; 853 char *p = NULL;
856 860
857 xf = (XepXfer*)xfer->data; 861 xf = (XepXfer*)xfer->data;
858 if(!xf) 862 if(!xf)
859 return; 863 return;
860 864
861 p = g_strdup_printf("%s@%s", xf->sid, xfer->who); 865 p = g_strdup_printf("%s%s%s", xf->sid, pb->name, purple_account_get_username(pb->account));
862 purple_cipher_digest_region("sha1", (guchar *)p, strlen(p), 866 purple_cipher_digest_region("sha1", (guchar *)p, strlen(p),
863 sizeof(hashval), hashval, NULL); 867 sizeof(hashval), hashval, NULL);
864 g_free(p); 868 g_free(p);
865 869
866 memset(dstaddr, 0, 41); 870 memset(dstaddr, 0, 41);