Commit Graph

221 Commits

Author SHA1 Message Date
Cory Fields 2e8cdc8687 net: No need to export DumpBanlist 2021-02-16 18:02:25 +00:00
EthanHeilman 71f39f4160 Fix de-serialization bug where AddrMan is corrupted after exception
* CAddrDB modified so that when de-serialization code throws an exception Addrman is reset to a clean state
* CAddrDB modified to make unit tests possible
* Regression test created to ensure bug is fixed
* StartNode modifed to clear adrman if CAddrDB::Read returns an error code.
2021-02-16 18:02:25 +00:00
Jonas Schnelli edef9aa895 use CBanEntry as object container for banned nodes
- added a reason enum for a ban
- added creation time for a ban

Using CBanEntry as container will keep banlist.dat extenable.
2021-02-16 18:02:24 +00:00
Jonas Schnelli fa9fcfea60 banlist.dat: store banlist on disk 2021-02-16 18:02:24 +00:00
Matt Corallo e286250ce4 Make fDisconnect an std::atomic 2021-01-26 10:23:32 -07:00
Homu 7a97e48cb7 Auto merge of #4909 - str4d:improve-logging, r=str4d
Improve logging

- Fix logging of peer spans under `net=info`.
- Log all mempool-accepted txids under `mempool=info`.
- Log the new log filter under `main=info` when calling `setlogfilter`.
2020-12-17 04:02:38 +00:00
Jack Grigg 42c38b00c1 net: Rework CNode spans
- Extract a reload function for recreating them.
- Record the peer id.
- Remove the peer id and address from the CNode constructor log
  (it will always be shown by the span at that log level).
2020-12-16 01:37:17 +00:00
Kris Nuttycombe e9b5d83709 Prefer explicit passing of CChainParams to the Params() global. 2020-12-15 08:23:09 -07:00
Jorge Timón c3983ccb1c scripted-diff: Remove #include <boost/foreach.hpp>
-BEGIN VERIFY SCRIPT-
sed -i ':a;N;$!ba;s/#include <boost\/foreach.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp
-END VERIFY SCRIPT-
2020-11-23 23:07:15 +00:00
Jorge Timón 92a867febc scripted-diff: Fully remove BOOST_FOREACH
-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-
2020-11-23 23:07:15 +00:00
Wladimir J. van der Laan 73bc7a068d Replace uses of boost::filesystem with fs
Step two in abstracting away boost::filesystem.

To repeat this, simply run:
```
git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g'
```
2020-10-22 01:11:37 +01:00
Wladimir J. van der Laan 7044e39a57 Replace includes of boost/filesystem.h with fs.h
This is step one in abstracting the use of boost::filesystem.
2020-10-22 01:11:37 +01:00
Jack Grigg 253ea6db38 Add some spans to the Zcash codebase 2020-08-07 15:26:28 +01:00
Daira Hopwood f7208c19c5 Clarify definition of NETWORK_UPGRADE_PEER_PREFERENCE_BLOCK_PERIOD.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-04-22 01:15:06 +01:00
Wladimir J. van der Laan 957e5d216f Kill insecure_random and associated global state
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`.

Zcash: Resolved conflicts with the following files

	src/addrman.cpp
	src/main.cpp
	src/net.cpp
	src/net.h
	src/policy/fees.cpp
	src/policy/fees.h
	src/random.cpp
	src/test/merkle_tests.cpp
	src/test/net_tests.cpp
	src/test/prevector_tests.cpp
	src/test/sighash_tests.cpp
	src/test/skiplist_tests.cpp
	src/test/test_bitcoin.cpp
	src/test/versionbits_tests.cpp
	src/wallet/test/crypto_tests.cpp
2020-01-22 21:41:26 +00:00
Luke Dashjr 2e02bb21f7
Constrain constant values to a single location in code 2019-12-04 17:18:39 +00:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Pavol Rusnak 2bc62dc4e3
limit total length of user agent comments
Reworked-By: Wladimir J. van der Laan <laanwj@gmail.com>
2018-04-13 07:40:34 -06:00
Simon 72b2192950 Overwinter peer management and network handshaking.
Implements ZIP 201.
2018-02-23 14:21:27 -08:00
Daira Hopwood 506a21850a Remove UPnP support. fixes #2500
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2017-07-03 08:57:05 +01:00
Patrick Strateman a05be280e7
Remove vfReachable and modify IsReachable to only use vfLimited.
We do not know that a class of Network is reachable, only that it is not.
2017-03-25 20:25:45 +13:00
Wladimir J. van der Laan 975dc649af
torcontrol improvements and fixes
- 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
2017-03-25 20:22:12 +13:00
Matt Quinn 8a5ae3c7a9
Consolidate individual references to the current maximum peer connection
value of 125 into a single constant declaration.
2017-03-25 20:22:07 +13:00
zkbot a7cf698873 Auto merge of #2100 - str4d:2074-rpc, r=arcalinea
Bitcoin 0.12 RPC PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6266
- bitcoin/bitcoin#6257
- bitcoin/bitcoin#6271
- bitcoin/bitcoin#6158
- bitcoin/bitcoin#6307
- bitcoin/bitcoin#6290
- bitcoin/bitcoin#6262
- bitcoin/bitcoin#6088
- bitcoin/bitcoin#6339
- bitcoin/bitcoin#6299 (partial, remainder in #2099)
- bitcoin/bitcoin#6350
- bitcoin/bitcoin#6247
- bitcoin/bitcoin#6362
- bitcoin/bitcoin#5486
- bitcoin/bitcoin#6417
- bitcoin/bitcoin#6398 (partial, remainder was included in #1950)
- bitcoin/bitcoin#6444
- bitcoin/bitcoin#6456 (partial, remainder was included in #2082)
- bitcoin/bitcoin#6380
- bitcoin/bitcoin#6970

Part of #2074.
2017-03-04 02:57:46 +00:00
Philip Kaufmann db954a65ac
use const references where appropriate 2017-03-03 10:57:05 -08:00
Jonas Schnelli fcc8920f36
setban: rewrite to UniValue, allow absolute bantime 2017-03-02 13:23:03 -08:00
Jonas Schnelli e521939942
[RPC] extend setban to allow subnets 2017-03-02 13:23:03 -08:00
Jonas Schnelli 445cd761c5
[net] remove unused return type bool from CNode::Ban() 2017-03-02 13:23:03 -08:00
Jonas Schnelli 997829713c
[net] extend core functionallity for ban/unban/listban 2017-03-02 13:23:03 -08:00
Gregory Maxwell a514cb2968 Only send one GetAddr response per connection.
This conserves resources from abusive peers that just send
 getaddr in a loop. Also makes correlating addr messages
 against INVs less effective.
2016-10-20 20:30:53 -07:00
Gregory Maxwell e2190f8017 Limit setAskFor and retire requested entries only when a getdata returns.
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.
2016-09-15 23:41:29 -07:00
kazcw 56f165bdc1 prevent peer flooding request queue for an inv
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.
2016-09-15 23:17:34 -07:00
Patrick Strateman 0560d671ab Remove redundant whiteconnections option 2016-08-15 19:37:27 -06:00
Patrick Strateman e279e5f90a Record nMinPingUsecTime 2016-08-15 19:31:14 -06:00
Gavin Andresen 9a1dcea2df
Use CScheduler for net's DumpAddresses
Instead of starting Yet Another Thread to dump addresses,
use CScheduler to do it.
2015-05-14 12:50:42 -04:00
Wladimir J. van der Laan 00e76db8c2
Merge pull request #6085
b05a89b Non-grammatical language improvements (Luke Dashjr)
7e6d23b Bugfix: Grammar fixes (Corinne Dashjr)
2015-05-04 08:01:58 +02:00
Corinne Dashjr 7e6d23b171 Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
Gavin Andresen d81cff32e5 Replace mruset setAddrKnown with CRollingBloomFilter addrKnown
Use a probabilistic bloom filter to keep track of which addresses
we think we have given our peers, instead of a list.

This uses much less memory, at the cost of sometimes failing to
relay an address to a peer-- worst case if the bloom filter happens
to be as full as it gets, 1-in-1,000.

Measured memory usage of a full mruset setAddrKnown: 650Kbytes
Constant memory usage of CRollingBloomFilter addrKnown: 37Kbytes.

This will also help heap fragmentation, because the 37K of storage
is allocated when a CNode is created (when a connection to a peer
is established) and then there is no per-item-remembered memory
allocation.

I plan on testing by restarting a full node with an empty peers.dat,
running a while with -debug=addrman and -debug=net, and making sure
that the 'addr' message traffic out is reasonable.
(suggestions for better tests welcome)
2015-04-30 08:16:20 -07:00
Wladimir J. van der Laan dd4ffcec0e
Merge pull request #5859
9519a9a Add correct bool combiner for net signals (Pieter Wuille)
2015-03-12 11:14:03 +01:00
Pieter Wuille 2f10aa0fa1
Merge pull request #5151
eec3713 make CMessageHeader a dumb storage class (Cory Fields)
2015-03-07 05:38:34 -08:00
Pieter Wuille ba04c4a780 Limit message sizes before transfer
This introduces a fixed limit for the size of p2p messages, and enforces it
before download.
2015-03-06 04:03:17 -08:00
Pieter Wuille 9519a9a420 Add correct bool combiner for net signals 2015-03-06 03:45:26 -08:00
Pieter Wuille 9abbeeabd7 Remove obsolete pubsub method definitions 2015-02-26 05:30:59 -08:00
Cory Fields eec37136fd make CMessageHeader a dumb storage class
It shouldn't know or care about bitcoind's chain param selection
2015-02-25 18:44:49 -05:00
Wladimir J. van der Laan 66b473457b
Delete RecvLine function
No longer necessary since #5161 / 845c86d128.
2015-01-20 18:03:20 +01:00
Wladimir J. van der Laan c986972ad7
Merge pull request #5476
73caf47 Display time offset in the debug window's Peers tab (Pavel Janík)
26a6bae Add time offset to getpeerinfo output (Pavel Janík)
2015-01-02 17:54:21 +01:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Pavel Janík 26a6bae753 Add time offset to getpeerinfo output 2014-12-15 11:06:15 +01:00
Pieter Wuille 12a49cac0a Limit the number of new addressses to accumulate 2014-12-04 13:19:16 +01:00