- Timestamp:
- 2015-10-21T13:14:17Z (9 years ago)
- Branches:
- master
- Children:
- b0da3b8
- Parents:
- 3314ced
- Location:
- lib
- Files:
-
- 4 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) { -
lib/proxy.h
r3314ced r12f041d 40 40 #define PROXY_SOCKS4 2 41 41 #define PROXY_SOCKS5 3 42 #define PROXY_SOCKS4A 4 42 43 43 44 extern char proxyhost[128]; -
lib/url.c
r3314ced r12f041d 48 48 } else if (g_strncasecmp(set_url, "socks5", i - set_url) == 0) { 49 49 url->proto = PROTO_SOCKS5; 50 } else if (g_strncasecmp(set_url, "socks4a", i - set_url) == 0) { 51 url->proto = PROTO_SOCKS4A; 50 52 } else { 51 53 return 0; -
lib/url.h
r3314ced r12f041d 30 30 #define PROTO_SOCKS4 3 31 31 #define PROTO_SOCKS5 4 32 #define PROTO_SOCKS4A 5 32 33 #define PROTO_DEFAULT PROTO_HTTP 33 34
Note: See TracChangeset
for help on using the changeset viewer.