Mercurial > pidgin.yaz
changeset 2907:28cd1b9d08a1
[gaim-migrate @ 2920]
evidently this broke things.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 21 Dec 2001 22:42:41 +0000 |
parents | 538c58b43eff |
children | aa590ecc67a7 |
files | src/proxy.c |
diffstat | 1 files changed, 40 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/proxy.c Fri Dec 21 10:23:04 2001 +0000 +++ b/src/proxy.c Fri Dec 21 22:42:41 2001 +0000 @@ -33,7 +33,6 @@ #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -119,24 +118,6 @@ g_source_remove(tag); } -static struct sockaddr_in *gaim_gethostbyname(char *host) -{ - static struct sockaddr_in sin; - - if (!inet_aton(host, &sin.sin_addr)) { - struct hostent *hp; - if (!(hp = gethostbyname(host))) { - return NULL; - } - memset(&sin, 0, sizeof(struct sockaddr_in)); - memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); - sin.sin_family = hp->h_addrtype; - } else - sin.sin_family = AF_INET; - - return &sin; -} - static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { struct PHB *phb = data; @@ -170,25 +151,31 @@ static int proxy_connect_none(char *host, unsigned short port, struct PHB *phb) { - struct sockaddr_in *sin; + struct sockaddr_in sin; + struct hostent *hp; int fd = -1; debug_printf("connecting to %s:%d with no proxy\n", host, port); - if (!(sin = gaim_gethostbyname(host))) { + if (!(hp = gethostbyname(host))) { debug_printf("gethostbyname failed\n"); g_free(phb); return -1; } - if ((fd = socket(sin->sin_family, SOCK_STREAM, 0)) < 0) { + memset(&sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons(port); + + if ((fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) { debug_printf("unable to create socket\n"); g_free(phb); return -1; } fcntl(fd, F_SETFL, O_NONBLOCK); - if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { + if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { debug_printf("Connect would have blocked\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); @@ -315,17 +302,23 @@ static int proxy_connect_http(char *host, unsigned short port, struct PHB *phb) { - struct sockaddr_in *sin; + struct hostent *hp; + struct sockaddr_in sin; int fd = -1; debug_printf("connecting to %s:%d via %s:%d using HTTP\n", host, port, proxyhost, proxyport); - if (!(sin = gaim_gethostbyname(proxyhost))) { + if (!(hp = gethostbyname(proxyhost))) { g_free(phb); return -1; } - if ((fd = socket(sin->sin_family, SOCK_STREAM, 0)) < 0) { + memset(&sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons(proxyport); + + if ((fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) { g_free(phb); return -1; } @@ -334,7 +327,7 @@ phb->port = port; fcntl(fd, F_SETFL, O_NONBLOCK); - if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { + if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { debug_printf("Connect would have blocked\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, http_canwrite, phb); @@ -434,17 +427,23 @@ static int proxy_connect_socks4(char *host, unsigned short port, struct PHB *phb) { - struct sockaddr_in *sin; + struct sockaddr_in sin; + struct hostent *hp; int fd = -1; debug_printf("connecting to %s:%d via %s:%d using SOCKS4\n", host, port, proxyhost, proxyport); - if (!(sin = gaim_gethostbyname(proxyhost))) { + if (!(hp = gethostbyname(proxyhost))) { g_free(phb); return -1; } - if ((fd = socket(sin->sin_family, SOCK_STREAM, 0)) < 0) { + memset(&sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons(proxyport); + + if ((fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) { g_free(phb); return -1; } @@ -453,7 +452,7 @@ phb->port = port; fcntl(fd, F_SETFL, O_NONBLOCK); - if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { + if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { debug_printf("Connect would have blocked\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, phb); @@ -657,17 +656,23 @@ static int proxy_connect_socks5(char *host, unsigned short port, struct PHB *phb) { - struct sockaddr_in *sin; int fd = -1; + struct sockaddr_in sin; + struct hostent *hp; debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", host, port, proxyhost, proxyport); - if (!(sin = gaim_gethostbyname(proxyhost))) { + if (!(hp = gethostbyname(proxyhost))) { g_free(phb); return -1; } - if ((fd = socket(sin->sin_family, SOCK_STREAM, 0)) < 0) { + memset(&sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons(proxyport); + + if ((fd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) { g_free(phb); return -1; } @@ -676,7 +681,7 @@ phb->port = port; fcntl(fd, F_SETFL, O_NONBLOCK); - if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { + if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { debug_printf("Connect would have blocked\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, phb);