10 #include "validation.h" 22 #include <boost/foreach.hpp> 30 if (fHelp || params.
size() != 0)
32 "getconnectioncount\n" 33 "\nReturns the number of connections to other nodes.\n" 35 "n (numeric) The connection count\n" 49 if (fHelp || params.
size() != 0)
52 "\nRequests that a ping be sent to all other nodes, to measure ping time.\n" 53 "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n" 54 "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n" 72 if (fHelp || params.
size() != 0)
75 "\nReturns data about each connected network node as a json array of objects.\n" 79 " \"id\": n, (numeric) Peer index\n" 80 " \"addr\":\"host:port\", (string) The ip address and port of the peer\n" 81 " \"addrlocal\":\"ip:port\", (string) local address\n" 82 " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n" 83 " \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n" 84 " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n" 85 " \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n" 86 " \"bytessent\": n, (numeric) The total bytes sent\n" 87 " \"bytesrecv\": n, (numeric) The total bytes received\n" 88 " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n" 89 " \"timeoffset\": ttt, (numeric) The time offset in seconds\n" 90 " \"pingtime\": n, (numeric) ping time (if available)\n" 91 " \"minping\": n, (numeric) minimum observed ping time (if any at all)\n" 92 " \"pingwait\": n, (numeric) ping wait (if non-zero)\n" 93 " \"version\": v, (numeric) The peer version, such as 7001\n" 94 " \"subver\": \"/Dash Core:x.x.x/\", (string) The string version\n" 95 " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" 96 " \"startingheight\": n, (numeric) The starting height (block) of the peer\n" 97 " \"banscore\": n, (numeric) The ban score\n" 98 " \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" 99 " \"synced_blocks\": n, (numeric) The last block we have in common with this peer\n" 101 " n, (numeric) The heights of blocks we're currently asking from this peer\n" 104 " \"bytessent_per_msg\": {\n" 105 " \"addr\": n, (numeric) The total bytes sent aggregated by message type\n" 108 " \"bytesrecv_per_msg\": {\n" 109 " \"addr\": n, (numeric) The total bytes received aggregated by message type\n" 123 vector<CNodeStats> vstats;
128 BOOST_FOREACH(
const CNodeStats& stats, vstats) {
146 if (stats.
dMinPing < std::numeric_limits<int64_t>::max()/1e6)
192 if (params.
size() == 2)
193 strCommand = params[1].get_str();
194 if (fHelp || params.
size() != 2 ||
195 (strCommand !=
"onetry" && strCommand !=
"add" && strCommand !=
"remove"))
197 "addnode \"node\" \"add|remove|onetry\"\n" 198 "\nAttempts add or remove a node from the addnode list.\n" 199 "Or try a connection to a node once.\n" 201 "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" 202 "2. \"command\" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once\n" 211 string strNode = params[0].
get_str();
213 if (strCommand ==
"onetry")
216 g_connman->OpenNetworkConnection(addr, NULL, strNode.c_str());
220 if (strCommand ==
"add")
225 else if(strCommand ==
"remove")
236 if (fHelp || params.
size() != 1)
238 "disconnectnode \"node\" \n" 239 "\nImmediately disconnects from the specified node.\n" 241 "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" 250 bool ret =
g_connman->DisconnectNode(params[0].get_str());
259 if (fHelp || params.
size() < 1 || params.
size() > 2)
261 "getaddednodeinfo dummy ( \"node\" )\n" 262 "\nReturns information about the given added node, or all added nodes\n" 263 "(note that onetry addnodes are not listed here)\n" 265 "1. dummy (boolean, required) Kept for historical purposes but ignored\n" 266 "2. \"node\" (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.\n" 270 " \"addednode\" : \"192.168.0.201\", (string) The node ip address or name (as provided to addnode)\n" 271 " \"connected\" : true|false, (boolean) If connected\n" 272 " \"addresses\" : [ (list of objects) Only when connected = true\n" 274 " \"address\" : \"192.168.0.201:9999\", (string) The dash server IP and port we're connected to\n" 275 " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n" 290 std::vector<AddedNodeInfo> vInfo =
g_connman->GetAddedNodeInfo();
292 if (params.
size() == 2) {
295 if (info.strAddedNode == params[1].
get_str()) {
296 vInfo.assign(1, info);
313 if (info.fConnected) {
315 address.
push_back(
Pair(
"address", info.resolvedAddress.ToString()));
316 address.
push_back(
Pair(
"connected", info.fInbound ?
"inbound" :
"outbound"));
328 if (fHelp || params.
size() > 0)
331 "\nReturns information about network traffic, including bytes in, bytes out,\n" 332 "and current time.\n" 335 " \"totalbytesrecv\": n, (numeric) Total bytes received\n" 336 " \"totalbytessent\": n, (numeric) Total bytes sent\n" 337 " \"timemillis\": t, (numeric) Total cpu time\n" 338 " \"uploadtarget\":\n" 340 " \"timeframe\": n, (numeric) Length of the measuring timeframe in seconds\n" 341 " \"target\": n, (numeric) Target in bytes\n" 342 " \"target_reached\": true|false, (boolean) True if target is reached\n" 343 " \"serve_historical_blocks\": true|false, (boolean) True if serving historical blocks\n" 344 " \"bytes_left_in_cycle\": t, (numeric) Bytes left in current time cycle\n" 345 " \"time_left_in_cycle\": t (numeric) Seconds left in current time cycle\n" 394 if (fHelp || params.
size() != 0)
397 "Returns an object containing various state info regarding P2P networking.\n" 400 " \"version\": xxxxx, (numeric) the server version\n" 401 " \"subversion\": \"/Dash Core:x.x.x/\", (string) the server subversion string\n" 402 " \"protocolversion\": xxxxx, (numeric) the protocol version\n" 403 " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" 404 " \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n" 405 " \"timeoffset\": xxxxx, (numeric) the time offset\n" 406 " \"connections\": xxxxx, (numeric) the number of connections\n" 407 " \"networkactive\": true|false, (bool) whether p2p networking is enabled\n" 408 " \"networks\": [ (array) information per network\n" 410 " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n" 411 " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n" 412 " \"reachable\": true|false, (boolean) is the network reachable?\n" 413 " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n" 417 " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in " +
CURRENCY_UNIT +
"/kB\n" 418 " \"localaddresses\": [ (array) list of local addresses\n" 420 " \"address\": \"xxxx\", (string) network address\n" 421 " \"port\": xxx, (numeric) network port\n" 422 " \"score\": xxx (numeric) relative score\n" 426 " \"warnings\": \"...\" (string) any network warnings (such as alert messages) \n" 468 if (params.
size() >= 2)
469 strCommand = params[1].get_str();
470 if (fHelp || params.
size() < 2 ||
471 (strCommand !=
"add" && strCommand !=
"remove"))
473 "setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n" 474 "\nAttempts add or remove a IP/Subnet from the banned list.\n" 476 "1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n" 477 "2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n" 478 "3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the ip is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n" 479 "4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n" 490 bool isSubnet =
false;
492 if (params[0].get_str().find(
"/") != string::npos)
497 LookupHost(params[0].get_str().c_str(), resolved,
false);
506 if (strCommand ==
"add")
512 if (params.
size() >= 3 && !params[2].
isNull())
513 banTime = params[2].get_int64();
515 bool absolute =
false;
521 else if(strCommand ==
"remove")
531 if (fHelp || params.
size() != 0)
534 "\nList all banned IPs/Subnets.\n" 547 for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++)
559 return bannedAddresses;
564 if (fHelp || params.
size() != 0)
567 "\nClear all banned IPs.\n" 582 if (fHelp || params.
size() != 1) {
584 "setnetworkactive true|false\n" 585 "Disable/enable all p2p network activity." 593 g_connman->SetNetworkActive(params[0].get_bool());
bool randomize_credentials
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
const std::string CURRENCY_UNIT
static UniValue GetNetworksInfo()
UniValue clearbanned(const UniValue ¶ms, bool fHelp)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::vector< int > vHeightInFlight
bool push_back(const UniValue &val)
UniValue ValueFromAmount(const CAmount &amount)
UniValue listbanned(const UniValue ¶ms, bool fHelp)
mapMsgCmdSize mapRecvBytesPerMsgCmd
UniValue getaddednodeinfo(const UniValue ¶ms, bool fHelp)
UniValue disconnectnode(const UniValue ¶ms, bool fHelp)
std::map< CSubNet, CBanEntry > banmap_t
UniValue setban(const UniValue ¶ms, bool fHelp)
std::string ToStringIPPort(bool fUseGetnameinfo=true) const
CCriticalSection cs_mapLocalHost
CAmount GetFeePerK() const
std::map< CNetAddr, LocalServiceInfo > mapLocalHost
UniValue getconnectioncount(const UniValue ¶ms, bool fHelp)
General application defined errors.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
std::string strSubVersion
UniValue getnettotals(const UniValue ¶ms, bool fHelp)
bool LookupSubNet(const char *pszName, CSubNet &ret)
bool IsReachable(enum Network net)
std::string GetWarnings(const std::string &strFor)
mapMsgCmdSize mapSendBytesPerMsgCmd
std::string banReasonToString()
static const int PROTOCOL_VERSION
UniValue setnetworkactive(const UniValue ¶ms, bool fHelp)
Node has not been added before.
UniValue ping(const UniValue ¶ms, bool fHelp)
Still downloading initial blocks.
std::unique_ptr< CConnman > g_connman
const UniValue NullUniValue
UniValue getpeerinfo(const UniValue ¶ms, bool fHelp)
UniValue getnetworkinfo(const UniValue ¶ms, bool fHelp)
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
std::string GetNetworkName(enum Network net)
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
UniValue addnode(const UniValue ¶ms, bool fHelp)
static const int CLIENT_VERSION
UniValue JSONRPCError(int code, const string &message)
bool IsLimited(enum Network net)
std::string get_str() const