From: <ev...@us...> - 2006-04-17 19:28:24
|
Revision: 16049 Author: evands Date: 2006-04-17 12:28:15 -0700 (Mon, 17 Apr 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16049&view=rev Log Message: ----------- __unix__ is not defined in Mac OS X [1], but this code for asynchronous DNS lookups works fine on that platform (at least as of OS X 10.3.9). We now check for __unix__ or __APPLE__ being defined. [1] http://developer.apple.com/technotes/tn2002/tn2071.html - under the section "Predefined Macros" Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-04-17 18:36:26 UTC (rev 16048) +++ trunk/src/proxy.c 2006-04-17 19:28:15 UTC (rev 16049) @@ -261,7 +261,7 @@ * Proxy API **************************************************************************/ -#ifdef __unix__ +#if defined(__unix__) || defined(__APPLE__) /* * This structure represents both a pending DNS request and @@ -768,7 +768,7 @@ return 0; } -#elif defined _WIN32 /* end __unix__ */ +#elif defined _WIN32 /* end __unix__ || __APPLE__ */ typedef struct _dns_tdata { char *hostname; @@ -882,7 +882,7 @@ return 0; } -#else /* not __unix__ or _WIN32 */ +#else /* not __unix__ or __APPLE__ or _WIN32 */ typedef struct { gpointer data; @@ -933,7 +933,7 @@ return 0; } -#endif /* not __unix__ or _WIN32 */ +#endif /* not __unix__ or __APPLE__ or _WIN32 */ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2006-05-09 01:35:47
|
Revision: 16163 Author: rlaager Date: 2006-05-08 18:35:43 -0700 (Mon, 08 May 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16163&view=rev Log Message: ----------- A patch in SF Bug #1461450 from gonufer. This should make SOCKS-5 proxies work again. It looked correct to me, but someone who really knows the proxy code might want to double-check. Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-05-09 01:22:33 UTC (rev 16162) +++ trunk/src/proxy.c 2006-05-09 01:35:43 UTC (rev 16163) @@ -1737,7 +1737,7 @@ { struct PHB *phb = data; int hlen = strlen(phb->host); - phb->write_buf_len = 5 + hlen + 1; + phb->write_buf_len = 5 + hlen + 2; phb->write_buffer = g_malloc(phb->write_buf_len); phb->written_len = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2006-05-30 22:22:57
|
Revision: 16210 Author: rlaager Date: 2006-05-30 15:22:52 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16210&view=rev Log Message: ----------- Brian Chu suggested that we print to stdout instead of stderr to make redirection cleaner because the gaim_debug stuff prints to stdout. I swear I committed this before, but I guess I didn't. Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-05-30 22:21:00 UTC (rev 16209) +++ trunk/src/proxy.c 2006-05-30 22:22:52 UTC (rev 16210) @@ -386,7 +386,7 @@ rc = select(child_in + 1, &fds, NULL, NULL, &tv); if (!rc) { if (show_debug) - fprintf(stderr,"dns[%d]: nobody needs me... =(\n", getpid()); + printf("dns[%d]: nobody needs me... =(\n", getpid()); break; } rc = read(child_in, &dns_params, sizeof(dns_params_t)); @@ -396,11 +396,11 @@ } if (rc == 0) { if (show_debug) - fprintf(stderr,"dns[%d]: Oops, father has gone, wait for me, wait...!\n", getpid()); + printf("dns[%d]: Oops, father has gone, wait for me, wait...!\n", getpid()); _exit(0); } if (dns_params.hostname[0] == '\0') { - fprintf(stderr, "dns[%d]: hostname = \"\" (port = %d)!!!\n", getpid(), dns_params.port); + printf("dns[%d]: hostname = \"\" (port = %d)!!!\n", getpid(), dns_params.port); _exit(1); } /* Tell our parent that we read the data successfully */ @@ -424,7 +424,7 @@ if (rc != 0) { close(child_out); if (show_debug) - fprintf(stderr,"dns[%d] Error: getaddrinfo returned %d\n", + printf("dns[%d] Error: getaddrinfo returned %d\n", getpid(), rc); dns_params.hostname[0] = '\0'; continue; @@ -445,7 +445,7 @@ write(child_out, &h_errno, sizeof(int)); close(child_out); if (show_debug) - fprintf(stderr,"DNS Error: %d\n", h_errno); + printf("DNS Error: %d\n", h_errno); _exit(0); } memset(&sin, 0, sizeof(struct sockaddr_in)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ebl...@us...> - 2006-07-07 21:57:19
|
Revision: 16456 Author: eblanton Date: 2006-07-07 14:57:15 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16456&view=rev Log Message: ----------- Suppress "Connect would have blocked", because it just confuses people Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-07-07 07:18:08 UTC (rev 16455) +++ trunk/src/proxy.c 2006-07-07 21:57:15 UTC (rev 16456) @@ -1021,8 +1021,9 @@ if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("proxy", - "Connect would have blocked.\n"); + /* This just confuses people. */ + /* gaim_debug_warning("proxy", + "Connect would have blocked.\n"); */ phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2006-08-12 20:01:45
|
Revision: 16724 Author: rlaager Date: 2006-08-12 13:01:35 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16724&view=rev Log Message: ----------- Remove an outdated comment. Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 15:17:14 UTC (rev 16723) +++ trunk/src/proxy.c 2006-08-12 20:01:35 UTC (rev 16724) @@ -38,7 +38,6 @@ #include "proxy.h" #include "util.h" -/* Does anyone know what PHB stands for? */ struct _GaimProxyConnectInfo { GaimProxyConnectFunction connect_cb; GaimProxyErrorFunction error_cb; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 21:07:36
|
Revision: 16726 Author: thekingant Date: 2006-08-12 14:07:34 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16726&view=rev Log Message: ----------- Use the GaimProxyConnectInfo typedef instead of struct _GaimProxyConnectInfo. Sorry, I should have done this in one of my other commits Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 20:40:07 UTC (rev 16725) +++ trunk/src/proxy.c 2006-08-12 21:07:34 UTC (rev 16726) @@ -46,7 +46,13 @@ int port; guint inpa; GaimProxyInfo *gpi; + + /** + * This contains alternating length/char* values. The char* + * values need to be freed when removed from the linked list. + */ GSList *hosts; + guchar *write_buffer; gsize write_buf_len; gsize written_len; @@ -71,7 +77,7 @@ static GaimProxyInfo *global_proxy_info = NULL; static GSList *connect_infos = NULL; -static void try_connect(struct _GaimProxyConnectInfo *); +static void try_connect(GaimProxyConnectInfo *); /************************************************************************** * Proxy structure API @@ -257,7 +263,7 @@ **************************************************************************/ static void -gaim_proxy_connect_info_destroy(struct _GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) { connect_infos = g_slist_remove(connect_infos, connect_info); @@ -280,7 +286,7 @@ } static void -gaim_proxy_connect_info_connected(struct _GaimProxyConnectInfo *connect_info, int fd) +gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info, int fd) { connect_info->connect_cb(connect_info->data, fd); gaim_proxy_connect_info_destroy(connect_info); @@ -292,7 +298,7 @@ * specified in the call to gaim_proxy_connect(). */ static void -gaim_proxy_connect_info_error(struct _GaimProxyConnectInfo *connect_info, const gchar *error_message) +gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { if (connect_info->error_cb == NULL) { @@ -990,7 +996,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error=0, ret; @@ -1034,7 +1040,7 @@ static gboolean clean_connect(gpointer data) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; gaim_proxy_connect_info_connected(connect_info, connect_info->port); @@ -1043,7 +1049,7 @@ static int -proxy_connect_none(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1097,7 +1103,7 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; const guchar *request = connect_info->write_buffer + connect_info->written_len; gsize request_len = connect_info->write_buf_len - connect_info->written_len; @@ -1135,7 +1141,7 @@ { int len, headers_len, status = 0; gboolean error; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; guchar *p; gsize max_read; gchar *msg; @@ -1367,7 +1373,7 @@ { char request[8192]; int request_len = 0; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -1430,7 +1436,7 @@ } static int -proxy_connect_http(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1489,7 +1495,7 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; guchar *buf; int len, max_read; @@ -1531,7 +1537,7 @@ { unsigned char packet[9]; struct hostent *hp; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -1588,7 +1594,7 @@ } static int -proxy_connect_socks4(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1640,7 +1646,7 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -1722,7 +1728,7 @@ static void s5_sendconnect(gpointer data, int source) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int hlen = strlen(connect_info->host); connect_info->write_buf_len = 5 + hlen + 2; connect_info->write_buffer = g_malloc(connect_info->write_buf_len); @@ -1746,7 +1752,7 @@ static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -1792,7 +1798,8 @@ s5_sendconnect(connect_info, source); } -static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) +static void +hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) { GaimCipher *cipher; GaimCipherContext *ctx; @@ -1839,7 +1846,7 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); @@ -1972,7 +1979,7 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -2087,7 +2094,7 @@ { unsigned char buf[5]; int i; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -2134,7 +2141,7 @@ } static int -proxy_connect_socks5(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -2168,8 +2175,7 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks5 proxy", - "Connect didn't block.\n"); + gaim_debug_misc("socks5 proxy", "Connect didn't block.\n"); len = sizeof(error); @@ -2184,7 +2190,7 @@ return fd; } -static void try_connect(struct _GaimProxyConnectInfo *connect_info) +static void try_connect(GaimProxyConnectInfo *connect_info) { size_t addrlen; struct sockaddr *addr; @@ -2236,8 +2242,9 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct _GaimProxyConnectInfo *connect_info = (struct _GaimProxyConnectInfo*)data; + GaimProxyConnectInfo *connect_info; + connect_info = data; connect_info->hosts = hosts; try_connect(connect_info); @@ -2316,14 +2323,14 @@ { const char *connecthost = host; int connectport = port; - struct _GaimProxyConnectInfo *connect_info; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ - connect_info = g_new0(struct _GaimProxyConnectInfo, 1); + connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->connect_cb = connect_cb; connect_info->error_cb = error_cb; connect_info->data = data; @@ -2378,14 +2385,14 @@ GaimProxyConnectFunction connect_cb, GaimProxyErrorFunction error_cb, gpointer data) { - struct _GaimProxyConnectInfo *connect_info; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ - connect_info = g_new0(struct _GaimProxyConnectInfo, 1); + connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->connect_cb = connect_cb; connect_info->error_cb = error_cb; connect_info->data = data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 22:16:26
|
Revision: 16728 Author: thekingant Date: 2006-08-12 15:16:23 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16728&view=rev Log Message: ----------- Extremely minor error message improvements Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 21:13:25 UTC (rev 16727) +++ trunk/src/proxy.c 2006-08-12 22:16:23 UTC (rev 16728) @@ -297,6 +297,10 @@ * failed. This will be passed to the callback function * specified in the call to gaim_proxy_connect(). */ +/* + * TODO: Make sure all callers of this function pass a really really + * good error_message. + */ static void gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { @@ -1066,7 +1070,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { + if (connect(fd, (struct sockaddr *)addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { /* This just confuses people. */ /* gaim_debug_warning("proxy", @@ -1085,7 +1090,8 @@ int error = ETIMEDOUT; gaim_debug_misc("proxy", "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { gaim_debug_error("proxy", "getsockopt failed.\n"); close(fd); return -1; @@ -1455,7 +1461,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("http proxy", "Connect would have blocked.\n"); @@ -1481,7 +1488,8 @@ "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -1612,7 +1620,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks4 proxy", "Connect would have blocked.\n"); @@ -1631,7 +1640,8 @@ len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -2159,7 +2169,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks5 proxy", "Connect would have blocked.\n"); @@ -2179,7 +2190,8 @@ len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -2196,7 +2208,14 @@ struct sockaddr *addr; int ret = -1; - while (connect_info->hosts) { + if (connect_info->hosts == NULL) + { + gaim_proxy_connect_info_error(connect_info, _("Could not resolve host name")); + return; + } + + while (connect_info->hosts) + { addrlen = GPOINTER_TO_INT(connect_info->hosts->data); connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); addr = connect_info->hosts->data; @@ -2229,12 +2248,12 @@ g_free(addr); - if (ret > 0) + if (ret >= 0) break; } if (ret < 0) { - gaim_proxy_connect_info_error(connect_info, _("TODO")); + gaim_proxy_connect_info_error(connect_info, _("Unable to establish a connection")); } } @@ -2244,6 +2263,12 @@ { GaimProxyConnectInfo *connect_info; + if (error_message != NULL) + { + gaim_debug_info("proxy", "Error while resolving hostname: %s\n", error_message); + /* TODO: Destroy connect_info and return? */ + } + connect_info = data; connect_info->hosts = hosts; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |