aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
AgeCommit message (Collapse)Author
2017-09-06net: drop unused connman paramCory Fields
The copy in PeerLogicValidation can be used instead.
2017-09-06net: use an interface class rather than signals for message processingCory Fields
Drop boost signals in favor of a stateful class. This will allow the message processing loop to actually move to net_processing in a future step.
2017-09-06net: pass CConnman via pointer rather than referenceCory Fields
There are a few too many edge-cases here to make this a scripted diff. The following commits will move a few functions into PeerLogicValidation, where the local connman instance can be used. This change prepares for that usage.
2017-09-06Merge #10596: Add vConnect to CConnman::OptionsWladimir J. van der Laan
352d582ba Add vConnect to CConnman::Options (Marko Bencun) Pull request description: Split the "-connect" argument parsing out of CConnman and put it into AppInitMain(). Tree-SHA512: f2d3efc4e2c5808ff98696ea20dd96df599bc472ed5afc9c3eea305d94c36a6ab50c632aa05396c7c34d1917d91b1e7ccd725656ff2631e2a36d9eac477455dc
2017-08-16Use nullptr instead of zero (0) as the null pointer constantpracticalswift
2017-08-14scripted-diff: stop using the gArgs wrappersMarko Bencun
They were temporary additions to ease the transition. -BEGIN VERIFY SCRIPT- find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g' -END VERIFY SCRIPT-
2017-08-07scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift
instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
2017-08-02[net] Fix use of uninitialized value in getnetworkinfo(const JSONRPCRequest& ↵practicalswift
request) When running test_bitcoin under Valgrind I found the following issue: ``` $ valgrind src/test/test_bitcoin ... ==10465== Use of uninitialised value of size 8 ==10465== at 0x6D09B61: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==10465== by 0x6D0B1BB: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<unsigned long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==10465== by 0x6D0B36C: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==10465== by 0x6D17699: std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==10465== by 0x4CAAD7: operator<< (ostream:171) ==10465== by 0x4CAAD7: formatValue<ServiceFlags> (tinyformat.h:345) ==10465== by 0x4CAAD7: void tinyformat::detail::FormatArg::formatImpl<ServiceFlags>(std::ostream&, char const*, char const*, int, void const*) (tinyformat.h:523) ==10465== by 0x1924D4: format (tinyformat.h:510) ==10465== by 0x1924D4: tinyformat::detail::formatImpl(std::ostream&, char const*, tinyformat::detail::FormatArg const*, int) (tinyformat.h:803) ==10465== by 0x553A55: vformat (tinyformat.h:947) ==10465== by 0x553A55: format<ServiceFlags> (tinyformat.h:957) ==10465== by 0x553A55: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<ServiceFlags>(char const*, ServiceFlags const&) (tinyformat.h:966) ==10465== by 0x54C952: getnetworkinfo(JSONRPCRequest const&) (net.cpp:462) ==10465== by 0x28EDB5: CallRPC(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (rpc_tests.cpp:31) ==10465== by 0x293947: rpc_tests::rpc_togglenetwork::test_method() (rpc_tests.cpp:88) ==10465== by 0x2950E5: rpc_tests::rpc_togglenetwork_invoker() (rpc_tests.cpp:84) ==10465== by 0x182496: invoke<void (*)()> (callback.hpp:56) ==10465== by 0x182496: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89) ... ``` The read of the uninitialized variable nLocalServices is triggered by g_connman->GetLocalServices() in getnetworkinfo(const JSONRPCRequest& request) (net.cpp:462): ```c++ UniValue getnetworkinfo(const JSONRPCRequest& request) { ... if(g_connman) obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices()))); ... } ``` The reason for the uninitialized nLocalServices is that CConnman::Start(...) is not called by the tests, and hence the initialization normally performed by CConnman::Start(...) is not done. This commit adds a method Init(const Options& connOptions) which is called by both the constructor and CConnman::Start(...). This method initializes nLocalServices and the other relevant values from the supplied Options object.
2017-07-27Merge #10501: remove some unused functionsWladimir J. van der Laan
f228b8e remove some unused functions (Marko Bencun) Pull request description: Identified with `cppcheck --enable=unusedFunction .`. - GetSendBufferSize()'s last use removed in 991955e - SetPort()'s last use removed in 7e195e8 - GetfLargeWorkInvalidChainFound() was introduced in e3ba0ef and never used Tree-SHA512: ea8e5498bec981e42e1342c171c37723c2f5e575c7d6c1a524d9c6cd9b332bdd0d84fddf9e14ca011bb49fb82bd037386382c9afc546b3c2231ae548358bd4f4
2017-07-26Merge #10824: Avoid unnecessary work in SetNetworkActiveWladimir J. van der Laan
a2420ae Avoid unnecessary work in SetNetworkActive (João Barbosa) Pull request description: This PR adds an early return to avoid unnecessary notifications when the status doesn't change. Tree-SHA512: 85d05ca6fa36cb581f94bc154d08bd72cd53f6a857173c6fb2f184058f9c0208c4cf5e5d196825a78339902d8f256688eb6793f99abc7be9c7cfac85136180d9
2017-07-22remove some unused functionsMarko Bencun
Identified with `cppcheck --enable=unusedFunction .`. - GetSendBufferSize()'s last use removed in 991955ee81034dc3fbc1c2a8e60c04fc9e0b538c - SetPort()'s last use removed in 7e195e8459ad741368db6bb574981fccb1707268 - GetfLargeWorkInvalidChainFound() was introduced in e3ba0ef95636290a3bb597ddd25d13ea13b034aa and never used
2017-07-22Move CloseSocket out of SetSocketNonBlocking and pass SOCKET by const ↵Dag Robole
reference in SetSocket* functions
2017-07-19Add vConnect to CConnman::OptionsMarko Bencun
Split the "-connect" argument parsing out of CConnman and put it into AppInitMain().
2017-07-14Avoid unnecessary work in SetNetworkActiveJoão Barbosa
2017-07-08Fix subscript[0] bug in net.cpp if GetGroup returns a 0-sized vectorJeremy Rubin
2017-06-27Util: Remove redundant calls to gArgs.IsArgSet()Jorge Timón
Return empty std::vector<std::string> with ArgsManager::GetArgs if nothing is set for that string
2017-06-26Merge #10496: Add Binds, WhiteBinds, Whitelistedrange to CConnman::OptionsWladimir J. van der Laan
07b2afe add Binds, WhiteBinds to CConnman::Options (Marko Bencun) ce79f32 add WhitelistedRange to CConnman::Options (Marko Bencun) Tree-SHA512: c23a6f317c955338af531fa3e53e3c42e995f88c6e1939bbc2ad119fa5b786c54b3dad3d2e9b3f830b7292c0c63a02fcff66a89907d0fa8d7c83aefade01af45
2017-06-24Merge #10446: net: avoid extra dns query per seedWladimir J. van der Laan
c1be285 chainparams: make supported service bits option explicit (Cory Fields) d5c7c1c net: use an internal address for fixed seeds (Cory Fields) 6cdc488 net: switch to dummy internal ip for dns seed source (Cory Fields) 6d0bd5b net: do not allow resolving to an internal address (Cory Fields) 7f31762 net: add an internal subnet for representing unresolved hostnames (Cory Fields) Tree-SHA512: 9bf1042bef546ac3ef0e0d3a9a5555eb21628ff2674a0cf8c6367194b22bfdab477adf452c0e7c56f44e0fb37debc5e14bdb623452e076fb9c492c7702601d7a
2017-06-22net: use an internal address for fixed seedsCory Fields
2017-06-15add Binds, WhiteBinds to CConnman::OptionsMarko Bencun
Part of a series of changes to clean up the instantiation of connman by decoupling the command line arguments. We also now abort with an error when explicit binds are set with -listen=0.
2017-06-15add WhitelistedRange to CConnman::OptionsMarko Bencun
Part of a series of changes to clean up the instantiation of connman by decoupling the command line arguments.
2017-06-14net: switch to dummy internal ip for dns seed sourceCory Fields
This addresss the TODO to avoid resolving twice.
2017-06-14net: add an internal subnet for representing unresolved hostnamesCory Fields
We currently do two resolves for dns seeds: one for the results, and one to serve in addrman as the source for those addresses. There's no requirement that the source hostname resolves to the stored identifier, only that the mapping is unique. So rather than incurring the second lookup, combine a private subnet with a hash of the hostname. The resulting v6 ip is guaranteed not to be publicy routable, and has only a negligible chance of colliding with a user's internal network (which would be of no consequence anyway).
2017-06-13Merge #10502: scripted-diff: Remove BOOST_FOREACH, Q_FOREACH and PAIRTYPEPieter Wuille
1238f13cf scripted-diff: Remove PAIRTYPE (Jorge Timón) 18dc3c396 scripted-diff: Remove Q_FOREACH (Jorge Timón) 7c00c2672 scripted-diff: Fully remove BOOST_FOREACH (Jorge Timón) a5410ac5e Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal (Jorge Timón) Tree-SHA512: d3ab4a173366402e7dcef31608977b757d4aa07abbbad2ee1bcbcfa311e994a4552f24e5a55272cb22c2dcf89a4b0495e02e9d9aceae4b08c0bab668f20e324c
2017-06-09Return early in IsBanned.Gregory Maxwell
I am not aware of any reason that we'd try to stop a ban-list timing side-channel and the prior code wouldn't be enough if we were.
2017-06-05scripted-diff: Fully remove BOOST_FOREACHJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
2017-06-05rpc: Add listen address to incoming connections in `getpeerinfo`Wladimir J. van der Laan
This adds the listening address on which incoming connections were received to the CNode and CNodeStats structures. The address is reported in `getpeerinfo`. This can be useful for distinguishing connections received on different listening ports (e.g. when using a different listening port for Tor hidden service connections) or different networks.
2017-06-01Merge #10441: net: only enforce expected services for half of outgoing ↵Wladimir J. van der Laan
connections b6fbfc2 net: only enforce the services required to connect (Cory Fields) Tree-SHA512: 88943bff63213a734f3c96c45760cadaeb9ba18287c8a20c279851ebaf058a334c969028fb2180f155508e3eea4b838147382e4f2b655e7a9aa098eadc81d53e
2017-05-30add SeedNodes to CConnman::OptionsMarko Bencun
Start of a series of changes to clean up the instantiation of connman by decoupling the command line arguments.
2017-05-28net: only enforce the services required to connectCory Fields
also once half of all outgoing nodes have our preferred flags, require only minimal flags from the rest.
2017-05-18Populate services in GetLocalAddressAlex Morcos
Previously if we didn't have any local addresses, GetLocalAddress would return 0.0.0.0 and then we'd swap in a peer's notion of our address in AdvertiseLocal, but then nServices would never get set.
2017-05-17Merge #10061: [net] Added SetSocketNoDelay() utility functionPieter Wuille
ad415bc [net] Added SetSocketNoDelay() utility function (Thomas Snider) Tree-SHA512: c19e3c9910b3fc2ef86f2434f3e91d343e9cd9e2116153941de9789e2a6fc0389bffe762d21b55cda4a4b1de993afee0564c6946e65d05cef9e866b58896f9af
2017-05-15Merge #9494: Introduce an ArgsManager class encapsulating cs_args, mapArgs ↵Wladimir J. van der Laan
and mapMultiArgs 78da882 Util: Small improvements in gArgs usage (Jorge Timón) 5292245 Util: Put mapMultiArgs inside ArgsManager (Jorge Timón) b3cbd55 scripted-diff: Util: Encapsulate mapMultiArgs behind gArgs (Jorge Timón) f2957ce Util: Create ArgsManager class... (Jorge Timón) Tree-SHA512: 7d58250da440ad0f41745f46ab6021d6ecbb292035cab3d86fb08ce6bd822df604ac31b3ded6fd6914f7cfd12ba531cbc06a76eb500f629627f47ae6ac8350a7
2017-05-09scripted-diff: Util: Encapsulate mapMultiArgs behind gArgsJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/mapMultiArgs.count(/gArgs.IsArgSet(/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i 's/mapMultiArgs.at("/gArgs.GetArgs("/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
2017-05-07Merge #10189: devtools/net: add a verifier for scriptable changes. Use it to ↵Wladimir J. van der Laan
make CNode::id private. 0f3471f net: make CNode's id private (Cory Fields) 9ff0a51 scripted-diff: net: Use accessor rather than node's id directly (Cory Fields) e50c33e devtools: add script to verify scriptable changes (Cory Fields) Tree-SHA512: a0ff50f4e1d38a2b63109b4996546c91b3e02e00d92c0bf04f48792948f78b1f6d9227a15d25c823fd4723a0277fc6a32c2c1287c7abbb7e50fd82ffb0f8d994
2017-05-04net: make CNode's id privateCory Fields
2017-05-04scripted-diff: net: Use accessor rather than node's id directlyCory Fields
-BEGIN VERIFY SCRIPT- sed -i "s/\(node\|to\|from\)->id/\1->GetId()/" src/net.cpp src/net_processing.cpp -END VERIFY SCRIPT-
2017-05-02Merge #10234: [net] listbanned RPC and QT should show correct banned subnetsWladimir J. van der Laan
d6732d8 [tests] update disconnect_ban.py test case to work with listbanned (John Newbery) 77c54b2 [net] listbanned RPC and QT should show correct banned subnets (John Newbery) Tree-SHA512: edd0e43377d456260d2697213c2829f8483630f3a668b6707d52605faefa610d951d10e6f22a95eff483cbd14faa8ac9b69fa7d3c0b5735c5f3df23fd71282e0
2017-04-28[net] listbanned RPC and QT should show correct banned subnetsJohn Newbery
2017-04-26Merge #9930: Trivial: Correct indentation and bracingWladimir J. van der Laan
31a14d4 Correct indentation and remove unnecessary braces (Matthias Grundmann) Tree-SHA512: c0e827ec4474133c7674254dfd13f59608820cd639debc7759bddae71d73451645fcfe14384f343d08f74d69ac3922bafc12a514f3b790ae2bf9271aa67d5f36
2017-04-14Check interruptNet during dnsseed lookupsMatt Corallo
2017-04-05[net] Added SetSocketNoDelay() utility functionThomas Snider
2017-04-02Correct indentation and remove unnecessary bracesMatthias Grundmann
2017-04-01Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell
This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
2017-03-18Merge #9987: Remove unused codeWladimir J. van der Laan
8dc957a Remove unused code (practicalswift) Tree-SHA512: c7bb286e3b92e42fec8aa1ac2491fd38be36602efca16b4bdc4e9d5ada75c11d99e7713092ec13794abd69d5ef2c732b86209a6d01710e5ebf6fc51b8a65c92a
2017-03-17Remove unused codepracticalswift
2017-03-16Merge #9921: build: Probe MSG_DONTWAIT in the same way as MSG_NOSIGNALWladimir J. van der Laan
a4d1c9f compat: use `unsigned int` instead of `u_int` (Wladimir J. van der Laan) 25da1ee build: cleanup: define MSG_DONTWAIT/MSG_NO_SIGNAL locally (Wladimir J. van der Laan) c459d50 build: Probe MSG_DONTWAIT in the same way as MSG_NOSIGNAL (Wladimir J. van der Laan) Tree-SHA512: 60d79d69439bb181465e4244aa5ddc28bbd84f69c0ca0c753956b3798c9022394e29d791bc085fe7ffb1268c64c789a57e24797daad63525bb776088188ff9ae
2017-03-08Add missing braces in semaphore posts in netMatt Corallo
2017-03-08Fix shutdown hang with >= 8 -addnodes setMatt Corallo
We previously would block waiting for a CSemaphoreGrant in ThreadOpenAddedConnections, when we did not need to. This would block as the posts in CConnman shutdown were both to the wrong semaphore and in the wrong location.
2017-03-06CScheduler boost->std::function, use millisecs for times, not secsMatt Corallo