DNS seeding

This commit is contained in:
Jeff Garzik
2011-03-08 22:40:50 -05:00
committed by Jeff Garzik
parent f36b494aeb
commit f684aec4f3
3 changed files with 31 additions and 0 deletions

27
net.cpp
View File

@@ -857,7 +857,34 @@ void ThreadSocketHandler2(void* parg)
static const char *strDNSSeed[] = {
"bitseed.xf2.org",
};
void DNSAddressSeed()
{
int found = 0;
printf("Loading addresses from DNS seeds (could take a while)\n");
for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
struct hostent* phostent = gethostbyname(strDNSSeed[seed_idx]);
if (!phostent)
continue;
for (int host = 0; phostent->h_addr_list[host] != NULL; host++) {
CAddress addr(*(unsigned int*)phostent->h_addr_list[host],
GetDefaultPort(), NODE_NETWORK);
addr.nTime = 0;
if (addr.IsValid() && addr.GetByte(3) != 127) {
AddAddress(addr);
found++;
}
}
}
printf("%d addresses found from DNS seeds\n");
}