aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
AgeCommit message (Collapse)Author
2016-11-07Merge #9045: Hash P2P messages as they are received instead of at process-timePieter Wuille
fe1dc62 Hash P2P messages as they are received instead of at process-time (Matt Corallo)
2016-11-07Get rid of nType and nVersionPieter Wuille
Remove the nType and nVersion as parameters to all serialization methods and functions. There is only one place where it's read and has an impact (in CAddress), and even there it does not impact any of the recursively invoked serializers. Instead, the few places that need nType or nVersion are changed to read it directly from the stream object, through GetType() and GetVersion() methods which are added to all stream classes.
2016-11-07Make nType and nVersion private and sometimes constPieter Wuille
Make the various stream implementations' nType and nVersion private and const (except in CDataStream where we really need a setter).
2016-11-03net: handle version push in InitializeNodeCory Fields
2016-11-03net: remove now-unused ssSend and FuzzCory Fields
2016-11-03drop the optimistic write counter hackCory Fields
This is now handled properly in realtime.
2016-11-03net: switch all callers to connman for pushing messagesCory Fields
Drop all of the old stuff.
2016-11-03connman is in charge of pushing messagesCory Fields
The changes here are dense and subtle, but hopefully all is more explicit than before. - CConnman is now in charge of sending data rather than the nodes themselves. This is necessary because many decisions need to be made with all nodes in mind, and a model that requires the nodes calling up to their manager quickly turns to spaghetti. - The per-node-serializer (ssSend) has been replaced with a (quasi-)const send-version. Since the send version for serialization can only change once per connection, we now explicitly tag messages with INIT_PROTO_VERSION if they are sent before the handshake. With this done, there's no need to lock for access to nSendVersion. Also, a new stream is used for each message, so there's no need to lock during the serialization process. - This takes care of accounting for optimistic sends, so the nOptimisticBytesWritten hack can be removed. - -dropmessagestest and -fuzzmessagestest have not been preserved, as I suspect they haven't been used in years.
2016-10-31net: Use deterministic randomness for CNode's nonce, and make it constCory Fields
2016-10-31net: constify a few CNode vars to indicate that they're threadsafeCory Fields
2016-10-30Hash P2P messages as they are received instead of at process-timeMatt Corallo
2016-10-24RPC: Add "togglenetwork" method to toggle network activity temporarilyJon Lund Steffensen
RPC command "togglenetwork" toggles network and returns new state after command. RPC command "getinfo" returns "networkactive" field in output.
2016-10-24Allow network activity to be temporarily suspended.Jon Lund Steffensen
Added the function SetNetworkActive() which when called with argument set to false disconnects all nodes and sets the flag fNetworkActive to false. As long as this flag is false no new connections are attempted and no incoming connections are accepted. Network activity is reenabled by calling the function with argument true.
2016-10-18Merge #8914: Kill insecure_random and associated global stateWladimir J. van der Laan
5eaaa83 Kill insecure_random and associated global state (Wladimir J. van der Laan)
2016-10-17Kill insecure_random and associated global stateWladimir J. van der Laan
There are only a few uses of `insecure_random` outside the tests. This PR replaces uses of insecure_random (and its accompanying global state) in the core code with an FastRandomContext that is automatically seeded on creation. This is meant to be used for inner loops. The FastRandomContext can be in the outer scope, or the class itself, then rand32() is used inside the loop. Useful e.g. for pushing addresses in CNode or the fee rounding, or randomization for coin selection. As a context is created per purpose, thus it gets rid of cross-thread unprotected shared usage of a single set of globals, this should also get rid of the potential race conditions. - I'd say TxMempool::check is not called enough to warrant using a special fast random context, this is switched to GetRand() (open for discussion...) - The use of `insecure_rand` in ConnectThroughProxy has been replaced by an atomic integer counter. The only goal here is to have a different credentials pair for each connection to go on a different Tor circuit, it does not need to be random nor unpredictable. - To avoid having a FastRandomContext on every CNode, the context is passed into PushAddress as appropriate. There remains an insecure_random for test usage in `test_random.h`.
2016-10-15Display minimum ping in debug window.R E Broadley
2016-10-04gui: fix ban from qt consoleCory Fields
Rather than doing a circle and re-resolving the node's IP, just use the one from nodestats directly. This requires syncing the addr field from CNode.
2016-09-22Comment on CConnman::nLocalServices meaninginstagibbs
2016-09-19Merge #8688: Move static global randomizer seeds into CConnmanWladimir J. van der Laan
d9ff591 Move static global randomizer seeds into CConnman (Pieter Wuille)
2016-09-19Move static global randomizer seeds into CConnmanPieter Wuille
2016-09-14net: fix maxuploadtarget settingCory Fields
This was broken by 63cafa6329e1a. Note that while this fixes the settings, it doesn't fix the actual usage of -maxuploadtarget completely, as there is currently a bug in the nOptimisticBytesWritten accounting that causes a delayed response if the target is reached. That bug will be addressed separately.
2016-09-08net: move MAX_FEELER_CONNECTIONS into connmanCory Fields
2016-09-08Convert ForEachNode* functions to take a templated function argument rather ↵Jeremy Rubin
than a std::function to eliminate std::function overhead
2016-09-08Made the ForEachNode* functions in src/net.cpp more pragmatic and self ↵Jeremy Rubin
documenting
2016-09-08net: move vNodesDisconnected into CConnmanCory Fields
2016-09-08net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::OptionsCory Fields
2016-09-08net: Introduce CConnection::Options to avoid passing so many paramsCory Fields
2016-09-08net: Drop StartNode/StopNode and use CConnman directlyCory Fields
2016-09-08net: pass CClientUIInterface into CConnmanCory Fields
2016-09-08net: Pass best block known height into CConnmanCory Fields
CConnman then passes the current best height into CNode at creation time. This way CConnman/CNode have no dependency on main for height, and the signals only move in one direction. This also helps to prevent identity leakage a tiny bit. Before this change, an attacker could theoretically make 2 connections on different interfaces. They would connect fully on one, and only establish the initial connection on the other. Once they receive a new block, they would relay it to your first connection, and immediately commence the version handshake on the second. Since the new block height is reflected immediately, they could attempt to learn whether the two connections were correlated. This is, of course, incredibly unlikely to work due to the small timings involved and receipt from other senders. But it doesn't hurt to lock-in nBestHeight at the time of connection, rather than letting the remote choose the time.
2016-09-08net: move max/max-outbound to CConnmanCory Fields
2016-09-08net: move semOutbound to CConnmanCory Fields
2016-09-08net: move nLocalServices/nRelevantServices to CConnmanCory Fields
These are in-turn passed to CNode at connection time. This allows us to offer different services to different peers (or test the effects of doing so).
2016-09-08net: move SendBufferSize/ReceiveFloodSize to CConnmanCory Fields
2016-09-08net: move send/recv statistics to CConnmanCory Fields
2016-09-08net: SocketSendData returns written sizeCory Fields
2016-09-08net: move messageHandlerCondition to CConnmanCory Fields
2016-09-08net: move nLocalHostNonce to CConnmanCory Fields
This behavior seems to have been quite racy and broken. Move nLocalHostNonce into CNode, and check received nonces against all non-fully-connected nodes. If there's a match, assume we've connected to ourself.
2016-09-08net: move nLastNodeId to CConnmanCory Fields
2016-09-08net: move whitelist functions into CConnmanCory Fields
2016-09-08net: create generic functor accessors and move vNodes to CConnmanCory Fields
2016-09-08net: Add most functions needed for vNodes to CConnmanCory Fields
2016-09-08net: move added node functions to CConnmanCory Fields
2016-09-08net: Add oneshot functions to CConnmanCory Fields
2016-09-08net: move ban and addrman functions into CConnmanCory Fields
2016-09-08net: handle nodesignals in CConnmanCory Fields
2016-09-08net: move OpenNetworkConnection into CConnmanCory Fields
2016-09-08net: Move socket binding into CConnmanCory Fields
2016-09-08net: Pass CConnman around as neededCory Fields
2016-09-08net: Create CConnman to encapsulate p2p connectionsCory Fields