aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2013-02-04 06:51:03 -0800
committerJeff Garzik <jgarzik@exmulti.com>2013-02-04 06:51:03 -0800
commit353b7f4a9c280ae02577b35cadb61783943493bc (patch)
treef38ae5d0e3bf787150fdc1fc7dcd64749691a6e1
parent2daa2c13e1d35d51cc3f70b2a7ff345810ae7f3d (diff)
parentaf8998824c7c1c762c6b47c32afefb7d1f4f0276 (diff)
Merge pull request #2237 from petertodd/testnet-dnsseed
Add DNS seed support for testnet
-rw-r--r--src/net.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/net.cpp b/src/net.cpp
index a6017b7356..3406a28b0e 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1145,11 +1145,17 @@ void MapPort()
// Each pair gives a source name and a seed name.
// The first name is used as information source for addrman.
// The second name should resolve to a list of seed addresses.
-static const char *strDNSSeed[][2] = {
+static const char *strMainNetDNSSeed[][2] = {
{"bitcoin.sipa.be", "seed.bitcoin.sipa.be"},
{"bluematt.me", "dnsseed.bluematt.me"},
{"dashjr.org", "dnsseed.bitcoin.dashjr.org"},
{"xf2.org", "bitseed.xf2.org"},
+ {NULL, NULL}
+};
+
+static const char *strTestNetDNSSeed[][2] = {
+ {"bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org"},
+ {NULL, NULL}
};
void ThreadDNSAddressSeed(void* parg)
@@ -1175,32 +1181,31 @@ void ThreadDNSAddressSeed(void* parg)
void ThreadDNSAddressSeed2(void* parg)
{
+ static const char *(*strDNSSeed)[2] = fTestNet ? strTestNetDNSSeed : strMainNetDNSSeed;
+
printf("ThreadDNSAddressSeed started\n");
int found = 0;
- if (!fTestNet)
- {
- printf("Loading addresses from DNS seeds (could take a while)\n");
-
- for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
- if (HaveNameProxy()) {
- AddOneShot(strDNSSeed[seed_idx][1]);
- } else {
- vector<CNetAddr> vaddr;
- vector<CAddress> vAdd;
- if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
+ printf("Loading addresses from DNS seeds (could take a while)\n");
+
+ for (unsigned int seed_idx = 0; strDNSSeed[seed_idx][0] != NULL; seed_idx++) {
+ if (HaveNameProxy()) {
+ AddOneShot(strDNSSeed[seed_idx][1]);
+ } else {
+ vector<CNetAddr> vaddr;
+ vector<CAddress> vAdd;
+ if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
+ {
+ BOOST_FOREACH(CNetAddr& ip, vaddr)
{
- BOOST_FOREACH(CNetAddr& ip, vaddr)
- {
- int nOneDay = 24*3600;
- CAddress addr = CAddress(CService(ip, GetDefaultPort()));
- addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
- vAdd.push_back(addr);
- found++;
- }
+ int nOneDay = 24*3600;
+ CAddress addr = CAddress(CService(ip, GetDefaultPort()));
+ addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
+ vAdd.push_back(addr);
+ found++;
}
- addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true));
}
+ addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true));
}
}