Commit graph

22 commits

Author SHA1 Message Date
Daniel Krawisz
c0b57def7f Added tests for addrmgr.KnownAddress
Adjusted tests in response to redefinition of KnownAddress.chance
2015-04-21 19:10:39 -05:00
David Hill
2cc85ef428 Reduce fingerprinting.
This change reduces fingerprinting via timestamps in addr messages.
Previously, the last seen time for an address was updated when
certain protocol commands were received.  Now, the last seen time
is set when the peer disconnects if the peer had sent a verack
message and was connected for more than 20 minutes.

This mimics Bitcoin Core commit:
9c2737901b5203f267d21d728019d64b46f1d9f3

Also, add additional sanity checking before updating the peer's
timestamp.  These include:

 - Do not mark a peer as connected if we never received
   a version message.
 - Disconnect a peer for sending a verack before btcd
   sent a version
 - Disconnect a peer for sending multiple verack's
2015-04-14 12:38:41 -04:00
David Hill
0eef96e1c8 addrmgr: Always use a 50% chance between tried and new entries.
This change was suggested as Countermeasure 2 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.

This mimics Bitcoin Core commit c6a63ceeb4956933588995bcf01dc3095aaeb1fc
2015-04-14 12:28:45 -04:00
David Hill
320ecea6a0 addrmgr: Do not bias toward fresh addresses.
This change was suggested as Countermeasure 2 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.

This mimics Bitcoin Core commit
f68ba3f67bd500a64fb8932c6b41924ddc31d76f
2015-04-14 11:21:57 -04:00
David Hill
c80c8e7fe9 Scale up addrman.
This change was suggested as Countermeasure 6 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.

This mimics Bitcoin Core commit 1d21ba2f5ecbf03086d0b65c4c4c80a39a94c2ee
2015-04-06 11:45:57 -04:00
Jimmy Song
f54ffd8c76 Added some unit tests to addrmgr. 2015-03-02 12:28:58 -06:00
Dave Collins
03433dad6a Update btcwire path import paths to new location. 2015-02-05 15:16:39 -06:00
Dave Collins
ee403e2abd Address a few things found by golint. 2015-01-28 09:52:53 -06:00
Dave Collins
f9f4d37976 Update btcd import paths to new location. 2015-01-17 00:48:13 -06:00
Dave Collins
54ccb83025 Update btcwire import paths to new location. 2015-01-16 15:13:21 -06:00
Dave Collins
0e8c3b743d Update btclog import paths to new location. 2015-01-16 11:42:25 -06:00
Dave Collins
d9d7f7ce4d Correct address manager test error print. 2015-01-16 10:14:06 -06:00
David Hill
bc46f8273c Add more reserved IP space to address manager. 2014-12-16 13:02:39 -05:00
Dave Collins
9c0db2f7fd Ensure all tickers are explicitly stopped.
As pointed out in #189, according to the Go documentation, a ticker must
be stopped to release associated resources.  This commit adds a defer call
to stop two tickers there were previously not being stopped as well as
changes two others that were being stopped over to use defer so it's more
consistent.

The other ticker in ScheduleShutdown is replaced and already calls Stop
before replacing it, so it has not been modified.

Closes #189.

ok @jrick
2014-12-03 18:43:31 -06:00
Olaoluwa Osuntokun
b97083f882 Fix some typos throughout repo. 2014-09-08 14:54:52 -05:00
David Hill
8774a77d33 Use Errorf when using formatting directives.
Found by go vet.
2014-08-28 11:49:49 -04:00
David Hill
06d2707744 We only care about the peers.json file... 2014-07-10 19:28:30 -05:00
David Hill
d269887c56 Put mutexes in exported functions. 2014-07-10 19:23:31 -05:00
David Hill
36e8b4c82e organize.
no objections from @davecgh
2014-07-10 19:03:34 -05:00
David Hill
3a45ec1058 Change AddAddressByIP to return an error. 2014-07-09 21:24:06 -04:00
David Hill
6f5a43d6c8 First round of address manager package refactor
These changes are a joint effort between myself and @dajohi.

- Separate IP address range/network code into its own file
- Group all of the RFC range declarations together
- Introduces a new unexported function to simplify the range declarations
- Add comments for all exported functions
- Use consistent variable casing in refactored code
- Add initial doc.go package overview
- Bump serialize interval to 10 minutes
- Correct GroupKey to perform as intended
- Make AddLocalAddress return error instead of just a debug message
- Add tests for AddLocalAddress
- Add tests for GroupKey
- Add tests for GetBestLocalAddress
- Use time.Time to improve readability
- Make address manager code golint clean
- Misc cleanup
- Add test coverage reporting
2014-07-07 09:04:22 -05:00
Dave Collins
62f21d3600 Move address manager to its own package.
This commit does just enough to move the address manager into its own
package.  Since it was not originally written as a package, it will
require a bit of refactoring and cleanup to turn it into a robust
package with a friendly API.
2014-07-06 01:06:38 -05:00