Bitcoin
|
#include <httpserver.h>
#include <chainparamsbase.h>
#include <compat.h>
#include <util/threadnames.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <netbase.h>
#include <rpc/protocol.h>
#include <shutdown.h>
#include <sync.h>
#include <ui_interface.h>
#include <memory>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <event2/thread.h>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <event2/util.h>
#include <event2/keyvalq_struct.h>
#include <support/events.h>
Classes | |
class | HTTPWorkItem |
class | WorkQueue< WorkItem > |
struct | HTTPPathHandler |
Macros | |
#define | EVENT_LOG_WARN _EVENT_LOG_WARN |
Functions | |
static bool | ClientAllowed (const CNetAddr &netaddr) |
static bool | InitHTTPAllowList () |
static std::string | RequestMethodString (HTTPRequest::RequestMethod m) |
static void | http_request_cb (struct evhttp_request *req, void *arg) |
static void | http_reject_request_cb (struct evhttp_request *req, void *) |
static bool | ThreadHTTP (struct event_base *base) |
static bool | HTTPBindAddresses (struct evhttp *http) |
static void | HTTPWorkQueueRun (WorkQueue< HTTPClosure > *queue, int worker_num) |
static void | libevent_log_cb (int severity, const char *msg) |
bool | InitHTTPServer () |
bool | UpdateHTTPServerLogging (bool enable) |
void | StartHTTPServer () |
void | InterruptHTTPServer () |
void | StopHTTPServer () |
struct event_base * | EventBase () |
static void | httpevent_callback_fn (evutil_socket_t, short, void *data) |
void | RegisterHTTPHandler (const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler) |
void | UnregisterHTTPHandler (const std::string &prefix, bool exactMatch) |
Variables | |
static const size_t | MAX_HEADERS_SIZE = 8192 |
static struct event_base * | eventBase = nullptr |
libevent event loop More... | |
static struct evhttp * | eventHTTP = nullptr |
HTTP server. More... | |
static std::vector< CSubNet > | rpc_allow_subnets |
List of subnets to allow RPC connections from. More... | |
static WorkQueue< HTTPClosure > * | workQueue = nullptr |
Work queue for handling longer requests off the event loop thread. More... | |
static std::vector< HTTPPathHandler > | pathHandlers |
Handlers for (sub)paths. More... | |
static std::vector< evhttp_bound_socket * > | boundSockets |
Bound listening sockets. More... | |
static std::thread | threadHTTP |
static std::vector< std::thread > | g_thread_http_workers |
#define EVENT_LOG_WARN _EVENT_LOG_WARN |
|
static |
Check if a network address is allowed to access the HTTP server
struct event_base* EventBase | ( | ) |
Return evhttp event base. This can be used by submodules to queue timers or custom events.
|
static |
Callback to reject HTTP requests after shutdown.
|
static |
HTTP request callback
|
static |
Bind HTTP server to specified addresses
|
static |
|
static |
Simple wrapper to set thread name and run work queue
|
static |
Initialize ACL list for HTTP server
bool InitHTTPServer | ( | ) |
Initialize HTTP server. Call this before RegisterHTTPHandler or EventBase().
void InterruptHTTPServer | ( | ) |
Interrupt HTTP server threads
|
static |
libevent event log callback
void RegisterHTTPHandler | ( | const std::string & | prefix, |
bool | exactMatch, | ||
const HTTPRequestHandler & | handler | ||
) |
Register handler for prefix. If multiple handlers match a prefix, the first-registered one will be invoked.
|
static |
HTTP request method as string - use for logging only
void StartHTTPServer | ( | ) |
Start HTTP server. This is separate from InitHTTPServer to give users race-condition-free time to register their handlers between InitHTTPServer and StartHTTPServer.
void StopHTTPServer | ( | ) |
Stop HTTP server
|
static |
Event dispatcher thread
void UnregisterHTTPHandler | ( | const std::string & | prefix, |
bool | exactMatch | ||
) |
Unregister handler for prefix
bool UpdateHTTPServerLogging | ( | bool | enable | ) |
Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if libevent doesn't support debug logging.
|
static |
Bound listening sockets.
|
static |
libevent event loop
HTTP module state
|
static |
HTTP server.
|
static |
|
static |
Maximum size of http request (request line + headers)
|
static |
Handlers for (sub)paths.
|
static |
List of subnets to allow RPC connections from.
|
static |
|
static |
Work queue for handling longer requests off the event loop thread.