PRCYCoin  2.0.0.7rc1
P2P Digital Currency
net.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2015 The Bitcoin developers
2 // Copyright (c) 2014-2015 The Dash developers
3 // Copyright (c) 2015-2018 The PIVX developers
4 // Copyright (c) 2018-2020 The DAPS Project developers
5 // Distributed under the MIT software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 
8 #include "rpc/server.h"
9 
10 #include "clientversion.h"
11 #include "main.h"
12 #include "net.h"
13 #include "netbase.h"
14 #include "protocol.h"
15 #include "sync.h"
16 #include "timedata.h"
17 #include "guiinterface.h"
18 #include "util.h"
19 #include "version.h"
20 
21 #include <univalue.h>
22 
23 
24 UniValue getconnectioncount(const UniValue& params, bool fHelp)
25 {
26  if (fHelp || params.size() != 0)
27  throw std::runtime_error(
28  "getconnectioncount\n"
29  "\nReturns the number of connections to other nodes.\n"
30  "\nbResult:\n"
31  "n (numeric) The connection count\n"
32  "\nExamples:\n" +
33  HelpExampleCli("getconnectioncount", "") + HelpExampleRpc("getconnectioncount", ""));
34 
36  return (int)vNodes.size();
37 }
38 
39 UniValue ping(const UniValue& params, bool fHelp)
40 {
41  if (fHelp || params.size() != 0)
42  throw std::runtime_error(
43  "ping\n"
44  "\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
45  "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
46  "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n"
47  "\nExamples:\n" +
48  HelpExampleCli("ping", "") + HelpExampleRpc("ping", ""));
49 
50  // Request that each node send a ping during next message processing pass
52  for (CNode* pNode : vNodes) {
53  pNode->fPingQueued = true;
54  }
55 
56  return "Done";
57 }
58 
59 static void CopyNodeStats(std::vector<CNodeStats>& vstats)
60 {
61  vstats.clear();
62 
63  LOCK(cs_vNodes);
64  vstats.reserve(vNodes.size());
65  for (CNode* pnode : vNodes) {
66  CNodeStats stats;
67  pnode->copyStats(stats);
68  vstats.push_back(stats);
69  }
70 }
71 
72 UniValue getpeerinfo(const UniValue& params, bool fHelp)
73 {
74  if (fHelp || params.size() != 0)
75  throw std::runtime_error(
76  "getpeerinfo\n"
77  "\nReturns data about each connected network node as a json array of objects.\n"
78  "\nbResult:\n"
79  "[\n"
80  " {\n"
81  " \"id\": n, (numeric) Peer index\n"
82  " \"addr\":\"host:port\", (string) The ip address and port of the peer\n"
83  " \"addrlocal\":\"ip:port\", (string) local address\n"
84  " \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n"
85  " \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n"
86  " \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n"
87  " \"bytessent\": n, (numeric) The total bytes sent\n"
88  " \"bytesrecv\": n, (numeric) The total bytes received\n"
89  " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n"
90  " \"timeoffset\": ttt, (numeric) The time offset in seconds\n"
91  " \"pingtime\": n, (numeric) ping time\n"
92  " \"pingwait\": n, (numeric) ping wait\n"
93  " \"version\": v, (numeric) The peer version, such as 7001\n"
94  " \"subver\": \"/Prcycoin Core:x.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"
100  " \"inflight\": [\n"
101  " n, (numeric) The heights of blocks we're currently asking from this peer\n"
102  " ...\n"
103  " ]\n"
104  " }\n"
105  " ,...\n"
106  "]\n"
107  "\nExamples:\n" +
108  HelpExampleCli("getpeerinfo", "") + HelpExampleRpc("getpeerinfo", ""));
109 
110  LOCK(cs_main);
111 
112  std::vector<CNodeStats> vstats;
113  CopyNodeStats(vstats);
114 
116 
117  for (const CNodeStats& stats : vstats) {
119  CNodeStateStats statestats;
120  bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
121  obj.push_back(Pair("id", stats.nodeid));
122  obj.push_back(Pair("addr", stats.addrName));
123  if (!(stats.addrLocal.empty()))
124  obj.push_back(Pair("addrlocal", stats.addrLocal));
125  obj.push_back(Pair("services", strprintf("%016x", stats.nServices)));
126  obj.push_back(Pair("lastsend", stats.nLastSend));
127  obj.push_back(Pair("lastrecv", stats.nLastRecv));
128  obj.push_back(Pair("bytessent", stats.nSendBytes));
129  obj.push_back(Pair("bytesrecv", stats.nRecvBytes));
130  obj.push_back(Pair("conntime", stats.nTimeConnected));
131  obj.push_back(Pair("timeoffset", stats.nTimeOffset));
132  obj.push_back(Pair("pingtime", stats.dPingTime));
133  if (stats.dPingWait > 0.0)
134  obj.push_back(Pair("pingwait", stats.dPingWait));
135  obj.push_back(Pair("version", stats.nVersion));
136  // Use the sanitized form of subver here, to avoid tricksy remote peers from
137  // corrupting or modifiying the JSON output by putting special characters in
138  // their ver message.
139  obj.push_back(Pair("subver", stats.cleanSubVer));
140  obj.push_back(Pair("inbound", stats.fInbound));
141  obj.push_back(Pair("startingheight", stats.nStartingHeight));
142  if (fStateStats) {
143  obj.push_back(Pair("banscore", statestats.nMisbehavior));
144  obj.push_back(Pair("synced_headers", statestats.nSyncHeight));
145  obj.push_back(Pair("synced_blocks", statestats.nCommonHeight));
146  UniValue heights(UniValue::VARR);
147  for (int height : statestats.vHeightInFlight) {
148  heights.push_back(height);
149  }
150  obj.push_back(Pair("inflight", heights));
151  }
152  obj.push_back(Pair("whitelisted", stats.fWhitelisted));
153 
154  ret.push_back(obj);
155  }
156 
157  return ret;
158 }
159 
160 UniValue addnode(const UniValue& params, bool fHelp)
161 {
162  std::string strCommand;
163  if (params.size() == 2)
164  strCommand = params[1].get_str();
165  if (fHelp || params.size() != 2 ||
166  (strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
167  throw std::runtime_error(
168  "addnode \"node\" \"add|remove|onetry\"\n"
169  "\nAttempts add or remove a node from the addnode list.\n"
170  "Or try a connection to a node once.\n"
171  "\nArguments:\n"
172  "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
173  "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"
174  "\nExamples:\n" +
175  HelpExampleCli("addnode", "\"192.168.0.6:59682\" \"onetry\"") + HelpExampleRpc("addnode", "\"192.168.0.6:59682\", \"onetry\""));
176 
177  std::string strNode = params[0].get_str();
178 
179  if (strCommand == "onetry") {
180  CAddress addr;
181  OpenNetworkConnection(addr, false, NULL, strNode.c_str());
182  return NullUniValue;
183  }
184 
186  std::vector<std::string>::iterator it = vAddedNodes.begin();
187  for (; it != vAddedNodes.end(); it++)
188  if (strNode == *it)
189  break;
190 
191  if (strCommand == "add") {
192  if (it != vAddedNodes.end())
193  throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
194  vAddedNodes.push_back(strNode);
195  } else if (strCommand == "remove") {
196  if (it == vAddedNodes.end())
197  throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
198  vAddedNodes.erase(it);
199  }
200 
201  return "Done";
202 }
203 
204 UniValue disconnectnode(const UniValue& params, bool fHelp)
205 {
206  if (fHelp || params.size() != 1)
207  throw std::runtime_error(
208  "disconnectnode \"node\" \n"
209  "\nImmediately disconnects from the specified node.\n"
210  "\nArguments:\n"
211  "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
212  "\nExamples:\n"
213  + HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"")
214  + HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"")
215  );
216  CNode* pNode = FindNode(params[0].get_str());
217  if (pNode == NULL)
218  throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes");
219  pNode->CloseSocketDisconnect();
220  return "Done";
221 }
222 
223 UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
224 {
225  if (fHelp || params.size() < 1 || params.size() > 2)
226  throw std::runtime_error(
227  "getaddednodeinfo dummy ( \"node\" )\n"
228  "\nReturns information about the given added node, or all added nodes\n"
229  "(note that onetry addnodes are not listed here)\n"
230 
231  "\nArguments:\n"
232  "1. dummy (boolean, required) Kept for historical purposes but ignored\n"
233  "2. \"node\" (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.\n"
234 
235  "\nResult:\n"
236  "[\n"
237  " {\n"
238  " \"addednode\" : \"192.168.0.201\", (string) The node ip address or name (as provided to addnode)\n"
239  " \"connected\" : true|false, (boolean) If connected\n"
240  " \"addresses\" : [ (list of objects) Only when connected = true\n"
241  " {\n"
242  " \"address\" : \"192.168.0.201:51472\", (string) The prcycoin server IP and port we're connected to\n"
243  " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n"
244  " }\n"
245  " ]\n"
246  " }\n"
247  " ,...\n"
248  "]\n"
249 
250  "\nExamples:\n" +
251  HelpExampleCli("getaddednodeinfo", "true") + HelpExampleCli("getaddednodeinfo", "true \"192.168.0.201\"") + HelpExampleRpc("getaddednodeinfo", "true, \"192.168.0.201\""));
252 
253  std::vector<AddedNodeInfo> vInfo = GetAddedNodeInfo();
254 
255  if (params.size() == 2) {
256  bool found = false;
257  for (const AddedNodeInfo& info : vInfo) {
258  if (info.strAddedNode == params[1].get_str()) {
259  vInfo.assign(1, info);
260  found = true;
261  break;
262  }
263  }
264  if (!found) {
265  throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
266  }
267  }
268 
270 
271  for (const AddedNodeInfo& info : vInfo) {
273  obj.push_back(Pair("addednode", info.strAddedNode));
274  obj.push_back(Pair("connected", info.fConnected));
275  UniValue addresses(UniValue::VARR);
276  if (info.fConnected) {
277  UniValue address(UniValue::VOBJ);
278  address.push_back(Pair("address", info.resolvedAddress.ToString()));
279  address.push_back(Pair("connected", info.fInbound ? "inbound" : "outbound"));
280  addresses.push_back(address);
281  }
282  obj.push_back(Pair("addresses", addresses));
283  ret.push_back(obj);
284  }
285 
286  return ret;
287 }
288 
289 UniValue getnettotals(const UniValue& params, bool fHelp)
290 {
291  if (fHelp || params.size() > 0)
292  throw std::runtime_error(
293  "getnettotals\n"
294  "\nReturns information about network traffic, including bytes in, bytes out,\n"
295  "and current time.\n"
296  "\nResult:\n"
297  "{\n"
298  " \"totalbytesrecv\": n, (numeric) Total bytes received\n"
299  " \"totalbytessent\": n, (numeric) Total bytes sent\n"
300  " \"timemillis\": t (numeric) Total cpu time\n"
301  "}\n"
302  "\nExamples:\n" +
303  HelpExampleCli("getnettotals", "") + HelpExampleRpc("getnettotals", ""));
304 
306  obj.push_back(Pair("totalbytesrecv", CNode::GetTotalBytesRecv()));
307  obj.push_back(Pair("totalbytessent", CNode::GetTotalBytesSent()));
308  obj.push_back(Pair("timemillis", GetTimeMillis()));
309  return obj;
310 }
311 
312 static UniValue GetNetworksInfo()
313 {
314  UniValue networks(UniValue::VARR);
315  for (int n = 0; n < NET_MAX; ++n) {
316  enum Network network = static_cast<enum Network>(n);
317  if (network == NET_UNROUTABLE)
318  continue;
319  proxyType proxy;
321  GetProxy(network, proxy);
322  obj.push_back(Pair("name", GetNetworkName(network)));
323  obj.push_back(Pair("limited", IsLimited(network)));
324  obj.push_back(Pair("reachable", IsReachable(network)));
325  obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()));
326  obj.push_back(Pair("proxy_randomize_credentials", proxy.randomize_credentials));
327  networks.push_back(obj);
328  }
329  return networks;
330 }
331 
332 UniValue getnetworkinfo(const UniValue& params, bool fHelp)
333 {
334  if (fHelp || params.size() != 0)
335  throw std::runtime_error(
336  "getnetworkinfo\n"
337  "Returns an object containing various state info regarding P2P networking.\n"
338  "\nResult:\n"
339  "{\n"
340  " \"version\": xxxxx, (numeric) the server version\n"
341  " \"subversion\": \"/Prcycoin Core:x.x.x.x/\", (string) the server subversion string\n"
342  " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
343  " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
344  " \"timeoffset\": xxxxx, (numeric) the time offset\n"
345  " \"connections\": xxxxx, (numeric) the number of connections\n"
346  " \"networks\": [ (array) information per network\n"
347  " {\n"
348  " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n"
349  " \"limited\": true|false, (boolean) is the network limited using -onlynet?\n"
350  " \"reachable\": true|false, (boolean) is the network reachable?\n"
351  " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n"
352  " }\n"
353  " ,...\n"
354  " ],\n"
355  " \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in prcycoin/kb\n"
356  " \"localaddresses\": [ (array) list of local addresses\n"
357  " {\n"
358  " \"address\": \"xxxx\", (string) network address\n"
359  " \"port\": xxx, (numeric) network port\n"
360  " \"score\": xxx (numeric) relative score\n"
361  " }\n"
362  " ,...\n"
363  " ]\n"
364  "}\n"
365  "\nExamples:\n" +
366  HelpExampleCli("getnetworkinfo", "") + HelpExampleRpc("getnetworkinfo", ""));
367 
368  LOCK(cs_main);
369 
371  obj.push_back(Pair("version", CLIENT_VERSION));
372  obj.push_back(Pair("subversion", strSubVersion));
373  obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
374  obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
375  obj.push_back(Pair("timeoffset", GetTimeOffset()));
376  obj.push_back(Pair("connections", (int)vNodes.size()));
377  obj.push_back(Pair("networks", GetNetworksInfo()));
378  obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
379  UniValue localAddresses(UniValue::VARR);
380  {
382  for (const std::pair<const CNetAddr, LocalServiceInfo> &item : mapLocalHost) {
384  rec.push_back(Pair("address", item.first.ToString()));
385  rec.push_back(Pair("port", item.second.nPort));
386  rec.push_back(Pair("score", item.second.nScore));
387  localAddresses.push_back(rec);
388  }
389  }
390  obj.push_back(Pair("localaddresses", localAddresses));
391  return obj;
392 }
393 
394 UniValue setban(const UniValue& params, bool fHelp)
395 {
396  std::string strCommand;
397  if (params.size() >= 2)
398  strCommand = params[1].get_str();
399  if (fHelp || params.size() < 2 ||
400  (strCommand != "add" && strCommand != "remove"))
401  throw std::runtime_error(
402  "setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n"
403  "\nAttempts add or remove a IP/Subnet from the banned list.\n"
404  "\nArguments:\n"
405  "1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n"
406  "2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n"
407  "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"
408  "4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
409  "\nExamples:\n"
410  + HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400")
411  + HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"")
412  + HelpExampleRpc("setban", "\"192.168.0.6\", \"add\" 86400")
413  );
414  CSubNet subNet;
415  CNetAddr netAddr;
416  bool isSubnet = false;
417  if (params[0].get_str().find("/") != std::string::npos)
418  isSubnet = true;
419  if (!isSubnet) {
420  CNetAddr resolved;
421  LookupHost(params[0].get_str().c_str(), resolved, false);
422  netAddr = resolved;
423  }
424  else
425  LookupSubNet(params[0].get_str().c_str(), subNet);
426  if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) )
427  throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Invalid IP/Subnet");
428  if (strCommand == "add")
429  {
430  if (isSubnet ? CNode::IsBanned(subNet) : CNode::IsBanned(netAddr))
431  throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned");
432  int64_t banTime = 0; //use standard bantime if not specified
433  if (params.size() >= 3 && !params[2].isNull())
434  banTime = params[2].get_int64();
435  bool absolute = false;
436  if (params.size() == 4)
437  absolute = params[3].get_bool();
438  isSubnet ? CNode::Ban(subNet, BanReasonManuallyAdded, banTime, absolute) : CNode::Ban(netAddr, BanReasonManuallyAdded, banTime, absolute);
439  }
440  else if(strCommand == "remove")
441  {
442  if (!( isSubnet ? CNode::Unban(subNet) : CNode::Unban(netAddr) ))
443  throw JSONRPCError(RPC_MISC_ERROR, "Error: Unban failed");
444  }
445 
446  return "Done";
447 }
448 
449 UniValue listbanned(const UniValue& params, bool fHelp)
450 {
451  if (fHelp || params.size() != 0)
452  throw std::runtime_error(
453  "listbanned\n"
454  "\nList all banned IPs/Subnets.\n"
455  "\nExamples:\n"
456  + HelpExampleCli("listbanned", "")
457  + HelpExampleRpc("listbanned", "")
458  );
459  banmap_t banMap;
460  CNode::GetBanned(banMap);
461  UniValue bannedAddresses(UniValue::VARR);
462  for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++)
463  {
464  CBanEntry banEntry = (*it).second;
466  rec.push_back(Pair("address", (*it).first.ToString()));
467  rec.push_back(Pair("banned_until", banEntry.nBanUntil));
468  rec.push_back(Pair("ban_created", banEntry.nCreateTime));
469  rec.push_back(Pair("ban_reason", banEntry.banReasonToString()));
470  bannedAddresses.push_back(rec);
471  }
472  return bannedAddresses;
473 }
474 
475 UniValue clearbanned(const UniValue& params, bool fHelp)
476 {
477  if (fHelp || params.size() != 0)
478  throw std::runtime_error(
479  "clearbanned\n"
480  "\nClear all banned IPs.\n"
481  "\nExamples:\n"
482  + HelpExampleCli("clearbanned", "")
483  + HelpExampleRpc("clearbanned", "")
484  );
486 
487  return "Done";
488 }
CNodeStats::addrName
std::string addrName
Definition: net.h:189
RPC_MISC_ERROR
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:40
disconnectnode
UniValue disconnectnode(const UniValue &params, bool fHelp)
Definition: net.cpp:204
LOCK2
#define LOCK2(cs1, cs2)
Definition: sync.h:183
setban
UniValue setban(const UniValue &params, bool fHelp)
Definition: net.cpp:394
CNodeStateStats::vHeightInFlight
std::vector< int > vHeightInFlight
Definition: main.h:292
vNodes
std::vector< CNode * > vNodes
Definition: net.cpp:85
CNodeStats::fInbound
bool fInbound
Definition: net.h:192
CNodeStateStats::nCommonHeight
int nCommonHeight
Definition: main.h:291
BanReasonManuallyAdded
@ BanReasonManuallyAdded
Definition: net.h:248
LookupSubNet
bool LookupSubNet(const char *pszName, CSubNet &ret)
Definition: netbase.cpp:667
minRelayTxFee
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
Definition: main.cpp:100
proxyType::IsValid
bool IsValid() const
Definition: netbase.h:34
NET_UNROUTABLE
@ NET_UNROUTABLE
Definition: netaddress.h:21
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:21
UniValue::get_bool
bool get_bool() const
Definition: univalue.cpp:302
CNodeStats::addrLocal
std::string addrLocal
Definition: net.h:199
getpeerinfo
UniValue getpeerinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:72
CNodeStats::nodeid
NodeId nodeid
Definition: net.h:183
CNodeStats::nVersion
int nVersion
Definition: net.h:190
cs_vAddedNodes
RecursiveMutex cs_vAddedNodes
Definition: net.cpp:96
getnetworkinfo
UniValue getnetworkinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:332
ValueFromAmount
UniValue ValueFromAmount(const CAmount &amount)
Definition: server.cpp:118
sync.h
timedata.h
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:78
CNode::GetTotalBytesRecv
static uint64_t GetTotalBytesRecv()
Definition: net.cpp:2097
CNetAddr
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netaddress.h:30
NET_MAX
@ NET_MAX
Definition: netaddress.h:26
CNode
Information about a peer.
Definition: net.h:306
GetAddedNodeInfo
std::vector< AddedNodeInfo > GetAddedNodeInfo()
Definition: net.cpp:1593
protocol.h
CNodeStateStats::nSyncHeight
int nSyncHeight
Definition: main.h:290
clientversion.h
CNodeStateStats::nMisbehavior
int nMisbehavior
Definition: main.h:289
cs_vNodes
RecursiveMutex cs_vNodes
Definition: net.cpp:86
UniValue::isNull
bool isNull() const
Definition: univalue.h:77
CNode::Ban
static void Ban(const CNetAddr &ip, const BanReason &banReason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
Definition: net.cpp:522
CNodeStats::nLastRecv
int64_t nLastRecv
Definition: net.h:186
guiinterface.h
Network
Network
Definition: netaddress.h:19
version.h
FindNode
CNode * FindNode(const CNetAddr &ip)
Definition: net.cpp:301
proxyType
Definition: netbase.h:28
CService::ToStringIPPort
std::string ToStringIPPort() const
Definition: netaddress.cpp:559
UniValue
Definition: univalue.h:19
ping
UniValue ping(const UniValue &params, bool fHelp)
Definition: net.cpp:39
UniValue::get_str
const std::string & get_str() const
Definition: univalue.cpp:309
cs_main
RecursiveMutex cs_main
Global state.
Definition: main.cpp:65
CNodeStats::nTimeConnected
int64_t nTimeConnected
Definition: net.h:187
UniValue::get_int64
int64_t get_int64() const
Definition: univalue.cpp:326
CNode::GetBanned
static void GetBanned(banmap_t &banmap)
Definition: net.cpp:573
listbanned
UniValue listbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:449
clearbanned
UniValue clearbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:475
CNode::Unban
static bool Unban(const CNetAddr &ip)
Definition: net.cpp:556
addnode
UniValue addnode(const UniValue &params, bool fHelp)
Definition: net.cpp:160
IsReachable
bool IsReachable(enum Network net)
check whether a given network is one we can probably connect to
Definition: net.cpp:280
CNodeStats::fWhitelisted
bool fWhitelisted
Definition: net.h:196
CNodeStats::dPingTime
double dPingTime
Definition: net.h:197
cs_mapLocalHost
RecursiveMutex cs_mapLocalHost
Definition: net.cpp:74
LookupHost
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Definition: netbase.cpp:184
univalue.h
AddedNodeInfo
Definition: net.h:796
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: protocol.cpp:60
CNetAddr::IsValid
bool IsValid() const
Definition: netaddress.cpp:188
CSubNet
Definition: netaddress.h:95
CBanEntry::nCreateTime
int64_t nCreateTime
Definition: net.h:256
CNodeStats::cleanSubVer
std::string cleanSubVer
Definition: net.h:191
HelpExampleRpc
std::string HelpExampleRpc(std::string methodname, std::string args)
Definition: server.cpp:607
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition: net.h:302
mapLocalHost
std::map< CNetAddr, LocalServiceInfo > mapLocalHost
Definition: net.cpp:75
CNodeStats::nLastSend
int64_t nLastSend
Definition: net.h:185
CNodeStats::nTimeOffset
int64_t nTimeOffset
Definition: net.h:188
CNode::ClearBanned
static void ClearBanned()
Definition: net.cpp:484
HelpExampleCli
std::string HelpExampleCli(std::string methodname, std::string args)
Definition: server.cpp:603
getnettotals
UniValue getnettotals(const UniValue &params, bool fHelp)
Definition: net.cpp:289
GetTimeMillis
int64_t GetTimeMillis()
Definition: utiltime.cpp:31
getaddednodeinfo
UniValue getaddednodeinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:223
CNodeStats::dPingWait
double dPingWait
Definition: net.h:198
strprintf
#define strprintf
Definition: tinyformat.h:1056
strSubVersion
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
Definition: net.cpp:83
CNodeStats::nSendBytes
uint64_t nSendBytes
Definition: net.h:194
CAddress
A CService with information about it as peer.
Definition: protocol.h:323
CNode::GetTotalBytesSent
static uint64_t GetTotalBytesSent()
Definition: net.cpp:2102
main.h
CBanEntry::banReasonToString
std::string banReasonToString()
Definition: net.h:289
proxyType::randomize_credentials
bool randomize_credentials
Definition: netbase.h:37
LOCK
#define LOCK(cs)
Definition: sync.h:182
nLocalServices
ServiceFlags nLocalServices
Definition: net.cpp:73
RPC_CLIENT_NODE_ALREADY_ADDED
@ RPC_CLIENT_NODE_ALREADY_ADDED
Still downloading initial blocks.
Definition: protocol.h:62
CNode::CloseSocketDisconnect
void CloseSocketDisconnect()
Definition: net.cpp:417
IsLimited
bool IsLimited(enum Network net)
Definition: net.cpp:252
OpenNetworkConnection
bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
Definition: net.cpp:1670
CBanEntry
Definition: net.h:251
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:173
CBanEntry::nBanUntil
int64_t nBanUntil
Definition: net.h:257
GetNodeStateStats
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
Definition: main.cpp:1081
RPC_CLIENT_NODE_NOT_ADDED
@ RPC_CLIENT_NODE_NOT_ADDED
Node is already added.
Definition: protocol.h:63
CSubNet::IsValid
bool IsValid() const
Definition: netaddress.cpp:698
GetProxy
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:558
UniValue::size
size_t size() const
Definition: univalue.h:69
RPC_CLIENT_NODE_NOT_CONNECTED
@ RPC_CLIENT_NODE_NOT_CONNECTED
Node has not been added before.
Definition: protocol.h:64
vAddedNodes
std::vector< std::string > vAddedNodes
Definition: net.cpp:95
netbase.h
GetNetworkName
std::string GetNetworkName(enum Network net)
Definition: netbase.cpp:60
CNodeStats::nRecvBytes
uint64_t nRecvBytes
Definition: net.h:195
getconnectioncount
UniValue getconnectioncount(const UniValue &params, bool fHelp)
Definition: net.cpp:24
GetTimeOffset
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
Definition: timedata.cpp:24
CNode::IsBanned
static bool IsBanned(CNetAddr ip)
Definition: net.cpp:494
UniValue::VARR
@ VARR
Definition: univalue.h:21
server.h
CNodeStateStats
Definition: main.h:288
net.h
CFeeRate::GetFeePerK
CAmount GetFeePerK() const
Definition: amount.h:50
CNodeStats::nStartingHeight
int nStartingHeight
Definition: net.h:193
CNodeStats::nServices
ServiceFlags nServices
Definition: net.h:184
CNodeStats
Definition: net.h:180
proxyType::proxy
CService proxy
Definition: netbase.h:36