Commit graph

540 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
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