mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-09-05 16:26:57 +00:00
initialize rand seed with nano-second granularity
in scenarios where one is to spin up several processes with the same proxy list in random mode, all processes started in the same second would pick the same proxy due to using the same srand() seed. closes #380
This commit is contained in:
@ -127,8 +127,18 @@ static void setup_hooks(void) {
|
||||
static int close_fds[16];
|
||||
static int close_fds_cnt = 0;
|
||||
|
||||
static unsigned get_rand_seed(void) {
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
return now.tv_sec ^ now.tv_nsec;
|
||||
#else
|
||||
return time(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void do_init(void) {
|
||||
srand(time(NULL));
|
||||
srand(get_rand_seed());
|
||||
core_initialize();
|
||||
|
||||
/* read the config file */
|
||||
|
Reference in New Issue
Block a user