Permalink
Browse files

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)
  • Loading branch information...
laanwj committed Jun 19, 2015
2 parents 529a44c + 1c043d5 commit 7ecdcd99ca6c488378a82531f742ca3a6be5eaee
Showing with 31 additions and 3 deletions.
  1. +1 −0 src/net.cpp
  2. +1 −1 src/qt/rpcconsole.cpp
  3. +2 −2 src/rpcnet.cpp
  4. +27 −0 src/test/rpc_tests.cpp
View
@@ -448,6 +448,7 @@ CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
{
+ LOCK(cs_setBanned);
setBanned.clear();
}
View
@@ -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();
}
}
View
@@ -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")
{
View
@@ -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()

0 comments on commit 7ecdcd9

Please sign in to comment.