Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/haad/proxychains.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Flores <domain@me.com>2018-03-30 21:14:18 +0300
committerAlex Flores <domain@me.com>2018-04-13 04:35:23 +0300
commitbd207014a20b41554207fc9ac9457e61ab570429 (patch)
tree4872ca62e7225829e84c8f0810d0f514c77245db
parentc38374ab5b21464b6a5ee6137393b236faeceff0 (diff)
patch for better random proxy selection
-rw-r--r--src/core.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index c3a624d..b0e3f21 100644
--- a/src/core.c
+++ b/src/core.c
@@ -514,6 +514,19 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
return SOCKET_ERROR;
}
+unsigned int get_rand_int(unsigned int range){
+ static FILE *fp;
+ unsigned int randval;
+ if (!fp) {
+ fp = fopen("/dev/urandom", "r");
+ }
+ if(fread(&randval, sizeof(randval), 1, fp)) {
+ return (randval % range);
+ } else {
+ srand((unsigned int)time(NULL));
+ return (rand() % range);
+ }
+}
static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int proxy_count, unsigned int *offset) {
unsigned int i = 0, k = 0;
@@ -522,10 +535,10 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
return NULL;
switch (how) {
case RANDOMLY:
- srand((unsigned int)time(NULL));
+
do {
k++;
- i = 0 + (unsigned int) (proxy_count * 1.0 * rand() / (RAND_MAX + 1.0));
+ i = 0 + get_rand_int(proxy_count);
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
break;
case FIFOLY: