diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-03-13 17:15:59 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-03-13 17:15:59 -0400 |
commit | 4b88647966a1144b5e5532fef50bbf34f9402e71 (patch) | |
tree | 8076c58bc252fe5b68e42776dfe395911633be8b | |
parent | d43fd8a038b7e5068e5db357ba7a9006da812d8a (diff) | |
parent | 448b4516ff982052e375d42059bcf0fb7e58589f (diff) |
Merge branch 'dns-seed' of https://github.com/jgarzik/bitcoin
-rw-r--r-- | init.cpp | 3 | ||||
-rw-r--r-- | net.cpp | 27 | ||||
-rw-r--r-- | net.h | 1 |
3 files changed, 31 insertions, 0 deletions
@@ -429,6 +429,9 @@ bool AppInit2(int argc, char* argv[]) } } + if (mapArgs.count("-dnsseed")) + DNSAddressSeed(); + if (mapArgs.count("-paytxfee")) { if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) @@ -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); +} @@ -30,6 +30,7 @@ CNode* FindNode(unsigned int ip); CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0); void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1); bool AnySubscribed(unsigned int nChannel); +void DNSAddressSeed(); bool BindListenPort(string& strError=REF(string())); void StartNode(void* parg); bool StopNode(); |