aboutsummaryrefslogtreecommitdiffstats
path: root/net.cpp
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2015-03-26 23:21:25 +0800
committersubtly <subtly@users.noreply.github.com>2015-03-26 23:21:25 +0800
commit708c55478c0df93995955bde989d26a25845b215 (patch)
treec033ea9975fee56baffc036106ad96b93e6c1d87 /net.cpp
parent70184ece429006ff824b6165b389a38491bc73fc (diff)
downloaddexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar.gz
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar.bz2
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar.lz
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar.xz
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.tar.zst
dexon-solidity-708c55478c0df93995955bde989d26a25845b215.zip
adopt node IP address from udp header when ping.ipAddress isn't public
Diffstat (limited to 'net.cpp')
-rw-r--r--net.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/net.cpp b/net.cpp
index a5f97345..ec1efb36 100644
--- a/net.cpp
+++ b/net.cpp
@@ -145,6 +145,40 @@ public:
bool success = false;
};
+BOOST_AUTO_TEST_CASE(isIPAddressType)
+{
+ string wildcard = "0.0.0.0";
+ BOOST_REQUIRE(bi::address::from_string(wildcard).is_unspecified());
+
+ string empty = "";
+ BOOST_REQUIRE_THROW(bi::address::from_string(empty).is_unspecified(), std::exception);
+
+ string publicAddress192 = "192.169.0.0";
+ BOOST_REQUIRE(isPublicAddress(publicAddress192));
+ BOOST_REQUIRE(!isPrivateAddress(publicAddress192));
+ BOOST_REQUIRE(!isLocalHostAddress(publicAddress192));
+
+ string publicAddress172 = "172.32.0.0";
+ BOOST_REQUIRE(isPublicAddress(publicAddress172));
+ BOOST_REQUIRE(!isPrivateAddress(publicAddress172));
+ BOOST_REQUIRE(!isLocalHostAddress(publicAddress172));
+
+ string privateAddress192 = "192.168.1.0";
+ BOOST_REQUIRE(isPrivateAddress(privateAddress192));
+ BOOST_REQUIRE(!isPublicAddress(privateAddress192));
+ BOOST_REQUIRE(!isLocalHostAddress(privateAddress192));
+
+ string privateAddress172 = "172.16.0.0";
+ BOOST_REQUIRE(isPrivateAddress(privateAddress172));
+ BOOST_REQUIRE(!isPublicAddress(privateAddress172));
+ BOOST_REQUIRE(!isLocalHostAddress(privateAddress172));
+
+ string privateAddress10 = "10.0.0.0";
+ BOOST_REQUIRE(isPrivateAddress(privateAddress10));
+ BOOST_REQUIRE(!isPublicAddress(privateAddress10));
+ BOOST_REQUIRE(!isLocalHostAddress(privateAddress10));
+}
+
BOOST_AUTO_TEST_CASE(v2PingNodePacket)
{
// test old versino of pingNode packet w/new