myMPD
Internal API documentation
|
Webserver implementation. More...
#include "compile_time.h"
#include "src/webserver/webserver.h"
#include "src/lib/api.h"
#include "src/lib/cert.h"
#include "src/lib/filehandler.h"
#include "src/lib/http_client.h"
#include "src/lib/json/json_rpc.h"
#include "src/lib/log.h"
#include "src/lib/mem.h"
#include "src/lib/mg_str_utils.h"
#include "src/lib/msg_queue.h"
#include "src/lib/sds_extras.h"
#include "src/lib/thread.h"
#include "src/webserver/albumart.h"
#include "src/webserver/folderart.h"
#include "src/webserver/placeholder.h"
#include "src/webserver/playlistart.h"
#include "src/webserver/proxy.h"
#include "src/webserver/request_handler.h"
#include "src/webserver/tagart.h"
#include <inttypes.h>
#include <libgen.h>
Functions | |
static void | read_queue (struct mg_mgr *mgr) |
static bool | parse_internal_message (struct t_work_response *response, struct t_mg_user_data *mg_user_data) |
static void | ev_handler (struct mg_connection *nc, int ev, void *ev_data) |
static void | ev_handler_redirect (struct mg_connection *nc_http, int ev, void *ev_data) |
static void | send_ws_notify (struct mg_mgr *mgr, struct t_work_response *response) |
static void | send_ws_notify_client (struct mg_mgr *mgr, struct t_work_response *response) |
static struct mg_connection * | get_nc_by_id (struct mg_mgr *mgr, unsigned long id) |
static void | send_raw_response (struct mg_mgr *mgr, struct t_work_response *response) |
static void | send_redirect (struct mg_mgr *mgr, struct t_work_response *response) |
static void | send_api_response (struct mg_mgr *mgr, struct t_work_response *response) |
static bool | enforce_acl (struct mg_connection *nc, sds acl) |
static bool | enforce_conn_limit (struct mg_connection *nc, int connection_count) |
static void | mongoose_log (char ch, void *param) |
bool | webserver_init (struct mg_mgr *mgr, struct t_config *config, struct t_mg_user_data *mg_user_data) |
bool | webserver_read_certs (struct t_mg_user_data *mg_user_data, struct t_config *config) |
void * | webserver_free (struct mg_mgr *mgr) |
void * | webserver_loop (void *arg_mgr) |
Webserver implementation.
|
static |
Matches the acl against the client ip and sends an error response / drains the connection if acl is not matched
nc | mongoose connection |
acl | acl string to check |
|
static |
Enforces the connection limit
nc | mongoose connection |
connection_count | connection count |
|
static |
Central webserver event handler nc->label usage 0 - connection type: F = frontend connection, B = backend connection 1 - http method: G = GET, H = HEAD, P = POST 2 - connection header: C = close, K = keepalive
nc | mongoose connection |
ev | connection event |
ev_data | event data (http / websocket message) |
|
static |
Redirects the client to https if ssl is enabled. Only requests to /browse/webradios are not redirected.
nc | mongoose connection |
ev | connection event |
ev_data | event data (http / websocket message) |
|
static |
Returns the mongoose connection by id
mgr | mongoose mgr |
id | connection id |
|
static |
Mongoose logging function
ch | character to log |
param |
|
static |
Sets the mg_user_data values from set_mg_user_data_request. Message is sent from the mympd_api thread.
response | Response with the data to set |
mg_user_data | t_mg_user_data to configure |
|
static |
Private definitions
Private functions Reads and processes all messages from the queue
mgr | pointer to mongoose mgr |
|
static |
Sends an api response
mgr | mongoose mgr |
response | jsonrpc response |
|
static |
Sends a raw http response message
mgr | mongoose mgr |
response | jsonrpc response |
|
static |
Sends a redirect http response message
mgr | mongoose mgr |
response | jsonrpc response |
|
static |
Broadcasts a message through all websocket connections for a specific or all partitions
mgr | mongoose mgr |
response | jsonrpc notification |
|
static |
Sends a message through the websocket to a specific client We use the jsonprc id to identify the websocket connection
mgr | mongoose mgr |
response | jsonrpc notification |
void * webserver_free | ( | struct mg_mgr * | mgr | ) |
Frees the mongoose mgr
mgr | mongoose mgr to free |
bool webserver_init | ( | struct mg_mgr * | mgr, |
struct t_config * | config, | ||
struct t_mg_user_data * | mg_user_data | ||
) |
Public functions Initializes the webserver
mgr | mongoose mgr |
config | pointer to myMPD config |
mg_user_data | already allocated t_mg_user_data to populate |
void * webserver_loop | ( | void * | arg_mgr | ) |
Main function for the webserver thread
arg_mgr | void pointer to mongoose mgr |
bool webserver_read_certs | ( | struct t_mg_user_data * | mg_user_data, |
struct t_config * | config | ||
) |
Reads the ssl key and certificate from disc
mg_user_data | pointer to mongoose user data |
config | pointer to myMPD config |