Mercurial > pidgin
changeset 670:9e51c1a4abba
[gaim-migrate @ 680]
socks4/5 proxy works
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 11 Aug 2000 22:55:32 +0000 |
parents | e871081839d0 |
children | 05700c2f3a4b |
files | ChangeLog src/proxy.c |
diffstat | 2 files changed, 46 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Aug 11 05:50:26 2000 +0000 +++ b/ChangeLog Fri Aug 11 22:55:32 2000 +0000 @@ -13,6 +13,7 @@ * Redesigned preferences dialog * Redesigned conversation dialog * Removed the Lag-O-Meter + * Socks 4/5 Proxy works version 0.9.20 (07/14/2000): * More plugin events, more plugin features
--- a/src/proxy.c Fri Aug 11 05:50:26 2000 +0000 +++ b/src/proxy.c Fri Aug 11 22:55:32 2000 +0000 @@ -219,7 +219,51 @@ } break; case PROXY_SOCKS5: - return -1; + { + struct sockaddr_in sin; + struct hostent *hostinfo; + char buff[11]; + + sethostent(0); + hostinfo = gethostbyname(proxy_host); + if (!hostinfo) return -1; + + sin.sin_addr.s_addr = atol(hostinfo->h_addr); + sin.sin_family = AF_INET; + sin.sin_port = htons(proxy_port); + + if (connect(sockfd, (struct sockaddr *)&sin, sizeof(sin)) < 0) + return -1; + + buff[0] = 5; + buff[1] = 1; + buff[2] = 0; + + write(sockfd, buff, 3); + read(sockfd, buff, 2); + + if (buff[1]) return -1; + + hostinfo = gethostbyname(proxy_realhost); + if (!hostinfo) return -1; + + buff[0] = 5; + buff[1] = 1; + buff[2] = 0; + buff[3] = 1; + buff[4] = (unsigned char) (hostinfo->h_addr_list[0])[0]; + buff[5] = (unsigned char) (hostinfo->h_addr_list[0])[1]; + buff[6] = (unsigned char) (hostinfo->h_addr_list[0])[2]; + buff[7] = (unsigned char) (hostinfo->h_addr_list[0])[3]; + memcpy(buff+8, &((struct sockaddr_in *)serv_addr)->sin_port, 2); + + write(sockfd, buff, 10); + read(sockfd, buff, 10); + + if (buff[1]) return -1; + + return 0; + } break; default: fprintf(stderr,"Unknown proxy type : %d.\n",proxy_type);