Commit Graph

10442 Commits

Author SHA1 Message Date
unsystemizer
5aa2365edd Clarify listenonion
> This new feature is enabled by default if Bitcoin Core is listening, and a connection to Tor can be made. It can be configured with the -listenonion, -torcontrol and -torpassword settings. To show verbose debugging information, pass -debug=tor.

But it is correct to say that the feature is enabled *regardless* of whether a connection to Tor can be made.

I propose to clarify that so that users can eliminate these in their logs (when `listen=1` and no Tor).
And I think it's okay to clarify about the `listen` option, because on several occasions when I read this before I always assumed `listening` meant `server=1` which cost me a lot of time in troubleshooting.

```
2016-10-24 06:19:22.551029 tor: Error connecting to Tor control socket
2016-10-24 06:19:22.551700 tor: Not connected to Tor control port 127.0.0.1:9051, trying to reconnect
```

0.12.1
2017-03-25 20:25:53 +13:00
Nathaniel Mahieu
4404073185 Clarify documentation for running a tor node
Previous wording suggested that no additional setup was required for a
tor hidden service to be created.
2017-03-25 20:25:52 +13:00
Wladimir J. van der Laan
ca5e229514 tor: Change auth order to only use HASHEDPASSWORD if -torpassword
Change authentication order to make it more clear (see #7700).

- If the `-torpassword` option is provided, force use of
  `HASHEDPASSWORD` auth.

- Give error message if `-torpassword` provided, but
  `HASHEDPASSWORD` auth is not available.

- Give error message if only `HASHEDPASSWORD` available, but
  `-torpassword` not given.
2017-03-25 20:25:50 +13:00
Adam Brown
ec8828aff3 [doc] Update port in tor.md
Tor Browser Bundle spawns the Tor process and listens on port 9150, it doesn't randomly pick a port.

[ci skip]
(cherry picked from commit 1b63cf98347b2a62915425576930f55c2126c2ff)
2017-03-25 20:25:49 +13:00
Jonas Schnelli
1a41e3f660 Fix torcontrol.cpp unused private field warning 2017-03-25 20:25:48 +13:00
Wladimir J. van der Laan
3d7cddcaa2 Fix memleak in TorController [rework]
It looks like, TorController::disconnected_cb(TorControlConnection&
conn) gets called multiple times which results in multiple event_new().

Avoid this by creating the event only once in the constructore, and
deleting it only once in the destructor (thanks to Cory Fields for the
idea).

Replaces the fix by Jonas Schnelli in #7610, see discussion there.
2017-03-25 20:25:46 +13: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
Gregory Maxwell
f28a87b4ba 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.
2017-03-25 20:25:44 +13:00
Gregory Maxwell
35db253fb6 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.
2017-03-25 20:25:42 +13:00
calebogden
e10e212470 Fixing typos on security-check.py and torcontrol.cpp 2017-03-25 20:25:41 +13:00
MarcoFalke
9b46a35b8d torcontrol debug: Change to a blanket message that covers both cases 2017-03-25 20:25:39 +13:00
Wladimir J. van der Laan
f3e1770cfb tests: Disable Tor interaction
This is unnecessary during the current tests (any test for Tor
interaction can explicitly enable it) and interferes with the proxy
test.
2017-03-25 20:25:38 +13:00
Daniel Cousens
65fd8eb134 torcontrol: only output disconnect if -debug=tor 2017-03-25 20:25:35 +13:00
Peter Todd
2b30758b2f Connect to Tor hidden services by default
Adds 127.0.0.1:9050 for the .onion proxy if we can succesfully connect
to the control port.

Natural followup to creating hidden services automatically.
2017-03-25 20:24:58 +13:00
MarcoFalke
7f9e7a9872 [doc] [tor] Clarify when to use bind
c.f. #6585
2017-03-25 20:24:56 +13:00
Wladimir J. van der Laan
2298877f78 doc: update docs for Tor listening
- add new data directory files for 0.12 to doc/files.md
- mention torcontrol in doc/tor.md
2017-03-25 20:22:13 +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
Peter Todd
77e5601e9e Better error message if Tor version too old 2017-03-25 20:22:11 +13:00
Wladimir J. van der Laan
eb5f63fe58 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.
2017-03-25 20:22:09 +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
f9f48667be Auto merge of #2176 - str4d:1593-libevent, r=bitcartel
libevent-based http server

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#5677
- bitcoin/bitcoin#6695
- bitcoin/bitcoin#6899
- bitcoin/bitcoin#7016
- bitcoin/bitcoin#7964
- bitcoin/bitcoin#8722
- bitcoin/bitcoin#8730
- bitcoin/bitcoin#9073
- bitcoin/bitcoin#9265
- bitcoin/bitcoin#9387
- bitcoin/bitcoin#9471
- bitcoin/bitcoin#9647
- bitcoin/bitcoin#9903
- bitcoin/bitcoin#6640
- bitcoin/bitcoin#8139
- bitcoin/bitcoin#8839

Closes #1593 and #1856.
2017-03-25 04:52:16 +00:00
Jack Grigg
3da13e885e Fix typo 2017-03-25 17:40:27 +13:00
Jack Grigg
206e2b9737 Wrap error string 2017-03-25 17:39:56 +13:00
Jack Grigg
47855b599d Revert "Revert "rpc-tests: re-enable rpc-tests for Windows""
This reverts commit 7fd5d4e30e.

We need to un-revert this before pulling in
https://github.com/bitcoin/bitcoin/pull/6616
2017-03-25 17:37:18 +13:00
zkbot
2bdb37276e Auto merge of #2198 - str4d:2139-timer, r=str4d
Improve mining metrics

Closes #2139.
2017-03-25 00:08:47 +00:00
Jack Grigg
601f00f6fb Add AtomicTimer tests 2017-03-25 13:06:00 +13:00
Jack Grigg
5c0d105b6b Update LocalSolPS test 2017-03-25 12:57:22 +13:00
Wladimir J. van der Laan
e93a3e1945 test: Avoid ConnectionResetErrors during RPC tests
This is necessary on FreeBSD and MacOSX, at least.

See https://github.com/bitcoin/bitcoin/pull/8834#issuecomment-250450213
2017-03-24 18:43:40 +13:00
Pieter Wuille
2edad86b2d Fix interrupted HTTP RPC connection workaround for Python 3.5+ 2017-03-24 18:43:21 +13:00
paveljanik
17694e4bcf [TRIVIAL] Fix typo: exactmath -> exactmatch
... but not yet in trivial tree
2017-03-24 18:42:45 +13:00
zkbot
6344719817 Auto merge of #2052 - str4d:2032-z_importkey-partial-rescan, r=bitcartel
Usability improvements for z_importkey

- Add height parameter to z_importkey to reduce rescan range
- Change semantics of rescan parameter, so users can explicitly force a rescan
  for existing keys.

Closes #2032
2017-03-24 03:47:11 +00:00
Jack Grigg
33589401ba Require that z_importkey height parameter be in valid range 2017-03-24 16:07:53 +13:00
zkbot
23f792c2f5 Auto merge of #2187 - bitcartel:1.0.7_getblock_by_height, r=bitcartel
Closes #2186. RPC getblock now accepts height or hash.
2017-03-24 02:55:27 +00:00
Simon
7d3b152897 Closes #2186. RPC getblock now accepts height or hash. 2017-03-23 19:25:04 -07:00
Jack Grigg
53c96bfa6c Test boolean fallback in z_importkey 2017-03-24 09:23:11 +13:00
Jack Grigg
a163953929 [depends] libevent 2.1.8 2017-03-24 09:03:59 +13:00
Ian Kelling
629a875229 Docs: add details to -rpcclienttimeout doc 2017-03-24 09:03:59 +13:00
Luke Dashjr
c65969a5a6 Skip RAII event tests if libevent is built without event_set_mem_functions 2017-03-24 09:03:59 +13:00
fanquake
ec626cc530 [depends] libevent 2.1.7rc 2017-03-24 09:03:59 +13:00
Karl-Johan Alm
ca50af75b1 Added EVENT_CFLAGS to test makefile to explicitly include libevent headers. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm
e8b6d84b9f Added some simple tests for the RAII-style events. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm
68377e18a8 Switched bitcoin-cli.cpp to use RAII unique pointers with deleters. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm
17fb609097 Added std::unique_ptr<> wrappers with deleters for libevent modules. 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan
7c2ab05969 bitcoin-cli: Make error message less confusing
Sorry for the churn on this, but the current message (introduced in #9073)
isn't acceptable:

    $ src/bitcoin-cli getinfo
    rpc: couldn't connect to server
    (make sure server is running and you are connecting to the correct RPC port: -1 unknown)

Putting the error code after the words "RPC port" made me wonder whether
there was a port configuration issue.

This changes it to:

    $ src/bitcoin-cli getinfo
    error: couldn't connect to server: unknown (code -1)
    (make sure server is running and you are connecting to the correct RPC port)
2017-03-24 09:03:59 +13:00
instagibbs
603205e381 Add common failure cases for rpc server connection failure 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan
32f4e7744c depends: Add libevent compatibility patch for windows
Add a patch that seems to be necessary for compatibilty of libevent
2.0.22 with recent mingw-w64 gcc versions (at least GCC 5.3.1 from Ubuntu
16.04).

Without this patch the Content-Length in the HTTP header ends up as
`Content-Length: zu`, causing communication between the RPC
client and server to break down. See discussion in #8653.

Source: https://sourceforge.net/p/levent/bugs/363/

Thanks to @sstone for the suggestion.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan
6415573a59 bitcoin-cli: More detailed error reporting
Register a evhttp error handler to get a more detailed error message
if the HTTP request fails.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan
08c581940a auto_ptr → unique_ptr
Change the few occurrences of the deprecated `auto_ptr` to c++11 `unique_ptr`.
Silences the deprecation warnings.

Also add a missing `std::` for consistency.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan
0e2b1ae259 chain: define enum used as bit field as uint32_t
Bitwise logic combined with `<` with undefined signedness will
potentially results in undefined behavior. Fix this by defining the type
as a c++11 typed enum.

Fixes #6017.
2017-03-24 09:03:59 +13:00
Gregory Maxwell
599d2c4034 Avoid a compile error on hosts with libevent too old for EVENT_LOG_WARN.
This uses _EVENT_LOG_WARN instead, which appears to be defined in the
 old versions of libevent that I have on some systems.
2017-03-24 09:03:59 +13:00