Browse Source

new rpc adddnsseed

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
bd479f0b2e
  1. 1
      src/bitcoinrpc.cpp
  2. 1
      src/bitcoinrpc.h
  3. 26
      src/net.cpp
  4. 2
      src/net.h
  5. 14
      src/rpcnet.cpp

1
src/bitcoinrpc.cpp

@ -204,6 +204,7 @@ static const CRPCCommand vRPCCommands[] = @@ -204,6 +204,7 @@ static const CRPCCommand vRPCCommands[] =
{ "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
{ "addnode", &addnode, true, true },
{ "adddnsseed", &adddnsseed, true, true },
{ "getaddednodeinfo", &getaddednodeinfo, true, true },
{ "getdifficulty", &getdifficulty, true, false },
{ "getgenerate", &getgenerate, true, false },

1
src/bitcoinrpc.h

@ -143,6 +143,7 @@ extern void EnsureWalletIsUnlocked(); @@ -143,6 +143,7 @@ extern void EnsureWalletIsUnlocked();
extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp
extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value adddnsseed(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp

26
src/net.cpp

@ -1174,11 +1174,17 @@ void MapPort(bool) @@ -1174,11 +1174,17 @@ void MapPort(bool)
void ThreadDNSAddressSeed()
void _ThreadDNSAddressSeed(const char *strDNS)
{
const vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
vector<CDNSSeedData> vSeeds = Params().DNSSeeds();
int found = 0;
if( strDNS ) {
printf("ThreadDNSAddressSeed: %s\n", strDNS);
vSeeds.clear();
vSeeds.push_back(CDNSSeedData(strDNS, strDNS));
}
printf("Loading addresses from DNS seeds (could take a while)\n");
BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) {
@ -1203,10 +1209,24 @@ void ThreadDNSAddressSeed() @@ -1203,10 +1209,24 @@ void ThreadDNSAddressSeed()
}
printf("%d addresses found from DNS seeds\n", found);
}
if( strDNS ) {
delete [] strDNS;
}
}
void ThreadDNSAddressSeed()
{
_ThreadDNSAddressSeed(NULL);
}
void AddDNSandRunThread(std::string strDNS)
{
boost::thread_group threadGroup;
char *strCopyOfDNS = new char [strDNS.length()+1];
strcpy(strCopyOfDNS, strDNS.c_str());
threadGroup.create_thread(boost::bind(_ThreadDNSAddressSeed, strCopyOfDNS));
}

2
src/net.h

@ -82,7 +82,7 @@ bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL); @@ -82,7 +82,7 @@ bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
bool IsReachable(const CNetAddr &addr);
void SetReachable(enum Network net, bool fFlag = true);
CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
void AddDNSandRunThread(std::string strDNS);
extern bool fDiscover;
extern uint64 nLocalServices;

14
src/rpcnet.cpp

@ -110,6 +110,20 @@ Value addnode(const Array& params, bool fHelp) @@ -110,6 +110,20 @@ Value addnode(const Array& params, bool fHelp)
return Value::null;
}
Value adddnsseed(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1 )
throw runtime_error(
"adddnsseed <seeder>\n"
"Add a different DNS <seeder> to obtain node list from.");
string strDNS = params[0].get_str();
AddDNSandRunThread(strDNS);
return Value::null;
}
Value getaddednodeinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)

Loading…
Cancel
Save