Skip to content

Commit b8cdfe8

Browse files
committed
allow non-numeric proxy ips under certain circumstances
conditions that need to be met are: 1) chaintype strict 2) proxy_dns on 3) not the first proxy in the list if these conditions are met, the dns name can be passed to be receiving proxy and be resolved there. addressing #246 (comment)
1 parent 9f17774 commit b8cdfe8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/libproxychains.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ static int proxy_from_string(const char *proxystring,
256256
return 0;
257257
}
258258

259+
static const char* bool_str(int bool_val) {
260+
if(bool_val) return "true";
261+
return "false";
262+
}
259263

260264
/* get configuration from config file */
261265
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
@@ -311,8 +315,20 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
311315
pd[count].port = htons((unsigned short) port_n);
312316
ip_type* host_ip = &pd[count].ip;
313317
if(1 != inet_pton(host_ip->is_v6 ? AF_INET6 : AF_INET, host, host_ip->addr.v6)) {
314-
fprintf(stderr, "proxy %s has invalid value or is not numeric\n", host);
315-
exit(1);
318+
if(*ct == STRICT_TYPE && proxychains_resolver && count > 0) {
319+
/* we can allow dns hostnames for all but the first proxy in the list if chaintype is strict, as remote lookup can be done */
320+
ip_type4 internal_ip = at_get_ip_for_host(host, strlen(host));
321+
pd[count].ip.is_v6 = 0;
322+
host_ip->addr.v4 = internal_ip;
323+
if(internal_ip.as_int == ip_type_invalid.addr.v4.as_int)
324+
goto inv_host;
325+
} else {
326+
inv_host:
327+
fprintf(stderr, "proxy %s has invalid value or is not numeric\n", host);
328+
fprintf(stderr, "non-numeric ips are only allowed under the following circumstances:\n");
329+
fprintf(stderr, "chaintype == strict (%s), proxy is not first in list (%s), proxy_dns active (%s)\n\n", bool_str(*ct == STRICT_TYPE), bool_str(count > 0), bool_str(proxychains_resolver));
330+
exit(1);
331+
}
316332
}
317333

318334
if(!strcmp(type, "http")) {

0 commit comments

Comments
 (0)