mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 07:37:54 +00:00
Merge pull request #6307
1c043d5
fix lock issue for QT node diconnect and RPC disconnectnode (Jonas Schnelli)932687b
setban: add IPv6 tests (Jonas Schnelli)62909f6
fix missing lock in CNode::ClearBanned() (Jonas Schnelli)
This commit is contained in:
commit
7ecdcd99ca
@ -448,6 +448,7 @@ CCriticalSection CNode::cs_setBanned;
|
||||
|
||||
void CNode::ClearBanned()
|
||||
{
|
||||
LOCK(cs_setBanned);
|
||||
setBanned.clear();
|
||||
}
|
||||
|
||||
|
@ -687,7 +687,7 @@ void RPCConsole::disconnectSelectedNode()
|
||||
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
|
||||
// Find the node, disconnect it and clear the selected node
|
||||
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
|
||||
bannedNode->CloseSocketDisconnect();
|
||||
bannedNode->fDisconnect = true;
|
||||
clearSelectedNode();
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ UniValue disconnectnode(const UniValue& params, bool fHelp)
|
||||
if (pNode == NULL)
|
||||
throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes");
|
||||
|
||||
pNode->CloseSocketDisconnect();
|
||||
pNode->fDisconnect = true;
|
||||
|
||||
return NullUniValue;
|
||||
}
|
||||
@ -519,7 +519,7 @@ UniValue setban(const UniValue& params, bool fHelp)
|
||||
|
||||
//disconnect possible nodes
|
||||
while(CNode *bannedNode = (isSubnet ? FindNode(subNet) : FindNode(netAddr)))
|
||||
bannedNode->CloseSocketDisconnect();
|
||||
bannedNode->fDisconnect = true;
|
||||
}
|
||||
else if(strCommand == "remove")
|
||||
{
|
||||
|
@ -231,6 +231,33 @@ BOOST_AUTO_TEST_CASE(rpc_ban)
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned")));
|
||||
ar = r.get_array();
|
||||
BOOST_CHECK_EQUAL(ar.size(), 0);
|
||||
|
||||
|
||||
BOOST_CHECK_THROW(r = CallRPC(string("setban test add")), runtime_error); //invalid IP
|
||||
|
||||
//IPv6 tests
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("setban FE80:0000:0000:0000:0202:B3FF:FE1E:8329 add")));
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned")));
|
||||
ar = r.get_array();
|
||||
o1 = ar[0].get_obj();
|
||||
adr = find_value(o1, "address");
|
||||
BOOST_CHECK_EQUAL(adr.get_str(), "fe80::202:b3ff:fe1e:8329/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||
|
||||
BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned")));
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 2001:db8::/30 add")));
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned")));
|
||||
ar = r.get_array();
|
||||
o1 = ar[0].get_obj();
|
||||
adr = find_value(o1, "address");
|
||||
BOOST_CHECK_EQUAL(adr.get_str(), "2001:db8::/ffff:fffc:0:0:0:0:0:0");
|
||||
|
||||
BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned")));
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128 add")));
|
||||
BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned")));
|
||||
ar = r.get_array();
|
||||
o1 = ar[0].get_obj();
|
||||
adr = find_value(o1, "address");
|
||||
BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user