Changeset 12f041d for lib/proxy.c
- Timestamp:
- 2015-10-21T13:14:17Z (9 years ago)
- Branches:
- master
- Children:
- b0da3b8
- Parents:
- 3314ced
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/proxy.c
r3314ced r12f041d 294 294 socklen_t len; 295 295 int error = ETIMEDOUT; 296 gboolean is_socks4a = (proxytype == PROXY_SOCKS4A); 296 297 297 298 if (phb->inpa > 0) { … … 304 305 sock_make_blocking(source); 305 306 306 /* XXX does socks4 not support host name lookups by the proxy? */ 307 if (!(hp = gethostbyname(phb->host))) { 307 if (!is_socks4a && !(hp = gethostbyname(phb->host))) { 308 308 return phb_close(phb); 309 309 } … … 313 313 packet[2] = phb->port >> 8; 314 314 packet[3] = phb->port & 0xff; 315 packet[4] = (unsigned char) (hp->h_addr_list[0])[0]; 316 packet[5] = (unsigned char) (hp->h_addr_list[0])[1]; 317 packet[6] = (unsigned char) (hp->h_addr_list[0])[2]; 318 packet[7] = (unsigned char) (hp->h_addr_list[0])[3]; 315 if (is_socks4a) { 316 packet[4] = 0; 317 packet[5] = 0; 318 packet[6] = 0; 319 packet[7] = 1; 320 } else { 321 packet[4] = (unsigned char) (hp->h_addr_list[0])[0]; 322 packet[5] = (unsigned char) (hp->h_addr_list[0])[1]; 323 packet[6] = (unsigned char) (hp->h_addr_list[0])[2]; 324 packet[7] = (unsigned char) (hp->h_addr_list[0])[3]; 325 } 319 326 packet[8] = 0; 320 327 if (write(source, packet, 9) != 9) { 321 328 return phb_close(phb); 329 } 330 331 if (is_socks4a) { 332 size_t host_len = strlen(phb->host) + 1; /* include the \0 */ 333 334 if (write(source, phb->host, host_len) != host_len) { 335 return phb_close(phb); 336 } 322 337 } 323 338 … … 506 521 } else if (proxytype == PROXY_HTTP) { 507 522 return proxy_connect_http(host, port, phb); 508 } else if (proxytype == PROXY_SOCKS4 ) {523 } else if (proxytype == PROXY_SOCKS4 || proxytype == PROXY_SOCKS4A) { 509 524 return proxy_connect_socks4(host, port, phb); 510 525 } else if (proxytype == PROXY_SOCKS5) {
Note: See TracChangeset
for help on using the changeset viewer.