Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/net.cpp
Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 2 || | ||||
"addnode", | "addnode", | ||||
"\nAttempts to add or remove a node from the addnode list.\n" | "\nAttempts to add or remove a node from the addnode list.\n" | ||||
"Or try a connection to a node once.\n" | "Or try a connection to a node once.\n" | ||||
"Nodes added using addnode (or -connect) are protected from " | "Nodes added using addnode (or -connect) are protected from " | ||||
"DoS disconnection and are not required to be\n" | "DoS disconnection and are not required to be\n" | ||||
"full nodes as other outbound peers are (though such peers " | "full nodes as other outbound peers are (though such peers " | ||||
"will not be synced from).\n", | "will not be synced from).\n", | ||||
{ | { | ||||
{"node", RPCArg::Type::STR, /* opt */ false, | {"node", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
/* default_val */ "", "The node (see getpeerinfo for nodes)"}, | "The node (see getpeerinfo for nodes)"}, | ||||
{"command", RPCArg::Type::STR, /* opt */ false, | {"command", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
/* default_val */ "", | |||||
"'add' to add a node to the list, 'remove' to remove a " | "'add' to add a node to the list, 'remove' to remove a " | ||||
"node from the list, 'onetry' to try a connection to the " | "node from the list, 'onetry' to try a connection to the " | ||||
"node once"}, | "node once"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + | HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + | ||||
HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")}, | HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")}, | ||||
Show All 35 Lines | if (request.fHelp || request.params.size() == 0 || | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"disconnectnode", | "disconnectnode", | ||||
"\nImmediately disconnects from the specified peer node.\n" | "\nImmediately disconnects from the specified peer node.\n" | ||||
"\nStrictly one out of 'address' and 'nodeid' can be provided " | "\nStrictly one out of 'address' and 'nodeid' can be provided " | ||||
"to identify the node.\n" | "to identify the node.\n" | ||||
"\nTo disconnect by nodeid, either set 'address' to the empty " | "\nTo disconnect by nodeid, either set 'address' to the empty " | ||||
"string, or call using the named 'nodeid' argument only.\n", | "string, or call using the named 'nodeid' argument only.\n", | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, /* opt */ true, | {"address", RPCArg::Type::STR, | ||||
/* default_val */ "fallback to nodeid", | /* default */ "fallback to nodeid", | ||||
"The IP address/port of the node"}, | "The IP address/port of the node"}, | ||||
{"nodeid", RPCArg::Type::NUM, /* opt */ true, | {"nodeid", RPCArg::Type::NUM, | ||||
/* default_val */ "fallback to address", | /* default */ "fallback to address", | ||||
"The node ID (see getpeerinfo for node IDs)"}, | "The node ID (see getpeerinfo for node IDs)"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + | HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + | ||||
HelpExampleCli("disconnectnode", "\"\" 1") + | HelpExampleCli("disconnectnode", "\"\" 1") + | ||||
HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") + | HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") + | ||||
HelpExampleRpc("disconnectnode", "\"\", 1")}, | HelpExampleRpc("disconnectnode", "\"\", 1")}, | ||||
Show All 38 Lines | static UniValue getaddednodeinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"getaddednodeinfo", | "getaddednodeinfo", | ||||
"\nReturns information about the given added node, or " | "\nReturns information about the given added node, or " | ||||
"all added nodes\n" | "all added nodes\n" | ||||
"(note that onetry addnodes are not listed here)\n", | "(note that onetry addnodes are not listed here)\n", | ||||
{ | { | ||||
{"node", RPCArg::Type::STR, /* opt */ true, | {"node", RPCArg::Type::STR, /* default */ "all nodes", | ||||
/* default_val */ "all nodes", | |||||
"If provided, return information about this specific node, " | "If provided, return information about this specific node, " | ||||
"otherwise all nodes are returned."}, | "otherwise all nodes are returned."}, | ||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"[\n" | "[\n" | ||||
" {\n" | " {\n" | ||||
" \"addednode\" : \"192.168.0.201\", (string) The node IP " | " \"addednode\" : \"192.168.0.201\", (string) The node IP " | ||||
"address or name (as provided to addnode)\n" | "address or name (as provided to addnode)\n" | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | static UniValue setban(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
(strCommand != "add" && strCommand != "remove")) { | (strCommand != "add" && strCommand != "remove")) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"setban", | "setban", | ||||
"\nAttempts to add or remove an IP/Subnet from the " | "\nAttempts to add or remove an IP/Subnet from the " | ||||
"banned list.\n", | "banned list.\n", | ||||
{ | { | ||||
{"subnet", RPCArg::Type::STR, /* opt */ false, | {"subnet", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
/* default_val */ "", | |||||
"The IP/Subnet (see getpeerinfo for nodes IP) with an " | "The IP/Subnet (see getpeerinfo for nodes IP) with an " | ||||
"optional netmask (default is /32 = single IP)"}, | "optional netmask (default is /32 = single IP)"}, | ||||
{"command", RPCArg::Type::STR, /* opt */ false, | {"command", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
/* default_val */ "", | |||||
"'add' to add an IP/Subnet to the list, 'remove' to " | "'add' to add an IP/Subnet to the list, 'remove' to " | ||||
"remove an IP/Subnet from the list"}, | "remove an IP/Subnet from the list"}, | ||||
{"bantime", RPCArg::Type::NUM, /* opt */ true, | {"bantime", RPCArg::Type::NUM, /* default */ "0", | ||||
/* default_val */ "0", | |||||
"time in seconds how long (or until when if [absolute] is " | "time in seconds how long (or until when if [absolute] is " | ||||
"set) the IP is banned (0 or empty means using the default " | "set) the IP is banned (0 or empty means using the default " | ||||
"time of 24h which can also be overwritten by the -bantime " | "time of 24h which can also be overwritten by the -bantime " | ||||
"startup argument)"}, | "startup argument)"}, | ||||
{"absolute", RPCArg::Type::BOOL, /* opt */ true, | {"absolute", RPCArg::Type::BOOL, /* default */ "false", | ||||
/* default_val */ "false", | |||||
"If set, the bantime must be an absolute timestamp in seconds " | "If set, the bantime must be an absolute timestamp in seconds " | ||||
"since epoch (Jan 1 1970 GMT)"}, | "since epoch (Jan 1 1970 GMT)"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{ | RPCExamples{ | ||||
HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + | HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + | ||||
HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") + | HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") + | ||||
HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400")}, | HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400")}, | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | |||||
static UniValue setnetworkactive(const Config &config, | static UniValue setnetworkactive(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"setnetworkactive", | "setnetworkactive", | ||||
"\nDisable/enable all p2p network activity.\n", | "\nDisable/enable all p2p network activity.\n", | ||||
{ | { | ||||
{"state", RPCArg::Type::BOOL, /* opt */ false, | {"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, | ||||
/* default_val */ "", | |||||
"true to enable networking, false to disable"}, | "true to enable networking, false to disable"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.ToString()); | .ToString()); | ||||
} | } | ||||
Show All 11 Lines | |||||
static UniValue getnodeaddresses(const Config &config, | static UniValue getnodeaddresses(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() > 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"getnodeaddresses", | "getnodeaddresses", | ||||
"\nReturn known addresses which can potentially be used " | "\nReturn known addresses which can potentially be used " | ||||
"to find new nodes in the network\n", | "to find new nodes in the network\n", | ||||
{ | { | ||||
{"count", RPCArg::Type::NUM, /* opt */ true, | {"count", RPCArg::Type::NUM, /* default */ "1", | ||||
/* default_val */ "1", | |||||
"How many addresses to return. Limited to the " | "How many addresses to return. Limited to the " | ||||
"smaller of " + | "smaller of " + | ||||
std::to_string(ADDRMAN_GETADDR_MAX) + " or " + | std::to_string(ADDRMAN_GETADDR_MAX) + " or " + | ||||
std::to_string(ADDRMAN_GETADDR_MAX_PCT) + | std::to_string(ADDRMAN_GETADDR_MAX_PCT) + | ||||
"% of all known addresses."}, | "% of all known addresses."}, | ||||
}, | }, | ||||
RPCResult{"[\n" | RPCResult{"[\n" | ||||
" {\n" | " {\n" | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |