X-Git-Url: http://www.git.stargrave.org/?p=dht-bootstrap.git;a=blobdiff_plain;f=dht-bootstrap.c;h=28f3fd26e4281a4b5545a6b50f6a5964bb2113b8;hp=e98cd6ea6bd5f2e4c9be46d714e6bf54bf56d851;hb=8bc75da6ede09929e212171c38ea356aeda387fc;hpb=1462580556aa27a98819e58f74264cd00d8cd5d6 diff --git a/dht-bootstrap.c b/dht-bootstrap.c index e98cd6e..28f3fd2 100644 --- a/dht-bootstrap.c +++ b/dht-bootstrap.c @@ -354,9 +354,7 @@ send_request(struct circular_list *list, int dopop, int doping, int want) return send_ping((struct sockaddr *)&ss, sslen, ttid, 4); } else { unsigned char id[20]; - int i; - for (i = 0; i < 20; i++) - id[i] = random() & 0xFF; + arc4random_buf(id, sizeof id); make_tid(ttid, "fn", 0); debugf("Sending find_node.\n"); return send_find_node((struct sockaddr *)&ss, sslen, ttid, 4, id, want); @@ -442,26 +440,7 @@ main(int argc, char **argv) dht_socket6 = newSock(ipv6addr, port); } - int rc = 0; - { - int fd = open("/dev/urandom", O_RDONLY); - if (fd < 0) { - perror("open(random)"); - exit(1); - } - - rc = read(fd, myid, 20); - if (rc < 20) { - perror("open(random)"); - exit(1); - } - - unsigned int seed; - rc = read(fd, &seed, sizeof(seed)); - srandom(seed); - - close(fd); - } + arc4random_buf(myid, sizeof myid); memcpy(my_v, "1:v4:JB\0\0", 9); have_v = 1; @@ -469,6 +448,7 @@ main(int argc, char **argv) if (!quiet) dht_debug = stdout; + int rc = 0; unsigned char ttid[4]; while (i < argc) {