mirror of
https://github.com/rofl0r/proxychains-ng
synced 2025-02-08 22:03:09 +08:00
Fix select_proxy dead loop in round_roubin_chain
Fix issue #147. If all proxies are in DOWN_STATE or BUSY_STATE state, select_proxy will run forever in an infinite loop. When all proxies are not available, we wait some intervals and retry. The wait time starts with 10 milliseconds and is increased by 10 milliiseconds in each loop. 14 loops sums up with 1.05 second.
This commit is contained in:
parent
1c8f8e4e7e
commit
275e64499e
19
src/core.c
19
src/core.c
@ -569,6 +569,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
unsigned int curr_len = 0;
|
||||
unsigned int curr_pos = 0;
|
||||
unsigned int looped = 0; // went back to start of list in RR mode
|
||||
int rr_loop_max = 14;
|
||||
|
||||
p3 = &p4;
|
||||
|
||||
@ -615,13 +616,17 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
/* We've reached the end of the list, go to the start */
|
||||
offset = 0;
|
||||
looped++;
|
||||
continue;
|
||||
} else if (looped && rc > 0 && offset >= curr_pos) {
|
||||
PDEBUG("GOTO MORE PROXIES 0\n");
|
||||
/* We've gone back to the start and now past our starting position */
|
||||
proxychains_proxy_offset = 0;
|
||||
goto error_more;
|
||||
}
|
||||
if (looped > rr_loop_max) {
|
||||
proxychains_proxy_offset = 0;
|
||||
goto error_more;
|
||||
} else {
|
||||
PDEBUG("rr_type all proxies down, release all\n");
|
||||
release_all(pd, proxy_count);
|
||||
/* Each loop we wait 10ms more */
|
||||
usleep(10000 * looped);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
PDEBUG("2:rr_offset = %d\n", offset);
|
||||
rc=start_chain(&ns, p1, RRT);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user