Browse Source

result permutation

pull/1/head
Pieter Wuille 13 years ago
parent
commit
d14cd8adb6
  1. 4
      dns.c
  2. 11
      main.cpp

4
dns.c

@ -295,8 +295,8 @@ ssize_t static dnshandle(dns_opt_t *opt, const unsigned char *inbuf, size_t insi
// A records // A records
if ((typ == TYPE_A || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY)) { if ((typ == TYPE_A || typ == QTYPE_ANY) && (cls == CLASS_IN || cls == QCLASS_ANY)) {
struct in_addr addr[20]; struct in_addr addr[32];
int naddr = opt->cb(addr, 20, 1); int naddr = opt->cb(addr, 32, 1);
int n = 0; int n = 0;
while (n < naddr) { while (n < naddr) {
int ret = write_record_a(&outpos, outend - auth_size, "", offset, CLASS_IN, opt->datattl, &addr[n]); int ret = write_record_a(&outpos, outend - auth_size, "", offset, CLASS_IN, opt->datattl, &addr[n]);

11
main.cpp

@ -44,12 +44,21 @@ extern "C" int GetIPList(struct in_addr *addr, int max, int ipv4only) {
if ((*it).GetInAddr(&addr[n])) if ((*it).GetInAddr(&addr[n]))
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; return n;
} }
extern "C" void* ThreadDNS(void*) { extern "C" void* ThreadDNS(void*) {
dns_opt_t opt; dns_opt_t opt;
opt.host = "seedtest.bitcoin.sipa.be"; opt.host = "seed.bitcoin.sipa.be";
opt.ns = "vps.sipa.be"; opt.ns = "vps.sipa.be";
opt.mbox = "sipa.ulyssis.org"; opt.mbox = "sipa.ulyssis.org";
opt.datattl = 60; opt.datattl = 60;

Loading…
Cancel
Save