diff options
| author | Gavin Andresen <[email protected]> | 2011-03-13 17:15:59 -0400 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2011-03-13 17:15:59 -0400 |
| commit | 4b88647966a1144b5e5532fef50bbf34f9402e71 (patch) | |
| tree | 8076c58bc252fe5b68e42776dfe395911633be8b /net.cpp | |
| parent | Merge branch 'log-timestamp' of https://github.com/TheBlueMatt/bitcoin (diff) | |
| parent | dnsseed: fix printf (diff) | |
| download | discoin-4b88647966a1144b5e5532fef50bbf34f9402e71.tar.xz discoin-4b88647966a1144b5e5532fef50bbf34f9402e71.zip | |
Merge branch 'dns-seed' of https://github.com/jgarzik/bitcoin
Diffstat (limited to 'net.cpp')
| -rw-r--r-- | net.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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", found); +} |