Commit graph

29 commits

Author SHA1 Message Date
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Wladimir J. van der Laan 40b556d374 evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.

- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.

- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral

- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.

- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.

By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.

What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.

Configuration options:

- `-rpcthreads`: repurposed as "number of  work handler threads". Still
defaults to 4.

- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.

- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.

- `-debug=http`: low-level http activity logging
2015-09-03 10:59:18 +02:00
Wladimir J. van der Laan 71cbeaad9a rpc: Implement random-cookie based authentication
When no `-rpcpassword` is specified, use a special 'cookie' file for
authentication. This file is generated with random content when the
daemon starts, and deleted when it exits. Read access to this file
controls who can access through RPC. By default this file is stored in
the data directory but it be overriden with `-rpccookiefile`.

This is similar to Tor CookieAuthentication: see
https://www.torproject.org/docs/tor-manual.html.en

Alternative to #6258. Like that pull, this allows running bitcoind
without any manual configuration. However, daemons should ideally never write to
their configuration files, so I prefer this solution.
2015-07-13 13:11:41 +02:00
Wladimir J. van der Laan b6668209aa build: Remove -DBOOST_SPIRIT_THREADSAFE
Now that boost spirit is no longer used, `-DBOOST_SPIRIT_THREADSAFE`
doesn't need to be passed to the compiler anymore.
2015-06-21 14:09:34 +02:00
Jonas Schnelli 9a8897f4ac Remove JSON Spirit wrapper, remove JSON Spirit leftovers
- implement find_value() function for UniValue
- replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper
- remove JSON Spirit sources
2015-06-04 09:16:21 +02:00
Jonas Schnelli 3df0411ad9 remove JSON Spirit UniValue wrapper 2015-06-04 09:16:06 +02:00
Jonas Schnelli 53b4671a9d extend conversion to UniValue 2015-06-04 09:16:05 +02:00
Jeff Garzik 15982a8b69 Convert tree to using univalue. Eliminate all json_spirit uses. 2015-06-04 09:16:05 +02:00
Cory Fields 856e862f4a namespace: drop most boost namespaces and a few header cleanups
A few boost::asio were left around because they're very wordy otherwise.
2015-01-02 15:12:03 -05:00
Cory Fields a3241998e1 namespace: remove boost namespace pollution 2015-01-02 15:12:03 -05:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford 72fb3d295a Update comments in src/rpc* to be doxygen compatible 2014-11-20 10:19:39 +08:00
Cory Fields 71697f97d3 Separate protocol versioning from clientversion 2014-10-29 00:24:40 -04:00
Philip Kaufmann 611116d4e3 header include cleanup
- ensures alphabetical ordering for includes etc. in source file headers
2014-09-14 12:43:56 +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 6e5fd003e0 Move *Version() functions to version.h/cpp 2014-08-26 13:25:21 +02:00
Wladimir J. van der Laan 733177ebd3 Remove size limit in RPC client, keep it in server
The size limit makes a lot of sense for the server, as it never has to
accept very large data.

The client, however, can request arbitrary amounts of data with
`listtransactions` on a large wallet.

Fixes #4604.
2014-08-06 13:03:58 +02:00
Wladimir J. van der Laan e17151ad2a Avoid a copy in RPC output
Split up HTTPReply into HTTPReply and HTTPReplyHeader, so that
the message data can be streamed directly.

Also removes a c_str(), which would have prevented binary
output with NUL characters in it.
2014-08-06 13:01:49 +02:00
Wladimir J. van der Laan 2ec5a3d212
rpc: Prevent easy memory exhaustion attack
Allocate memory for POST message data only as bytes come in, instead of
all at once at the beginning.

Fixes #4343.
2014-07-04 09:20:39 +02:00
kazcw 16f33f163d fix RPC error replies
After pull #4288, RPC messages indicating errors have a Content-Length unrelated
to their actual contents, rendering bitcoin-cli and curl unable to decode the
reply.

This patch sets the Content-Length field based on the actual content returned.

Additionally, pull #4288 clobbered the error descriptions provided in
ErrorReply, which bitcoin-cli relies upon; this patch moves #4288 http-error
descriptions to an HTTPError method, allowing HTTPReply to pass content on
unchanged.
2014-06-28 19:16:15 -07:00
Jeff Garzik ed5769f536 Move AcceptedConnection class to rpcserver.h.
Also, add parens to HTTPReply() to assist readability.
2014-06-27 00:10:53 -04:00
Jeff Garzik c912e22db0 RPC cleanup: Improve HTTP server replies
1) support varying content types
2) support only sending the header
3) properly deliver error message as content, if HTTP error
4) move AcceptedConnection class to header, for wider use
2014-06-26 23:32:18 -04:00
Wladimir J. van der Laan 3e8ac6af9a
Replace non-threadsafe gmtime and setlocale
Make DateTimeStrFormat use boost::posix_time.

Also re-enable the util_DateTimeStrFormat tests, as they are no
longer platform specific.
2014-05-23 15:23:11 +02:00
Wladimir J. van der Laan 783b182c8f Remove dummy PRIszX macros for formatting
Size specifiers are no longer needed now that we use typesafe tinyformat
for string formatting, instead of the system's sprintf.

No functional changes.

This continues the work in #3735.
2014-05-06 15:29:16 +02:00
Luke Dashjr 3cb1edbfb6 Update moved and dead links 2014-03-24 20:26:02 +00:00
Wladimir J. van der Laan 5283410568 Remove unused includes of boost lexical_cast
We don't use lexical_cast anywhere, no need to include it.
2014-03-07 17:55:13 +01:00
gubatron 57702541a2 Copyright header updates s/2013/2014 on files whose last git commit was done in 2014.
contrib/devtools/fix-copyright-headers.py script to be able to perform this maintenance task with ease during the rest of the year, every year. Modifications to contrib/devtools/README.md to document what fix-copyright-headers.py does.
2014-02-09 21:06:06 -05:00
Wladimir J. van der Laan 7d9d134bf9 Remove redundant .c_str()s
After the tinyformat switch sprintf() family functions support passing
actual std::string objects.

Remove unnecessary c_str calls (236 of them) in logging and formatting.
2014-01-23 16:05:01 +01:00
Wladimir J. van der Laan fb78cc2378 Split up bitcoinrpc (code movement only)
Split bitcoinrpc up into

- rpcserver: bitcoind RPC server
- rpcclient: bitcoin-cli RPC client
- rpcprotocol: shared common HTTP/JSON-RPC protocol code

One step towards making bitcoin-cli independent from the rest
of the code, and thus a smaller executable that doesn't have to
be linked against leveldb.

This commit only does code movement, there are no functional changes.
2013-11-27 06:00:29 +01:00