Commit graph

641 commits

Author SHA1 Message Date
Wladimir J. van der Laan d9c99c3058 net: No longer send local address in addrMe
After #8594 the addrFrom sent by a node is not used anymore at all,
so don't bother sending it.

Also mitigates the privacy issue in (#8616). It doesn't completely solve
the issue as GetLocalAddress is also called in AdvertiseLocal, but at
least when advertising addresses it stands out less as *our* address.
2016-09-15 23:42:01 +02:00
Cory Fields f3552da813 net: fix maxuploadtarget setting
This was broken by 63cafa6329.

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-14 13:14:04 -04:00
Wladimir J. van der Laan 881d7eaf29
Merge #8715: net: only delete CConnman if it's been created
36fa01f net: only delete CConnman if it's been created (Cory Fields)
2016-09-14 10:16:25 +02:00
Cory Fields 36fa01f217 net: only delete CConnman if it's been created
In the case of (for example) an already-running bitcoind, the shutdown sequence
begins before CConnman has been created, leading to a null-pointer dereference
when g_connman->Stop() is called.

Instead, Just let the CConnman dtor take care of stopping.
2016-09-13 22:43:23 -04:00
Jonas Schnelli 1b6bcdd3aa
Remove maxuploadtargets recommended minimum 2016-09-13 18:08:17 +02:00
Cory Fields 0103c5b90f net: move MAX_FEELER_CONNECTIONS into connman 2016-09-08 13:06:05 -04:00
Jeremy Rubin e700cd0bc8 Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead 2016-09-08 13:06:05 -04:00
Jeremy Rubin d1a2295f0d Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting 2016-09-08 13:06:05 -04:00
Cory Fields 98591c5027 net: move vNodesDisconnected into CConnman 2016-09-08 13:06:05 -04:00
Cory Fields fa2f8bc47f net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::Options 2016-09-08 13:06:00 -04:00
Cory Fields a19553b992 net: Introduce CConnection::Options to avoid passing so many params 2016-09-08 13:04:29 -04:00
Cory Fields bafa5fc5a1 net: Drop StartNode/StopNode and use CConnman directly 2016-09-08 12:24:07 -04:00
Cory Fields e81a602cf0 net: pass CClientUIInterface into CConnman 2016-09-08 12:24:07 -04:00
Cory Fields f60b9059e4 net: Pass best block known height into CConnman
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-08 12:24:06 -04:00
Cory Fields fdf69ff21a net: move max/max-outbound to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 8a593694b1 net: move semOutbound to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields bd72937dc4 net: move nLocalServices/nRelevantServices to CConnman
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-08 12:24:06 -04:00
Cory Fields be9c796dc5 net: move SendBufferSize/ReceiveFloodSize to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 63cafa6329 net: move send/recv statistics to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields adf5d4c2e4 net: SocketSendData returns written size 2016-09-08 12:24:06 -04:00
Cory Fields ee44fa9576 net: move messageHandlerCondition to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 960cf2e405 net: move nLocalHostNonce to CConnman
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-08 12:24:06 -04:00
Cory Fields 551e0887db net: move nLastNodeId to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 6c19d92361 net: move whitelist functions into CConnman 2016-09-08 12:24:06 -04:00
Cory Fields 53347f0cb9 net: create generic functor accessors and move vNodes to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields c0569c7fa1 net: Add most functions needed for vNodes to CConnman 2016-09-08 12:12:58 -04:00
Cory Fields 8ae2dac1c6 net: move added node functions to CConnman 2016-09-08 12:12:58 -04:00
Cory Fields 502dd3a8a0 net: Add oneshot functions to CConnman 2016-09-08 12:12:57 -04:00
Cory Fields a0f3d3cdad net: move ban and addrman functions into CConnman 2016-09-08 12:12:57 -04:00
Cory Fields aaf018e3b7 net: handle nodesignals in CConnman 2016-09-08 12:06:24 -04:00
Cory Fields b1a5f43208 net: move OpenNetworkConnection into CConnman 2016-09-08 12:06:24 -04:00
Cory Fields 02137f11e2 net: Move socket binding into CConnman 2016-09-08 12:06:24 -04:00
Cory Fields 8d58c4d81f net: Pass CConnman around as needed 2016-09-08 12:04:35 -04:00
Cory Fields cd16f48028 net: Create CConnman to encapsulate p2p connections 2016-09-08 12:04:35 -04:00
Cory Fields d93b14dc5d net: move CBanDB and CAddrDB out of net.h/cpp
This will eventually solve a circular dependency
2016-09-08 12:03:22 -04:00
Wladimir J. van der Laan cbe9ae8c69
Merge #8466: [Trivial] Do not shadow variables in networking code
b7c349d Do not shadow variables in networking code (Pavel Janík)
2016-09-02 12:51:56 +02:00
Pieter Wuille 53f8f226bd
Merge #8462: Move AdvertiseLocal debug output to net category
f13c1ba Move AdvertiseLocal debug output to net category (Michael Rotarius)
2016-08-25 15:15:16 +02:00
Ethan Heilman dbb1f640e6 Added feeler connections increasing good addrs in the tried table.
Tests if addresses are online or offline by briefly connecting to them. These short lived connections are referred to as feeler connections. Feeler connections are designed to increase the number of fresh online addresses in tried by selecting and connecting to addresses in new. One feeler connection is attempted on average once every two minutes.

This change was suggested as Countermeasure 4 in
Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman,
Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report
2015/263. March 2015.
2016-08-23 16:26:42 -04:00
Wladimir J. van der Laan e753eaeb34
Merge #8505: Trivial: Fix typos in various files
1aacfc2 various typos (leijurv)
2016-08-17 12:51:16 +02:00
Pavel Janík b7c349d5e7 Do not shadow variables in networking code 2016-08-15 14:10:07 +02:00
Wladimir J. van der Laan 1030fa718c
Merge #8128: Net: Turn net structures into dumb storage classes
9e9d644 net: fixup nits (Cory Fields)
8945384 net: Have LookupNumeric return a CService directly (Cory Fields)
21ba407 net: narrow include scope after moving to netaddress (Cory Fields)
21e5b96 net: move CNetAddr/CService/CSubNet out of netbase (Cory Fields)
1017b8a net: Add direct tests for new CSubNet constructors (Cory Fields)
b6c3ff3 net: Split resolving out of CSubNet (Cory Fields)
f96c7c4 net: Split resolving out of CService (Cory Fields)
31d6b1d net: Split resolving out of CNetAddr (Cory Fields)
2016-08-15 13:35:27 +02:00
leijurv 1aacfc2da5
various typos 2016-08-14 07:57:11 -06:00
Michael Rotarius f13c1bae52 Move AdvertiseLocal debug output to net category 2016-08-05 18:34:32 +02:00
Cory Fields 8945384bca net: Have LookupNumeric return a CService directly
Also fix up a few small issues:
- Lookup with "badip:port" now sets the port to 0
- Don't allow assert to have side-effects
2016-08-04 16:41:39 -04:00
Wladimir J. van der Laan f97d335942
Merge #8392: Fix several node initialization issues
9d4eb9a Do diskspace check before import thread is started (Pieter Wuille)
aa59f2e Add extra message to avoid a long 'Loading banlist' (Pieter Wuille)
0fd2a33 Use a signal to continue init after genesis activation (Pieter Wuille)
2016-08-04 12:33:21 +02:00
Wladimir J. van der Laan 194110fb91
Merge #8189: rename mapAddrCount to mapNetGroupNodes
657fc19 rename mapAddrCount to mapNetGroupNodes (instagibbs)
2016-08-03 11:50:45 +02:00
Cory Fields 21ba407a73 net: narrow include scope after moving to netaddress
Net functionality is no longer needed for CAddress/CAddrman/etc. now that
CNetAddr/CService/CSubNet are dumb storage classes.
2016-07-31 14:01:44 -04:00
Cory Fields f96c7c4d91 net: Split resolving out of CService 2016-07-31 13:24:07 -04:00
Cory Fields 31d6b1d5f0 net: Split resolving out of CNetAddr 2016-07-31 13:24:07 -04:00
Pieter Wuille aa59f2ed3f Add extra message to avoid a long 'Loading banlist' 2016-07-30 02:17:51 +02:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Pieter Wuille b8a97498df BIP144: Handshake and relay (receiver side)
Service bit logic by Nicolas Dorier.

Only download blocks from witness peers after fork.
2016-06-22 15:42:59 +02:00
Matt Corallo 927f8eede0 Add ability to fetch CNode by NodeId 2016-06-19 23:06:55 -07:00
Wladimir J. van der Laan 3f89a534ac
Merge #8113: Rework addnode behaviour
1a5a4e6 Randomize name lookup result in ConnectSocketByName (Pieter Wuille)
f9f5cfc Prevent duplicate connections where one is by name and another by ip (Pieter Wuille)
1111b80 Rework addnode behaviour (Pieter Wuille)
2016-06-16 12:06:51 +02:00
Wladimir J. van der Laan e4bb4a85a5
Merge #8084: Add recently accepted blocks and txn to AttemptToEvictConnection.
6ee7f05 Allow disconnecting a netgroup with only one member in eviction. (Gregory Maxwell)
5d0ca81 Add recently accepted blocks and txn to AttemptToEvictConnection. (Gregory Maxwell)
2016-06-16 11:03:52 +02:00
Gregory Maxwell 6ee7f05622 Allow disconnecting a netgroup with only one member in eviction.
With the latest additions there are enough protective measures that
 we can take the training wheels off.
2016-06-15 20:19:13 +00:00
Gregory Maxwell 5d0ca81f74 Add recently accepted blocks and txn to AttemptToEvictConnection.
This protects any not-already-protected peers who were the most
 recent four to relay transactions and most recent four to send
 blocks to us.
2016-06-15 20:19:07 +00:00
Pieter Wuille bc0a895d81 Do not set extra flags for unfiltered DNS seed results 2016-06-15 19:31:58 +02:00
Pieter Wuille f9f5cfc506 Prevent duplicate connections where one is by name and another by ip 2016-06-13 23:53:08 +02:00
Pieter Wuille 1111b80df8 Rework addnode behaviour
* Use CNode::addeName to track whether a connection to a name is already open
  * A new connection to a previously-connected by-name addednode is only opened when
    the previous one closes (even if the name starts resolving to something else)
  * At most one connection is opened per addednode (even if the name resolves to multiple)
* Unify the code between ThreadOpenAddedNodeConnections and getaddednodeinfo
  * Information about open connections is always returned, and the dns argument becomes a dummy
  * An IP address and inbound/outbound is only reported for the (at most 1) open connection
2016-06-13 23:53:06 +02:00
Pieter Wuille ecd7fd37c8 Introduce REQUIRED_SERVICES constant 2016-06-13 17:40:16 +02:00
Pieter Wuille ee06e04369 Introduce enum ServiceFlags for service flags 2016-06-13 17:40:16 +02:00
Pieter Wuille 15bf863219 Don't require services in -addnode 2016-06-13 17:40:16 +02:00
Pieter Wuille 5e7ab16d29 Only store and connect to NODE_NETWORK nodes 2016-06-13 17:40:16 +02:00
Pieter Wuille fc83f18153 Verify that outbound connections have expected services 2016-06-13 17:40:16 +02:00
instagibbs 657fc19d65 rename mapAddrCount to mapNetGroupNodes 2016-06-10 10:09:06 -04:00
Pieter Wuille 4286f43025
Merge #8173: Use SipHash for node eviction (cont'd)
eebc232 test: Add more test vectors for siphash (Wladimir J. van der Laan)
8884830 Use C++11 thread-safe static initializers (Pieter Wuille)
c31b24f Use 64-bit SipHash of netgroups in eviction (Pieter Wuille)
9bf156b Support SipHash with arbitrary byte writes (Pieter Wuille)
053930f Avoid recalculating vchKeyedNetGroup in eviction logic. (Patrick Strateman)
2016-06-08 18:32:34 +02:00
Pieter Wuille cd0c5135ab
Merge #8083: Add support for dnsseeds with option to filter by servicebits
2d83013d Add support for dnsseeds with option to filter by servicebits (Jonas Schnelli)
2016-06-08 17:42:14 +02:00
Wladimir J. van der Laan 67c91f8c4c
Merge #8065: Addrman offline attempts
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell)
c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
2016-06-08 13:01:53 +02:00
Pieter Wuille 888483098e Use C++11 thread-safe static initializers 2016-06-07 16:29:03 +02:00
Pieter Wuille c31b24f745 Use 64-bit SipHash of netgroups in eviction 2016-06-07 16:20:40 +02:00
Patrick Strateman 053930ffc4 Avoid recalculating vchKeyedNetGroup in eviction logic.
Lazy calculate vchKeyedNetGroup in CNode::GetKeyedNetGroup.
2016-06-07 16:20:40 +02:00
Gregory Maxwell 4d8993b346 Defer inserting into maprelay until just before relaying.
This reduces the rate of not founds by better matching the far
 end expectations, it also improves privacy by removing the
 ability to use getdata to probe for a node having a txn before
 it has been relayed.
2016-05-31 15:35:45 +00:00
Wladimir J. van der Laan 862fd24b40
Merge #8080: Do not use mempool for GETDATA for tx accepted after the last mempool req.
7e908c7 Do not use mempool for GETDATA for tx accepted after the last mempool req. (Gregory Maxwell)
2016-05-31 15:47:32 +02:00
Pieter Wuille 52b02ecd6d Use global ::fRelayTxes instead of CNode one 2016-05-26 20:04:43 +02:00
Pieter Wuille c028c7b755
Merge #8049: Expose information on whether transaction relay is enabled in getnetwork
1ab1dc3 rpc: Add `relaytxes` flag to `getnetworkinfo` (Wladimir J. van der Laan)
581ddff net: Add fRelayTxes flag (Wladimir J. van der Laan)
2016-05-26 15:02:16 +02:00
Gregory Maxwell 6182d10503 Do not increment nAttempts by more than one for every Good connection.
This slows the increase of the nAttempts in addrman while partitioned,
 even if the node hasn't yet noticed the partitioning.
2016-05-26 12:56:32 +00:00
Gregory Maxwell c769c4af11 Avoid counting failed connect attempts when probably offline.
If a node is offline failed outbound connection attempts will crank up
 the addrman counter and effectively blow away our state.

This change reduces the problem by only counting attempts made while
 the node believes it has outbound connections to at least two
 netgroups.

Connect and addnode connections are also not counted, as there is no
 reason to unequally penalize them for their more frequent
 connections -- though there should be no real effect from this
 unless their addnode configureation is later removed.

Wasteful repeated connection attempts while only a few connections are
 up are avoided via nLastTry.

This is still somewhat incomplete protection because our outbound
 peers could be down but not timed out or might all be on 'local'
 networks (although the requirement for multiple netgroups helps).
2016-05-26 12:56:27 +00:00
Gregory Maxwell 7e908c7b82 Do not use mempool for GETDATA for tx accepted after the last mempool req.
The ability to GETDATA a transaction which has not (yet) been relayed
 is a privacy loss vector.

The use of the mempool for this was added as part of the mempool p2p
 message and is only needed to fetch transactions returned by it.
2016-05-25 18:05:58 +00:00
Jonas Schnelli 2d83013dc5
Add support for dnsseeds with option to filter by servicebits 2016-05-25 14:57:24 +02:00
Wladimir J. van der Laan 83121cca75
Merge #7906: net: prerequisites for p2p encapsulation changes
5d5e7a0 net: No need to export ConnectNode (Cory Fields)
e9ed620 net: No need to export DumpBanlist (Cory Fields)
8b8f877 net: make Ban/Unban/ClearBan functionality consistent (Cory Fields)
cca221f net: Drop CNodeRef for AttemptToEvictConnection (Cory Fields)
563f375 net: use the exposed GetNodeSignals() rather than g_signals directly (Cory Fields)
9faa490 net: remove unused set (Cory Fields)
52cbce2 net: don't import std namespace (Cory Fields)
2016-05-18 12:13:05 +02:00
Pieter Wuille 5c3f8ddcaa
Merge #7696: Fix de-serialization bug where AddrMan is left corrupted
1475ecf 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. (EthanHeilman)
2016-05-17 10:53:00 +02:00
Gregory Maxwell d87b198b73 Remove unneeded feerate param from RelayTransaction/AcceptToMemoryPool. 2016-05-16 04:10:06 +00:00
Wladimir J. van der Laan 581ddff05c net: Add fRelayTxes flag
Add a fRelayTxes to keep track of the relay transaction flag
we send to other peers.
2016-05-12 14:12:46 +02:00
Cory Fields e9ed6206b3 net: No need to export DumpBanlist 2016-05-10 12:28:22 -04:00
Cory Fields 8b8f87714d net: make Ban/Unban/ClearBan functionality consistent
- Ban/Unban/ClearBan call uiInterface.BannedListChanged() as necessary
- Ban/Unban/ClearBan sync to disk if the operation is user-invoked
- Mark node for disconnection automatically when banning
- Lock cs_vNodes while setting disconnected
- Don't spin in a tight loop while setting disconnected
2016-05-10 12:28:22 -04:00
Kaz Wesley e53e7c5473 don't run ThreadMessageHandler at lowered priority
There's no clear reason ThreadMessageHandler should be low priority.
Fixes #8010 (priority inversion).
2016-05-05 13:25:35 -07:00
Cory Fields cca221fd21 net: Drop CNodeRef for AttemptToEvictConnection
Locking for each operation here is unnecessary, and solves the wrong problem.
Additionally, it introduces a problem when cs_vNodes is held in an owning
class, to which invididual CNodeRefs won't have access.

These should be weak pointers anyway, once vNodes contain shared pointers.

Rather than using a refcounting class, use a 3-step process instead.

1. Lock vNodes long enough to snapshot the fields necessary for comparing
2. Unlock and do the comparison
3. Re-lock and mark the resulting node for disconnection if it still exists
2016-05-05 13:22:25 -04:00
Cory Fields 563f375cde net: use the exposed GetNodeSignals() rather than g_signals directly 2016-05-05 13:22:25 -04:00
Cory Fields 9faa4902cd net: remove unused set 2016-05-05 13:22:24 -04:00
Cory Fields 52cbce287a net: don't import std namespace
This file is about to be broken up into chunks and moved around. Drop the
namespace now rather than requiring other files to use it.
2016-05-05 13:22:24 -04:00
Wladimir J. van der Laan 3b9a0bf41f
Merge #7840: Several performance and privacy improvements to inv/mempool handling
b559914 Move bloom and feerate filtering to just prior to tx sending. (Gregory Maxwell)
4578215 Return mempool queries in dependency order (Pieter Wuille)
ed70683 Handle mempool requests in send loop, subject to trickle (Pieter Wuille)
dc13dcd Split up and optimize transaction and block inv queues (Pieter Wuille)
f2d3ba7 Eliminate TX trickle bypass, sort TX invs for privacy and priority. (Gregory Maxwell)
2016-05-05 13:14:40 +02:00
EthanHeilman 1475ecf611 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.
2016-05-04 18:55:01 -04:00
Wladimir J. van der Laan 8206835cc1
Merge #7974: More comments on the design of AttemptToEvictConnection.
d90351f More comments on the design of AttemptToEvictConnection. (Gregory Maxwell)
2016-05-04 15:52:13 +02:00
Gregory Maxwell d90351f050 More comments on the design of AttemptToEvictConnection.
Some developers clearly don't get this and have been posting
 "improvements" that create clear vulnerabilities.  It should
 have been better explained in the code, since the design
 is somewhat subtle and getting it right is important.
2016-04-29 23:15:23 +00:00
Kaz Wesley f4ac02ee7c fix race that could fail to persist a ban
DumpBanList currently does this:
  - with lock: take a copy of the banmap
  - perform I/O (write out the banmap)
  - with lock: mark the banmap non-dirty
If a new ban is added during the I/O operation, it may never be persisted to
disk.

Reorder operations so that the data to be persisted cannot be older than the
time at which the banmap was marked non-dirty.
2016-04-27 09:41:13 -07:00
Gregory Maxwell b559914753 Move bloom and feerate filtering to just prior to tx sending.
This will avoid sending more pointless INVs around updates, and
 prevents using filter updates to timetag transactions.

Also adds locking for fRelayTxes.
2016-04-21 00:33:56 +02:00
Pieter Wuille ed7068302c Handle mempool requests in send loop, subject to trickle
By eliminating queued entries from the mempool response and responding only at
trickle time, this makes the mempool no longer leak transaction arrival order
information (as the mempool itself is also sorted)-- at least no more than
relay itself leaks it.
2016-04-21 00:33:56 +02:00
Cory Fields a98cd1fc86 net: manually resolve dns seed sources
Note: Some seeds aren't actually returning an IP for their name entries, so
they're being added to addrman with a source of [::].

This commit shouldn't change that behavior, for better or worse.
2016-04-20 13:07:19 -04:00
Cory Fields e9fc71e5fa net: require lookup functions to specify all arguments
To make it clear where DNS resolves are happening
2016-04-17 17:37:36 -04:00
Wladimir J. van der Laan 64e71b3721
Merge #7856: Only send one GetAddr response per connection.
66b0724 Only send one GetAddr response per connection. (Gregory Maxwell)
2016-04-15 09:03:17 +02:00
Pieter Wuille 38c310299c Change mapRelay to store CTransactions 2016-04-14 16:24:56 +02:00
Suhas Daftuar 7e91f632c7 Use txid as key in mapAlreadyAskedFor
Previously we used the CInv that would be sent to the peer announcing the
transaction as the key, but using the txid instead allows us to decouple the
p2p layer from the application logic (which relies on this map to avoid
duplicate tx requests).
2016-04-11 15:58:01 -04:00
Gregory Maxwell 66b07247a7 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-04-11 01:09:34 +00:00
Alex Morcos 9e072a6e66 Implement "feefilter" P2P message.
The "feefilter" p2p message is used to inform other nodes of your mempool min fee which is the feerate that any new transaction must meet to be accepted to your mempool.  This will allow them to filter invs to you according to this feerate.
2016-03-21 10:46:25 -04:00
Patrick Strateman 110b62f069 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.
2016-02-17 23:21:27 -08:00
jloughry 37767fd46f fix spelling of advertise in src and doc 2016-02-12 12:51:54 -07:00
Wladimir J. van der Laan 2cdbf28cf3
Merge #7192: Unify product name to as few places as possible
027fdb8 When/if the copyright line does not mention Bitcoin Core developers, add a second line to copyrights in -version, About dialog, and splash screen (Luke Dashjr)
cc2095e Rewrite FormatParagraph to handle newlines within input strings correctly (Luke Dashjr)
cddffaf Bugfix: Include COPYRIGHT_HOLDERS_SUBSTITUTION in Makefile substitutions so it gets passed to extract-strings correctly (Luke Dashjr)
29598e4 Move PACKAGE_URL to configure.ac (Luke Dashjr)
78ec83d splashscreen: Resize text to fit exactly (Luke Dashjr)
3cae140 Bugfix: Actually use _COPYRIGHT_HOLDERS_SUBSTITUTION everywhere (Luke Dashjr)
4d5a3df Bugfix: gitian-descriptors: Add missing python-setuptools requirement for OS X (biplist module) (Luke Dashjr)
e4ab5e5 Bugfix: Correct copyright year in Mac DMG background image (Luke Dashjr)
917b1d0 Set copyright holders displayed in notices separately from the package name (Luke Dashjr)
c39a6ff Travis & gitian-osx: Use depends for ds_store and mac_alias modules (Luke Dashjr)
902ccde depends: Add mac_alias to depends (Luke Dashjr)
82a2d98 depends: Add ds_store to depends (Cory Fields)
de619a3 depends: Pass PYTHONPATH along to configure (Cory Fields)
e611b6e macdeploy: Use rsvg-convert rather than cairosvg (Luke Dashjr)
63bcdc5 More complicated package name substitution for Mac deployment (Luke Dashjr)
1a6c67c Parameterise 2009 in translatable copyright strings (Luke Dashjr)
d5f4683 Unify package name to as few places as possible without major changes (Luke Dashjr)
2016-02-04 13:42:24 +01:00
Wladimir J. van der Laan 898fedf42f
Merge #7458: [Net] peers.dat, banlist.dat recreated when missing
c77c662 peers.dat, banlist.dat recreated when missing (kirkalx)
2016-02-04 08:54:21 +01:00
kirkalx c77c6625f3 peers.dat, banlist.dat recreated when missing 2016-02-04 11:46:24 +13:00
Luke Dashjr a68bb9f5e7 Merge branch 'master' into single_prodname 2016-02-03 05:41:13 +00:00
Gregory Maxwell 1e05727072 Decide eviction group ties based on time.
This corrects a bug the case of tying group size where the code may
 fail to select the group with the newest member. Since newest time
 is the final selection criteria, failing to break ties on it
 on the step before can undermine the final selection.

Tied netgroups are very common.

(cherry picked from commit 8e09f914f8)
2016-02-01 15:31:21 +01:00
Gregory Maxwell 1e9613ac09 Do not absolutely protect local peers from eviction.
With automatic tor HS support in place we should probably not be providing
 absolute protection for local peers, since HS inbound could be used to
 attack pretty easily.  Instead, this counts on the latency metric inside
 AttemptToEvictConnection to privilege actually local peers.

(cherry picked from commit 46dbcd4833)
2016-02-01 15:31:17 +01:00
Wladimir J. van der Laan 5578144413
Merge #7350: Banlist updates
e8600c9 banlist (bugfix): allow CNode::SweepBanned() to run on interval (Philip Kaufmann)
2977c24 banlist: add more banlist infos to log / add GUI signal (Philip Kaufmann)
ce479aa banlist: better handling of banlist in StartNode() (Philip Kaufmann)
57c77fe banlist: update set dirty to be more fine grained (Philip Kaufmann)
2016-01-20 13:38:40 +01:00
Chris Wheeler 9d263bd17c Typo fixes in comments 2016-01-17 11:03:56 +00:00
Luke Dashjr 5bc4fb7b60 Merge branch 'master' into 20150703_banlist_updates 2016-01-15 05:17:15 +00:00
Wladimir J. van der Laan 605c17844e
Merge pull request #7205
fa71669 [devtools] Use git pretty-format for year parsing (MarcoFalke)
fa24439 Bump copyright headers to 2015 (MarcoFalke)
fa6ad85 [devtools] Rewrite fix-copyright-headers.py (MarcoFalke)
2016-01-05 14:11:40 +01:00
21E14 a5a0831458 Double semicolon cleanup. 2015-12-30 12:23:07 -05:00
Luke Dashjr d5f46832de Unify package name to as few places as possible without major changes 2015-12-14 02:11:10 +00:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Pieter Wuille 5400ef6bcb Replace trickle nodes with per-node/message Poisson delays
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.
2015-12-11 22:20:38 +01:00
Wladimir J. van der Laan 9bbe71b641 net: Add and document network messages in protocol.h
- 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.
2015-12-10 12:14:06 +01:00
Wladimir J. van der Laan e3bc5e0e92 net: Account for sendheaders verack messages
Looks like these were forgotten in #6589.
2015-12-07 15:17:53 +01:00
Jonas Schnelli ca188c629e
log bytes recv/sent per command 2015-12-07 13:32:59 +01:00
Wladimir J. van der Laan 8843676621
Merge pull request #7133
aa4b0c2 When not filtering blocks, getdata sends more in one test (Pieter Wuille)
d41e44c Actually only use filterInventoryKnown with MSG_TX inventory messages. (Gregory Maxwell)
b6a0da4 Only use filterInventoryKnown with MSG_TX inventory messages. (Patick Strateman)
6b84935 Rename setInventoryKnown filterInventoryKnown (Patick Strateman)
e206724 Remove mruset as it is no longer used. (Gregory Maxwell)
ec73ef3 Replace setInventoryKnown with a rolling bloom filter. (Gregory Maxwell)
2015-12-03 13:16:46 +01:00
Wladimir J. van der Laan 1b5118bfa0
Merge pull request #7079
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-12-01 09:02:33 +01:00
Patick Strateman 6b849350ab Rename setInventoryKnown filterInventoryKnown 2015-11-30 12:53:48 +01:00
Gregory Maxwell ec73ef37ec Replace setInventoryKnown with a rolling bloom filter.
Mruset setInventoryKnown was reduced to a remarkably small 1000
 entries as a side effect of sendbuffer size reductions in 2012.

This removes setInventoryKnown filtering from merkleBlock responses
 because false positives there are especially unattractive and
 also because I'm not sure if there aren't race conditions around
 the relay pool that would cause some transactions there to
 be suppressed. (Also, ProcessGetData was accessing
 setInventoryKnown without taking the required lock.)
2015-11-30 12:53:48 +01:00
Luke Dashjr b966aa836a Constrain constant values to a single location in code 2015-11-28 18:47:29 +01:00
Gregory Maxwell ebb25f4c23 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.
2015-11-23 01:54:23 +00:00
kazcw 5029698186 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.
2015-11-23 01:18:54 +00:00
Peter Todd 08843ed998 Add relaytxes status to getpeerinfo 2015-11-20 16:07:12 -08:00
Patick Strateman 71a2683f4b Use DEFAULT_BLOCKSONLY and DEFAULT_WHITELISTALWAYSRELAY constants 2015-11-14 05:10:59 -08:00
Patick Strateman 4044f07d1c Add blocksonly mode 2015-11-14 04:52:21 -08:00
MarcoFalke b27e81f115 [net] Cleanup maxuploadtarget
* 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-12 20:45:57 +01:00
Wladimir J. van der Laan 09c1ae1c01 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
2015-11-12 17:58:15 +01:00
Wladimir J. van der Laan 8f4e67f152 net: Automatically create hidden service, listen on Tor
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-11-10 17:29:56 +01:00
Jonas Schnelli 872fee3fcc
Introduce -maxuploadtarget
* -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-26 15:37:30 +01:00
Gregory Maxwell a4e28b3d1e Set TCP_NODELAY on P2P sockets.
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-10-22 17:57:48 +00:00
Philip Kaufmann e8600c924d banlist (bugfix): allow CNode::SweepBanned() to run on interval
- allows CNode::SweepBanned() to run, even if !CNode::BannedSetIsDirty(),
  because if nBanUntil is over we want the ban to be disabled for these
  nodes
2015-10-02 11:38:16 +02:00
Philip Kaufmann 2977c243ef banlist: add more banlist infos to log / add GUI signal
- to match the peers.dat handling also supply a debug.log entry for how
  many entries were loaded from banlist.dat and how long it took
- add a GUI init message for loading the banlist (same as with peers.dat)

- move the same message for peers.dat upwards in the code, to be able to
  reuse the timing variable nStart and also just log, if our read from
  peers.dat didn't fail
2015-10-02 11:38:16 +02:00
Philip Kaufmann ce479aaada banlist: better handling of banlist in StartNode()
- only start working on/with banlist data, if reading in the banlist from
  disk didn't fail
- as CNode::setBannedIsDirty is false (default) when reading fails, we
  don't need to explicitly set it to false to prevent writing
  banlist.dat in that case either
2015-10-02 11:38:15 +02:00
Philip Kaufmann 57c77fe4d3 banlist: update set dirty to be more fine grained
- move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist()
- ensure we only set false, if the write succeeded
2015-10-02 11:38:14 +02:00
Wladimir J. van der Laan 93ff1b9041 net: correctly initialize nMinPingUsecTime
`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-04 16:27:38 +02:00
Matt Corallo a6eb4ba38b Report minimum ping time in getpeerinfo 2015-09-03 13:06:13 -07:00
Wladimir J. van der Laan 69dc5b51a0
Merge pull request #6374
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-09-03 18:27:24 +02:00
Wladimir J. van der Laan af9305a7e8
Merge pull request #6583
9f3e48e add support for miniupnpc api version 14 (Pavel Vasin)
2015-08-31 17:38:07 +02:00
Patrick Strateman 027de94e1f
Use network group instead of CNetAddr in final pass to select node to disconnect 2015-08-30 22:09:14 -07:00
J Ross Nicoll 9bebf60698
Make sure LogPrint strings are line-terminated 2015-08-29 17:40:13 +01:00
Patrick Strateman 000c18aace Fix comment 2015-08-25 16:31:13 -07:00