Commit Graph

204 Commits

Author SHA1 Message Date
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
Gregory Maxwell 845c86d128 Do not use third party services for IP detection.
This is a simplified re-do of closed pull #3088.

This patch eliminates the privacy and reliability problematic use
of centralized web services for discovering the node's addresses
for advertisement.

The Bitcoin protocol already allows your peers to tell you what
IP they think you have, but this data isn't trustworthy since
they could lie. So the challenge is using it without creating a
DOS vector.

To accomplish this we adopt an approach similar to the one used
by P2Pool: If we're announcing and don't have a better address
discovered (e.g. via UPNP) or configured we just announce to
each peer the address that peer told us. Since peers could
already replace, forge, or drop our address messages this cannot
create a new vulnerability... but if even one of our peers is
giving us a good address we'll eventually make a useful
advertisement.

We also may randomly use the peer-provided address for the
daily rebroadcast even if we otherwise have a seemingly routable
address, just in case we've been misconfigured (e.g. by UPNP).

To avoid privacy problems, we only do these things if discovery
is enabled.
2014-11-07 12:13:46 -08:00
Cory Fields fa7361907a boost: split stream classes out of serialize.h
serialization now has no dependencies.
2014-10-22 15:21:06 -04:00
Pieter Wuille 341735eb8f Headers-first synchronization
Many changes:
* Do not use 'getblocks', but 'getheaders', and use it to build a headers tree.
* Blocks are fetched in parallel from all available outbound peers, using a
  limited moving window. When one peer stalls the movement of the window, it is
  disconnected.
* No more orphan blocks. At all. We only ever request a block for which we have
  verified the headers, and store it to disk immediately. This means that a
  disk-fill attack would require PoW.
* Require protocol version 31800 for every peer (released in december 2010).
* No more syncnode (we sync from everyone we can, though limited to 1 during
  initial *headers* sync).
* Introduce some extra named constants, comments and asserts.
2014-10-14 15:42:01 -07:00
Wladimir J. van der Laan d4168c82be Limit CNode::mapAskFor
Tighten resource constraints on CNode.
2014-09-09 09:19:15 +02:00
Philip Kaufmann 093303a887 add missing header end comments
- ensures a consistent usage in header files
- also add a blank line after the copyright header where missing
- also remove orphan new-lines at the end of some files
2014-08-28 22:25:21 +02:00
Wladimir J. van der Laan ad49c256c3 Split up util.cpp/h
Split up util.cpp/h into:

- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)

The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).

Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-26 13:25:22 +02:00
Wladimir J. van der Laan 651480c8e4 move functions in main and net to implementation files 2014-08-26 13:25:21 +02:00
Wladimir J. van der Laan 04d6c7d10c
Merge pull request #4605
aa82795 Add detailed network info to getnetworkinfo RPC (Wladimir J. van der Laan)
075cf49 Add GetNetworkName function (Wladimir J. van der Laan)
c91a947 Add IsReachable(net) function (Wladimir J. van der Laan)
60dc8e4 Allow -onlynet=onion to be used (Wladimir J. van der Laan)
2014-08-18 13:37:54 +02:00
Philip Kaufmann efd6b87811 small net cleanup
- add comment for disabling sigpipe
- add closing comment in compat.h
- remove redundant check in net.h
2014-08-08 07:40:45 +02:00
Wladimir J. van der Laan c91a9471be Add IsReachable(net) function
Allows other parts of the program to query for reachable
status of a network. Similar to IsLimited(net).
2014-07-30 15:41:17 +02:00
Wladimir J. van der Laan 0430c30af1 Add missing FindNode prototype to net.h
Also make the argument a const std::string & instead of pass-by-value.
2014-07-24 17:28:47 +02:00
Wladimir J. van der Laan 43f510d37d Convert closesocket 'compat wrapper' to function in netbase
Simpler alternative to #4348.

The current setup with closesocket() is strange. It poses
as a compatibility wrapper but adds functionality.

Rename it and make it a documented utility function in netbase.

Code movement only, zero effect on the functionality.
2014-07-17 15:46:25 +02:00
Wladimir J. van der Laan 6513a9f703
Merge pull request #4400
4eedf4f make RandAddSeed() use OPENSSL_cleanse() (Philip Kaufmann)
6354935 move rand functions from util to new random.h/.cpp (Philip Kaufmann)
001a53d add GetRandBytes() as wrapper for RAND_bytes() (Philip Kaufmann)
2014-07-14 11:35:30 +02:00
Pieter Wuille dc942e6f27 Introduce whitelisted peers.
This adds a -whitelist option to specify subnet ranges from which peers
that connect are whitelisted. In addition, there is a -whitebind option
which works like -bind, except peers connecting to it are also
whitelisted (allowing a separate listen port for trusted connections).

Being whitelisted has two effects (for now):
* They are immune to DoS disconnection/banning.
* Transactions they broadcast (which are valid) are always relayed,
  even if they were already in the mempool. This means that a node
  can function as a gateway for a local network, and that rebroadcasts
  from the local network will work as expected.

Whitelisting replaces the magic exemption localhost had for DoS
disconnection (local addresses are still never banned, though), which
implied hidden service connects (from a localhost Tor node) were
incorrectly immune to DoS disconnection as well. This old
behaviour is removed for that reason, but can be restored using
-whitelist=127.0.0.1 or -whitelist=::1 can be specified. -whitebind
is safer to use in case non-trusted localhost connections are expected
(like hidden services).
2014-07-09 20:40:14 +02:00
Philip Kaufmann 6354935c48 move rand functions from util to new random.h/.cpp 2014-07-09 09:42:19 +02:00
Wladimir J. van der Laan e1f7c7d173
Merge pull request #4472
9f4da19 Use pong receive time rather than processing time (Pieter Wuille)
2014-07-07 06:28:43 +02:00
Pieter Wuille 9f4da19bab Use pong receive time rather than processing time 2014-07-06 16:08:18 +02:00