diff options
author | subtly <subtly@users.noreply.github.com> | 2015-03-26 23:21:25 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2015-03-26 23:21:25 +0800 |
commit | 708c55478c0df93995955bde989d26a25845b215 (patch) | |
tree | c033ea9975fee56baffc036106ad96b93e6c1d87 /net.cpp | |
parent | 70184ece429006ff824b6165b389a38491bc73fc (diff) | |
download | dexon-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.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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 |