result permutation
This commit is contained in:
parent
c5fc5b4efb
commit
d14cd8adb6
2 changed files with 12 additions and 3 deletions
4
dns.c
4
dns.c
|
@ -295,8 +295,8 @@ ssize_t static dnshandle(dns_opt_t *opt, const unsigned char *inbuf, size_t insi
|
|||
|
||||
// A records
|
||||
if ((typ == TYPE_A || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY)) {
|
||||
struct in_addr addr[20];
|
||||
int naddr = opt->cb(addr, 20, 1);
|
||||
struct in_addr addr[32];
|
||||
int naddr = opt->cb(addr, 32, 1);
|
||||
int n = 0;
|
||||
while (n < naddr) {
|
||||
int ret = write_record_a(&outpos, outend - auth_size, "", offset, CLASS_IN, opt->datattl, &addr[n]);
|
||||
|
|
11
main.cpp
11
main.cpp
|
@ -44,12 +44,21 @@ extern "C" int GetIPList(struct in_addr *addr, int max, int ipv4only) {
|
|||
if ((*it).GetInAddr(&addr[n]))
|
||||
n++;
|
||||
}
|
||||
// permute list
|
||||
for (int i=0; i<n; i++) {
|
||||
int k = i + (rand() % (n-i));
|
||||
if (i != k) {
|
||||
struct in_addr sw = addr[i];
|
||||
addr[i] = addr[k];
|
||||
addr[k] = sw;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
extern "C" void* ThreadDNS(void*) {
|
||||
dns_opt_t opt;
|
||||
opt.host = "seedtest.bitcoin.sipa.be";
|
||||
opt.host = "seed.bitcoin.sipa.be";
|
||||
opt.ns = "vps.sipa.be";
|
||||
opt.mbox = "sipa.ulyssis.org";
|
||||
opt.datattl = 60;
|
||||
|
|
Loading…
Add table
Reference in a new issue