aboutsummaryrefslogtreecommitdiff
path: root/net.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-03-08 22:40:50 -0500
committerJeff Garzik <jgarzik@pobox.com>2011-03-08 22:40:50 -0500
commitf684aec4f38d6a9e48e870ca5dae6bd65da516cf (patch)
treee22936135a00387dbffe4a13a32ca0244401c26f /net.cpp
parentf36b494aebcfe4cc6a45003520ee7d15eeaba8df (diff)
downloadbitcoin-f684aec4f38d6a9e48e870ca5dae6bd65da516cf.tar.xz
DNS seeding
Diffstat (limited to 'net.cpp')
-rw-r--r--net.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/net.cpp b/net.cpp
index d18b63eb5f..798c7e5622 100644
--- a/net.cpp
+++ b/net.cpp
@@ -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");
+}