Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/net.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"ping", | "ping", | ||||
"Requests that a ping be sent to all other nodes, to measure ping " | "Requests that a ping be sent to all other nodes, to measure ping " | ||||
"time.\n" | "time.\n" | ||||
"Results provided in getpeerinfo, pingtime and pingwait fields are " | "Results provided in getpeerinfo, pingtime and pingwait fields are " | ||||
"decimal seconds.\n" | "decimal seconds.\n" | ||||
"Ping command is handled in queue with all other commands, so it " | "Ping command is handled in queue with all other commands, so it " | ||||
"measures processing backlog, not just network ping.\n", | "measures processing backlog, not just network ping.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")}, | RPCExamples{HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (!node.connman) { | if (!node.connman) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_CLIENT_P2P_DISABLED, | RPC_CLIENT_P2P_DISABLED, | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 2 || | ||||
{ | { | ||||
{"node", RPCArg::Type::STR, RPCArg::Optional::NO, | {"node", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The node (see getpeerinfo for nodes)"}, | "The node (see getpeerinfo for nodes)"}, | ||||
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, | {"command", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"'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{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
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\"")}, | ||||
} | } | ||||
.ToString()); | .ToString()); | ||||
} | } | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
Show All 36 Lines | RPCHelpMan{ | ||||
{ | { | ||||
{"address", RPCArg::Type::STR, | {"address", RPCArg::Type::STR, | ||||
/* default */ "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, | {"nodeid", RPCArg::Type::NUM, | ||||
/* default */ "fallback to address", | /* default */ "fallback to address", | ||||
"The node ID (see getpeerinfo for node IDs)"}, | "The node ID (see getpeerinfo for node IDs)"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + | RPCExamples{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")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
▲ Show 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | const RPCHelpMan help{ | ||||
{"bantime", RPCArg::Type::NUM, /* default */ "0", | {"bantime", RPCArg::Type::NUM, /* default */ "0", | ||||
"time in seconds how long (or until when if [absolute] is set) " | "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 " | "the IP is banned (0 or empty means using the default time of 24h " | ||||
"which can also be overwritten by the -bantime startup argument)"}, | "which can also be overwritten by the -bantime startup argument)"}, | ||||
{"absolute", RPCArg::Type::BOOL, /* default */ "false", | {"absolute", RPCArg::Type::BOOL, /* default */ "false", | ||||
"If set, the bantime must be an absolute timestamp expressed in " + | "If set, the bantime must be an absolute timestamp expressed in " + | ||||
UNIX_EPOCH_TIME}, | UNIX_EPOCH_TIME}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
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")}, | ||||
}; | }; | ||||
std::string strCommand; | std::string strCommand; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static UniValue listbanned(const Config &config, | static UniValue listbanned(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"listbanned", | "listbanned", | ||||
"List all manually banned IPs/Subnets.\n", | "List all manually banned IPs/Subnets.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::ARR, | ||||
"", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::OBJ, | |||||
"", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR, "address", ""}, | |||||
{RPCResult::Type::NUM_TIME, "banned_until", ""}, | |||||
{RPCResult::Type::NUM_TIME, "ban_created", ""}, | |||||
{RPCResult::Type::STR, "ban_reason", ""}, | |||||
}}, | |||||
}}, | |||||
RPCExamples{HelpExampleCli("listbanned", "") + | RPCExamples{HelpExampleCli("listbanned", "") + | ||||
HelpExampleRpc("listbanned", "")}, | HelpExampleRpc("listbanned", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (!node.banman) { | if (!node.banman) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, | throw JSONRPCError(RPC_DATABASE_ERROR, | ||||
Show All 18 Lines | |||||
} | } | ||||
static UniValue clearbanned(const Config &config, | static UniValue clearbanned(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"clearbanned", | "clearbanned", | ||||
"Clear all banned IPs.\n", | "Clear all banned IPs.\n", | ||||
{}, | {}, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::NONE, "", ""}, | ||||
RPCExamples{HelpExampleCli("clearbanned", "") + | RPCExamples{HelpExampleCli("clearbanned", "") + | ||||
HelpExampleRpc("clearbanned", "")}, | HelpExampleRpc("clearbanned", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (!node.banman) { | if (!node.banman) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
Show All 10 Lines | static UniValue setnetworkactive(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"setnetworkactive", | "setnetworkactive", | ||||
"Disable/enable all p2p network activity.\n", | "Disable/enable all p2p network activity.\n", | ||||
{ | { | ||||
{"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, | {"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, | ||||
"true to enable networking, false to disable"}, | "true to enable networking, false to disable"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResult{RPCResult::Type::BOOL, "", "The value that was passed in"}, | ||||
RPCExamples{""}, | RPCExamples{""}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (!node.banman) { | if (!node.banman) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_CLIENT_P2P_DISABLED, | RPC_CLIENT_P2P_DISABLED, | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |