This new call allows user to get a list of random address entries from addrman store.
{ "getbestblockhash", &getbestblockhash, true, false },
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
+ { "getaddrmaninfo", &getaddrmaninfo, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
{ "addnode", &addnode, true, true },
{ "getaddednodeinfo", &getaddednodeinfo, true, true },
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 getaddrmaninfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp);
}
}
+Value getaddrmaninfo(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "getaddrmaninfo\n"
+ "Returns a dump of addrman data.");
+
+ vector<CAddress> vAddr = addrman.GetAddr();
+
+ Array ret;
+
+ BOOST_FOREACH(const CAddress &addr, vAddr) {
+ // Don't return addresses older than nCutOff timestamp
+ int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
+
+ if (!addr.IsRoutable() || addr.IsLocal() || addr.nTime > nCutOff)
+ continue;
+
+ Object addrManItem;
+ addrManItem.push_back(Pair("address", addr.ToString()));
+
+ string strNetType;
+ switch(addr.GetNetwork())
+ {
+ case NET_TOR:
+ strNetType = "tor";
+ break;
+ case NET_I2P:
+ strNetType = "i2p";
+ case NET_IPV4:
+ strNetType = "ipv4";
+ break;
+ default:
+ case NET_IPV6:
+ strNetType = "ipv6";
+
+ }
+ addrManItem.push_back(Pair("type", strNetType));
+ addrManItem.push_back(Pair("time", (int64_t)addr.nTime));
+
+ ret.push_back(addrManItem);
+ }
+
+ return ret;
+}
+
Value getpeerinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)