aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
AgeCommit message (Collapse)Author
2016-01-05Bump copyright headers to 2015MarcoFalke
- Bump copyright headers to 2015 - [devtools] Rewrite fix-copyright-headers.py - [devtools] Use git pretty-format for year parsing Github-Pull: #7205 Rebased-From: fa6ad855e9159b2247da4fa0054f32fa181499ab fa24439ff3d8ab5b9efaf66ef4dae6713b88cb35 fa71669452e57039e4270fd2b33a0e0e1635b813
2015-12-14Replace trickle nodes with per-node/message Poisson delaysPieter Wuille
We used to have a trickle node, a node which was chosen in each iteration of the send loop that was privileged and allowed to send out queued up non-time critical messages. Since the removal of the fixed sleeps in the network code, this resulted in fast and attackable treatment of such broadcasts. This pull request changes the 3 remaining trickle use cases by random delays: * Local address broadcast (while also removing the the wiping of the seen filter) * Address relay * Inv relay (for transactions; blocks are always relayed immediately) The code is based on older commits by Patrick Strateman. Github-Pull: #7125 Rebased-From: 5400ef6bcb9d243b2b21697775aa6491115420f3
2015-12-11net: Add and document network messages in protocol.hWladimir J. van der Laan
- Avoids string typos (by making the compiler check) - Makes it easier to grep for handling/generation of a certain message type - Refer directly to documentation by following the symbol in IDE - Move list of valid message types to protocol.cpp: protocol.cpp is a more appropriate place for this, and having the array there makes it easier to keep things consistent. Github-Pull: #7181 Rebased-From: 9bbe71b641e2fc985daf127988a14a67c99da50a
2015-12-04Replace setInventoryKnown with a rolling bloom filter.Gregory Maxwell
Github-Pull: #7133 Rebased-From: ec73ef37eccfeda76de55c4ff93ea54d4e69e1ec e20672479ef7f2048c2e27494397641d47a4d88d 6b849350ab074a7ccb80ecbef387f59e1271ded6 b6a0da45db8d534e7a77d1cebe382cd5d83ba9b8 d41e44c9accb3df84e0abbc602cc76b72754d382 aa4b0c26b0a94ca6164c441aae723e118554d214
2015-12-01Merge pull request #7079Wladimir J. van der Laan
ebb25f4 Limit setAskFor and retire requested entries only when a getdata returns. (Gregory Maxwell) 5029698 prevent peer flooding request queue for an inv (kazcw)
2015-11-28Constrain constant values to a single location in codeLuke Dashjr
2015-11-23Limit setAskFor and retire requested entries only when a getdata returns.Gregory Maxwell
The setAskFor duplicate elimination was too eager and removed entries when we still had no getdata response, allowing the peer to keep INVing and not responding.
2015-11-23prevent peer flooding request queue for an invkazcw
mapAlreadyAskedFor does not keep track of which peer has a request queued for a particular tx. As a result, a peer can blind a node to a tx indefinitely by sending many invs for the same tx, and then never replying to getdatas for it. Each inv received will be placed 2 minutes farther back in mapAlreadyAskedFor, so a short message containing 10 invs would render that tx unavailable for 20 minutes. This is fixed by disallowing a peer from having more than one entry for a particular inv in mapAlreadyAskedFor at a time.
2015-11-20Add relaytxes status to getpeerinfoPeter Todd
2015-11-14Use DEFAULT_BLOCKSONLY and DEFAULT_WHITELISTALWAYSRELAY constantsPatick Strateman
2015-11-14Add blocksonly modePatick Strateman
2015-11-12[net] Cleanup maxuploadtargetMarcoFalke
* log: nMaxOutboundLimit is in bytes * log: Hide misleading -maxuploadtarget=0 warning * qa : Minor cleanup to maxuploadtarget rpc tests * net: Use DEFAULT_MAX_UPLOAD_TARGET = 0
2015-11-12torcontrol improvements and fixesWladimir J. van der Laan
- Force AUTHCOOKIE size to be 32 bytes: This provides protection against an attack where a process pretends to be Tor and uses the cookie authentication method to nab arbitrary files such as the wallet - torcontrol logging - fix cookie auth - add HASHEDPASSWORD auth, fix fd leak when fwrite() fails - better error reporting when cookie file is not ok - better init/shutdown flow - stop advertizing service when disconnected from tor control port - COOKIE->SAFECOOKIE auth
2015-11-10net: Automatically create hidden service, listen on TorWladimir J. van der Laan
Starting with Tor version 0.2.7.1 it is possible, through Tor's control socket API, to create and destroy 'ephemeral' hidden services programmatically. https://stem.torproject.org/api/control.html#stem.control.Controller.create_ephemeral_hidden_service This means that if Tor is running (and proper authorization is available), bitcoin automatically creates a hidden service to listen on, without user manual configuration. This will positively affect the number of available .onion nodes. - When the node is started, connect to Tor through control socket - Send `ADD_ONION` command - First time: - Make it create a hidden service key - Save the key in the data directory for later usage - Make it redirect port 8333 to the local port 8333 (or whatever port we're listening on). - Keep control socket connection open for as long node is running. The hidden service will (by default) automatically go away when the connection is closed.
2015-10-26Introduce -maxuploadtargetJonas Schnelli
* -maxuploadtarget can be set in MiB * if <limit> - ( time-left-in-24h-cycle / 600 * MAX_BLOCK_SIZE ) has reach, stop serve blocks older than one week and filtered blocks * no action if limit has reached, no guarantee that the target will not be surpassed * add outbound limit informations to rpc getnettotals
2015-10-22Set TCP_NODELAY on P2P sockets.Gregory Maxwell
Nagle appears to be a significant contributor to latency now that the static sleeps are gone. Most of our messages are relatively large compared to IP + TCP so I do not expect this to create enormous overhead. This may also reduce traffic burstyness somewhat.
2015-09-04net: correctly initialize nMinPingUsecTimeWladimir J. van der Laan
`nMinPingUsecTime` was left uninitialized in CNode. The correct initialization for a minimum-until-now is int64_t's max value, so initialize it to that. Thanks @MarcoFalke for noticing.
2015-09-03Report minimum ping time in getpeerinfoMatt Corallo
2015-09-03Merge pull request #6374Wladimir J. van der Laan
027de94 Use network group instead of CNetAddr in final pass to select node to disconnect (Patrick Strateman) 000c18a Fix comment (Patrick Strateman) fed3094 Acquire cs_vNodes before changing refrence counts (Patrick Strateman) 69ee1aa CNodeRef copy constructor and assignment operator (Patrick Strateman) dc81dd0 Return false early if vEvictionCandidates is empty (Patrick Strateman) 17f3533 Better support for nodes with non-standard nMaxConnections (Patrick Strateman) 1317cd1 RAII wrapper for CNode* (Patrick Strateman) df23937 Add comments to AttemptToEvictConnection (Patrick Strateman) a8f6e45 Remove redundant whiteconnections option (Patrick Strateman) b105ba3 Prefer to disconnect peers in favor of whitelisted peers (Patrick Strateman) 2c70153 AttemptToEvictConnection (Patrick Strateman) 4bac601 Record nMinPingUsecTime (Patrick Strateman) ae037b7 Refactor: Move failure conditions to the top of AcceptConnection (Patrick Strateman) 1ef4817 Refactor: Bail early in AcceptConnection (Patrick Strateman) 541a1dd Refactor: AcceptConnection (Patrick Strateman)
2015-08-31Merge pull request #6583Wladimir J. van der Laan
9f3e48e add support for miniupnpc api version 14 (Pavel Vasin)
2015-08-30Use network group instead of CNetAddr in final pass to select node to disconnectPatrick Strateman
2015-08-29Make sure LogPrint strings are line-terminatedJ Ross Nicoll
2015-08-25Fix commentPatrick Strateman
2015-08-25Acquire cs_vNodes before changing refrence countsPatrick Strateman
2015-08-25CNodeRef copy constructor and assignment operatorPatrick Strateman
2015-08-25net: Set SO_REUSEADDR for Windows tooCory Fields
When running the rpc tests in Wine, nodes often fail to listen on localhost due to a stale socket from a previous run. This aligns the behavior with other platforms.
2015-08-23add support for miniupnpc api version 14Pavel Vasin
The value of new arg ttl is set to 2 as it's recommended default.
2015-08-22Return false early if vEvictionCandidates is emptyPatrick Strateman
2015-08-22Better support for nodes with non-standard nMaxConnectionsPatrick Strateman
2015-08-22RAII wrapper for CNode*Patrick Strateman
2015-08-22Add comments to AttemptToEvictConnectionPatrick Strateman
2015-08-22Remove redundant whiteconnections optionPatrick Strateman
2015-08-22Prefer to disconnect peers in favor of whitelisted peersPatrick Strateman
2015-08-22AttemptToEvictConnectionPatrick Strateman
2015-08-22Refactor: Move failure conditions to the top of AcceptConnectionPatrick Strateman
2015-08-22Refactor: Bail early in AcceptConnectionPatrick Strateman
2015-08-22Refactor: AcceptConnectionPatrick Strateman
2015-08-10typofixes (found by misspell_fixer)Veres Lajos
2015-08-05Merge pull request #6462Wladimir J. van der Laan
7b79cbd limit total length of user agent comments (Pavol Rusnak) 557f8ea implement uacomment config parameter which can add comments to user agent as per BIP-0014 (Pavol Rusnak)
2015-08-05limit total length of user agent commentsPavol Rusnak
Reworked-By: Wladimir J. van der Laan <laanwj@gmail.com>
2015-08-03Consolidate individual references to the current maximum peer connectionMatt Quinn
value of 125 into a single constant declaration.
2015-07-31implement uacomment config parameterPavol Rusnak
which can add comments to user agent as per BIP-0014
2015-07-27Make CRollingBloomFilter set nTweak for youPeter Todd
While CBloomFilter is usually used with an explicitly set nTweak, CRollingBloomFilter is only used internally. Requiring every caller to set nTweak is error-prone and redundant; better to have the class handle that for you with a high-quality randomness source. Additionally when clearing the filter it makes sense to change nTweak as well to recover from a bad setting, e.g. due to insufficient randomness at initialization, so the clear() method is replaced by a reset() method that sets a new, random, nTweak value.
2015-07-27Merge pull request #5697Wladimir J. van der Laan
60c8bac Includes: Cleanup around net main and wallet (Jorge Timón) 9dd793f TRIVIAL: Missing includes (Jorge Timón)
2015-07-23Includes: Cleanup around net main and walletJorge Timón
-Move from .h to .cpp: in main, net and wallet -Remove unnecessary #include "main.h" -Cleanup some wallet files includes
2015-07-23Merge pull request #6287Wladimir J. van der Laan
a794284 locking: add a quick example of GUARDED_BY (Cory Fields) 2b890dd locking: fix a few small issues uncovered by -Wthread-safety (Cory Fields) cd27bba locking: teach Clang's -Wthread-safety to cope with our scoped lock macros (Cory Fields)
2015-07-10Test whether created sockets are select()ablePieter Wuille
2015-07-10Merge pull request #5288Wladimir J. van der Laan
e3cae52 Added -whiteconnections=<n> option (Josh Lehan)
2015-07-02Adding CSubNet constructor over a single CNetAddrJonas Schnelli
2015-07-02use CBanEntry as object container for banned nodesJonas Schnelli
- added a reason enum for a ban - added creation time for a ban Using CBanEntry as container will keep banlist.dat extenable.