diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-06-19 17:32:34 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-06-19 17:32:36 +0200 |
commit | 7ecdcd99ca6c488378a82531f742ca3a6be5eaee (patch) | |
tree | 952452c6cf7f9700cecc0389f389de245977598b | |
parent | 529a44c144a0c9c4bfefb6d7b41b328c3642149b (diff) | |
parent | 1c043d567230d639fa86afb96575689bfc8abdcd (diff) |
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)
-rw-r--r-- | src/net.cpp | 1 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 2 | ||||
-rw-r--r-- | src/rpcnet.cpp | 4 | ||||
-rw-r--r-- | src/test/rpc_tests.cpp | 27 |
4 files changed, 31 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp index 6b8a0a2b1e..0511256e55 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -448,6 +448,7 @@ CCriticalSection CNode::cs_setBanned; void CNode::ClearBanned() { + LOCK(cs_setBanned); setBanned.clear(); } diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 681617bd81..f828ce2534 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -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(); } } diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 5a26c7c3ae..1572b16687 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -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") { diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index e60281949e..c38df0ecf3 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -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() |