mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
new rpc adddnsseed
This commit is contained in:
parent
a2c87535c0
commit
bd479f0b2e
@ -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 },
|
||||
|
@ -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
26
src/net.cpp
@ -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()
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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…
x
Reference in New Issue
Block a user