Mercurial > pidgin
diff libgaim/protocols/qq/udp_proxy_s5.c @ 14195:902c3aa4950a
[gaim-migrate @ 16867]
Revamped the QQ proxy code.
Fixed an infinite loop that was occurring if we hit qq_input_pending() with an unexpected value of cond.
Rewrote part of qq_proxy.c so that we use Gaim's non-blocking dns lookups.
Quieted some warnings created by new code in proxy.c and passed appropriate error messages to _qq_got_login().
Added some extra error handling to qq_proxy_write().
I was beginning to do major clean-up on this this code when I realized that once that clean-up is done, I will have duplicated a very large amount of code from proxy.c. Therefore, I am submitting this working code now and will later submit a patch to gaim-devel that will add support for UDP proxying in proxy.c, thus eliminating the need for such code in the individual prpls.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Sat, 19 Aug 2006 02:32:55 +0000 |
parents | 60b1bc8dbf37 |
children | fd744ac11331 |
line wrap: on
line diff
--- a/libgaim/protocols/qq/udp_proxy_s5.c Sat Aug 19 02:26:57 2006 +0000 +++ b/libgaim/protocols/qq/udp_proxy_s5.c Sat Aug 19 02:32:55 2006 +0000 @@ -25,15 +25,13 @@ #include "udp_proxy_s5.h" -extern gint /* defined in qq_proxy.c */ - _qq_fill_host(struct sockaddr_in *addr, const gchar * host, guint16 port); - static void _qq_s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { unsigned char buf[512]; struct PHB *phb = data; struct sockaddr_in sin; int len, error; + socklen_t errlen; gaim_input_remove(phb->inpa); gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read again.\n"); @@ -61,7 +59,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -84,8 +82,8 @@ error = ETIMEDOUT; gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connect didn't block\n"); - len = sizeof(error); - if (getsockopt(phb->udpsock, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + errlen = sizeof(error); + if (getsockopt(phb->udpsock, SOL_SOCKET, SO_ERROR, &error, &errlen) < 0) { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "getsockopt failed.\n"); close(phb->udpsock); return; @@ -105,7 +103,8 @@ unsigned char buf[512]; struct PHB *phb = data; struct sockaddr_in sin, ctlsin; - int port, ctllen; + int port; + socklen_t ctllen; gaim_debug(GAIM_DEBUG_INFO, "s5_sendconnect", "remote host is %s:%d\n", phb->host, phb->port); @@ -137,7 +136,9 @@ port = ntohs(ctlsin.sin_port) + 1; while (1) { - _qq_fill_host(&sin, "0.0.0.0", port); + inet_aton("0.0.0.0", &(sin.sin_addr)); + sin.sin_family = AF_INET; + sin.sin_port = htons(port); if (bind(phb->udpsock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { port++; if (port > 65500) { @@ -158,7 +159,7 @@ gaim_debug(GAIM_DEBUG_INFO, "s5_sendconnect", "packet too small\n"); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -182,7 +183,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -195,7 +196,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -238,7 +239,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -263,7 +264,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -297,7 +298,7 @@ close(source); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); @@ -327,7 +328,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, NULL); + phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host);