From 75698984cba22ff40f1d1e5a8015d89145f7498b Mon Sep 17 00:00:00 2001 From: Daniel Hams Date: Mon, 3 Feb 2014 23:44:34 +0000 Subject: [PATCH 1/6] Introduce a list of addresses to reject during interface endpoint discovery. On MacOSX the loopback device is lo0, not lo, plus there are multicast bridges which cause issues too. --- libethereum/PeerNetwork.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libethereum/PeerNetwork.cpp b/libethereum/PeerNetwork.cpp index 97f782e3a..901157091 100644 --- a/libethereum/PeerNetwork.cpp +++ b/libethereum/PeerNetwork.cpp @@ -36,6 +36,17 @@ static const eth::uint c_maxHashes = 256; ///< Maximum number of hashes GetChai static const eth::uint c_maxBlocks = 128; ///< Maximum number of blocks Blocks will ever send. BUG: if this gets too big (e.g. 2048) stuff starts going wrong. static const eth::uint c_maxBlocksAsk = 2048; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain). +// Addresses we will skip during network interface discovery +// Use a vector as the list is small +// Why this and not names? +// Under MacOSX loopback (127.0.0.1) can be named lo0 and br0 are bridges (0.0.0.0) +static const vector c_rejectAddresses = { + {bi::address_v4::from_string("127.0.0.1")}, + {bi::address_v6::from_string("::1")}, + {bi::address_v4::from_string("0.0.0.0")}, + {bi::address_v6::from_string("::")} +}; + PeerSession::PeerSession(PeerServer* _s, bi::tcp::socket _socket, uint _rNId): m_server(_s), m_socket(std::move(_socket)), @@ -768,11 +779,13 @@ void PeerServer::populateAddresses() continue; auto it = r.resolve({host, "30303"}); bi::tcp::endpoint ep = it->endpoint(); - m_addresses.push_back(ep.address().to_v4()); - if (ifa->ifa_name != string("lo")) - m_peerAddresses.push_back(ep.address().to_v4()); + bi::address ad = ep.address(); + m_addresses.push_back(ad.to_v4()); + bool isLocal = std::find( c_rejectAddresses.begin(), c_rejectAddresses.end(), ad) != c_rejectAddresses.end(); + if ( !isLocal ) + m_peerAddresses.push_back(ad.to_v4()); if (m_verbosity >= 1) - cout << "Address: " << host << " = " << m_addresses.back() << (ifa->ifa_name != string("lo") ? " [PEER]" : " [LOCAL]") << endl; + cout << "Address: " << host << " = " << m_addresses.back() << ( isLocal ? " [LOCAL]" : " [PEER]" ) << endl; } } From d665def810972881bb67b97208e9b65fc9241f57 Mon Sep 17 00:00:00 2001 From: Auston Sterling Date: Tue, 4 Feb 2014 11:37:44 -0500 Subject: [PATCH 2/6] Fixed locating cryptopp in system locations --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e51bfde..686ada1e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,12 @@ set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE) set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE) # Look for availabe Crypto++ version and if it is >= 5.6.2 -if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARIES) +if(EXISTS CRYPTOPP_INCLUDE_DIR AND EXISTS CRYPTOPP_LIBRARIES) set(CRYPTOPP_FOUND TRUE) message(STATUS "Found Crypto++: ${CRYPTOPP_INCLUDE_DIR}, ${CRYPTOPP_LIBRARIES}") else() + unset(CRYPTOPP_INCLUDE_DIR CACHE) + unset(CRYPTOPP_LIBRARIES CACHE) find_path(CRYPTOPP_INCLUDE_DIR cryptlib.h /usr/include/crypto++ /usr/include/cryptopp From 529a83bb331ac1ab1e1e988231c2628df81e7d66 Mon Sep 17 00:00:00 2001 From: Auston Sterling Date: Tue, 4 Feb 2014 12:12:56 -0500 Subject: [PATCH 3/6] Look at the contents of CMake variables --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 686ada1e4..5599c1b59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE) set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE) # Look for availabe Crypto++ version and if it is >= 5.6.2 -if(EXISTS CRYPTOPP_INCLUDE_DIR AND EXISTS CRYPTOPP_LIBRARIES) +if(EXISTS ${CRYPTOPP_INCLUDE_DIR} AND EXISTS ${CRYPTOPP_LIBRARIES}) set(CRYPTOPP_FOUND TRUE) message(STATUS "Found Crypto++: ${CRYPTOPP_INCLUDE_DIR}, ${CRYPTOPP_LIBRARIES}") else() From a8bbc9d1fb630d1fdd5abf9c5368308d043492ca Mon Sep 17 00:00:00 2001 From: Daniel Hams Date: Tue, 4 Feb 2014 18:10:00 +0000 Subject: [PATCH 4/6] Old habits getting in the way. Formatting fixes. --- libethereum/PeerNetwork.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libethereum/PeerNetwork.cpp b/libethereum/PeerNetwork.cpp index 901157091..fd8445f4e 100644 --- a/libethereum/PeerNetwork.cpp +++ b/libethereum/PeerNetwork.cpp @@ -781,11 +781,11 @@ void PeerServer::populateAddresses() bi::tcp::endpoint ep = it->endpoint(); bi::address ad = ep.address(); m_addresses.push_back(ad.to_v4()); - bool isLocal = std::find( c_rejectAddresses.begin(), c_rejectAddresses.end(), ad) != c_rejectAddresses.end(); - if ( !isLocal ) + bool isLocal = std::find(c_rejectAddresses.begin(), c_rejectAddresses.end(), ad) != c_rejectAddresses.end(); + if (!isLocal) m_peerAddresses.push_back(ad.to_v4()); if (m_verbosity >= 1) - cout << "Address: " << host << " = " << m_addresses.back() << ( isLocal ? " [LOCAL]" : " [PEER]" ) << endl; + cout << "Address: " << host << " = " << m_addresses.back() << (isLocal ? " [LOCAL]" : " [PEER]") << endl; } } From f16c18c124de08f338123dfb80c5db0483b7a927 Mon Sep 17 00:00:00 2001 From: SharpCoiner Date: Tue, 4 Feb 2014 13:37:07 -0800 Subject: [PATCH 5/6] Do not assume that the build dir is called cpp-ethereum-build. --- alephzero/alephzero.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alephzero/alephzero.pro b/alephzero/alephzero.pro index 62e4f844e..578b54ef4 100644 --- a/alephzero/alephzero.pro +++ b/alephzero/alephzero.pro @@ -14,8 +14,8 @@ CONFIG(debug, debug|release): DEFINES += ETH_DEBUG QMAKE_CXXFLAGS += -std=c++11 -QMAKE_LIBDIR += ../../cpp-ethereum-build/libethereum ../../secp256k1 ../../cryptopp562 -LIBS += -Wl,-rpath,../../cpp-ethereum-build/libethereum -Wl,-rpath,../../secp256k1 -Wl,-rpath,../../cryptopp562 -lethereum -lcryptopp -lminiupnpc -lsecp256k1 -lleveldb -lgmp -lboost_filesystem -lboost_system +QMAKE_LIBDIR += ../libethereum ../../cpp-ethereum-build/libethereum ../../secp256k1 ../../cryptopp562 +LIBS += -Wl,-rpath,../libethereu -Wl,-rpath,../../cpp-ethereum-build/libethereum -Wl,-rpath,../../secp256k1 -Wl,-rpath,../../cryptopp562 -lethereum -lcryptopp -lminiupnpc -lsecp256k1 -lleveldb -lgmp -lboost_filesystem -lboost_system INCLUDEPATH = ../../secp256k1/include ../../cpp-ethereum SOURCES += main.cpp \ From 2b392d29f89e25cee8f9462766673e33a3bcb643 Mon Sep 17 00:00:00 2001 From: SharpCoiner Date: Tue, 4 Feb 2014 15:54:06 -0800 Subject: [PATCH 6/6] Fixed typo. --- alephzero/alephzero.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alephzero/alephzero.pro b/alephzero/alephzero.pro index 578b54ef4..18f336a67 100644 --- a/alephzero/alephzero.pro +++ b/alephzero/alephzero.pro @@ -15,7 +15,7 @@ CONFIG(debug, debug|release): DEFINES += ETH_DEBUG QMAKE_CXXFLAGS += -std=c++11 QMAKE_LIBDIR += ../libethereum ../../cpp-ethereum-build/libethereum ../../secp256k1 ../../cryptopp562 -LIBS += -Wl,-rpath,../libethereu -Wl,-rpath,../../cpp-ethereum-build/libethereum -Wl,-rpath,../../secp256k1 -Wl,-rpath,../../cryptopp562 -lethereum -lcryptopp -lminiupnpc -lsecp256k1 -lleveldb -lgmp -lboost_filesystem -lboost_system +LIBS += -Wl,-rpath,../libethereum -Wl,-rpath,../../cpp-ethereum-build/libethereum -Wl,-rpath,../../secp256k1 -Wl,-rpath,../../cryptopp562 -lethereum -lcryptopp -lminiupnpc -lsecp256k1 -lleveldb -lgmp -lboost_filesystem -lboost_system INCLUDEPATH = ../../secp256k1/include ../../cpp-ethereum SOURCES += main.cpp \