comparison src/proxy.c @ 1451:f6cc5cb7faf6

[gaim-migrate @ 1461] patch from customdesigned to hopefully fix proxying once and for all. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 31 Jan 2001 08:07:59 +0000
parents 153eb28ea454
children c0ab844d4790
comparison
equal deleted inserted replaced
1450:024f9250ba63 1451:f6cc5cb7faf6
193 if (!(hp = gethostbyname(host))) 193 if (!(hp = gethostbyname(host)))
194 return -1; 194 return -1;
195 195
196 packet[0] = 4; 196 packet[0] = 4;
197 packet[1] = 1; 197 packet[1] = 1;
198 packet[2] = (((unsigned short)htons(port)) >> 8); 198 packet[2] = port >> 8;
199 packet[3] = (((unsigned short)htons(port)) & 0xff); 199 packet[3] = port & 0xff;
200 packet[4] = (unsigned char)(hp->h_addr_list[0])[0]; 200 packet[4] = (unsigned char)(hp->h_addr_list[0])[0];
201 packet[5] = (unsigned char)(hp->h_addr_list[0])[1]; 201 packet[5] = (unsigned char)(hp->h_addr_list[0])[1];
202 packet[6] = (unsigned char)(hp->h_addr_list[0])[2]; 202 packet[6] = (unsigned char)(hp->h_addr_list[0])[2];
203 packet[7] = (unsigned char)(hp->h_addr_list[0])[3]; 203 packet[7] = (unsigned char)(hp->h_addr_list[0])[3];
204 packet[8] = 0; 204 packet[8] = 0;
217 { 217 {
218 int i, fd = -1; 218 int i, fd = -1;
219 unsigned char buf[512]; 219 unsigned char buf[512];
220 struct sockaddr_in sin; 220 struct sockaddr_in sin;
221 struct hostent *hp; 221 struct hostent *hp;
222 int hlen = strlen(host);
222 223
223 debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", host, port, proxyhost, proxyport); 224 debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", host, port, proxyhost, proxyport);
224 225
225 if (!(hp = gethostbyname(proxyhost))) 226 if (!(hp = gethostbyname(proxyhost)))
226 return -1; 227 return -1;
261 262
262 buf[0] = 0x05; 263 buf[0] = 0x05;
263 buf[1] = 0x01; /* CONNECT */ 264 buf[1] = 0x01; /* CONNECT */
264 buf[2] = 0x00; /* reserved */ 265 buf[2] = 0x00; /* reserved */
265 buf[3] = 0x03; /* address type -- host name */ 266 buf[3] = 0x03; /* address type -- host name */
266 buf[4] = strlen(host); 267 buf[4] = hlen;
267 memcpy(buf + 5, host, strlen(host)); 268 memcpy(buf + 5, host, hlen);
268 buf[5 + strlen(host)] = htons(port) >> 8; 269 buf[5 + strlen(host)] = port >> 8;
269 buf[5 + strlen(host) + 1] = htons(port) & 0xff; 270 buf[5 + strlen(host) + 1] = port & 0xff;
270 271
271 if (write(fd, buf, (5 + strlen(host) + 2)) < (5 + strlen(host) + 2)) { 272 if (write(fd, buf, (5 + strlen(host) + 2)) < (5 + strlen(host) + 2)) {
272 close(fd); 273 close(fd);
273 return -1; 274 return -1;
274 } 275 }