Skip to content

Commit

Permalink
rpc: Named arguments for net calls
Browse files Browse the repository at this point in the history
  • Loading branch information
laanwj authored and random-zebra committed May 25, 2021
1 parent 8e5bed7 commit 81de632
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ UniValue setban(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 2 ||
(strCommand != "add" && strCommand != "remove"))
throw std::runtime_error(
"setban \"ip(/netmask)\" \"add|remove\" ( bantime absolute )\n"
"setban \"subnet\" \"add|remove\" ( bantime absolute )\n"
"\nAttempts add or remove a IP/Subnet from the banned list.\n"

"\nArguments:\n"
"1. \"ip(/netmask)\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n"
"1. \"subnet\" (string, required) The IP/Subnet (see getpeerinfo for nodes ip) with a optional netmask (default is /32 = single ip)\n"
"2. \"command\" (string, required) 'add' to add a IP/Subnet to the list, 'remove' to remove a IP/Subnet from the list\n"
"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"
"4. \"absolute\" (boolean, optional) If set, the bantime must be a absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
Expand Down Expand Up @@ -552,23 +552,23 @@ UniValue clearbanned(const JSONRPCRequest& request)
}

static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ----------
{ "network", "getnetworkinfo", &getnetworkinfo, true },
{ "network", "addnode", &addnode, true },
{ "network", "disconnectnode", &disconnectnode, true },
{ "network", "getaddednodeinfo", &getaddednodeinfo, true },
{ "network", "getconnectioncount", &getconnectioncount, true },
{ "network", "getnettotals", &getnettotals, true },
{ "network", "getpeerinfo", &getpeerinfo, true },
{ "network", "ping", &ping, true },
{ "network", "setban", &setban, true },
{ "network", "listbanned", &listbanned, true },
{ "network", "clearbanned", &clearbanned, true },
{ // category name actor (function) okSafe argNames
// --------------------- ------------------------ ----------------------- ------ --------
{ "network", "getnetworkinfo", &getnetworkinfo, true, {} },
{ "network", "addnode", &addnode, true, {"node","command"} },
{ "network", "disconnectnode", &disconnectnode, true, {"node"} },
{ "network", "getaddednodeinfo", &getaddednodeinfo, true, {"dummy","node"} },
{ "network", "getconnectioncount", &getconnectioncount, true, {} },
{ "network", "getnettotals", &getnettotals, true, {} },
{ "network", "getpeerinfo", &getpeerinfo, true, {} },
{ "network", "ping", &ping, true, {} },
{ "network", "setban", &setban, true, {"subnet", "command", "bantime", "absolute"} },
{ "network", "listbanned", &listbanned, true, {} },
{ "network", "clearbanned", &clearbanned, true, {} },
};

void RegisterNetRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
}

0 comments on commit 81de632

Please sign in to comment.