myMPD
Internal API documentation
Loading...
Searching...
No Matches
proxy.h File Reference

HTTP proxy functions. More...

#include "dist/mongoose/mongoose.h"
#include "dist/sds/sds.h"
#include "src/lib/api.h"
#include <stdbool.h>
Include dependency graph for proxy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  t_backend_nc_data
 

Functions

bool is_allowed_proxy_uri (const char *uri)
 
void send_backend_request (struct mg_connection *nc)
 
void handle_backend_close (struct mg_connection *nc)
 
void free_backend_nc_data (struct t_backend_nc_data *data)
 
struct mg_connection * create_backend_connection (struct mg_connection *nc, struct mg_connection *backend_nc, sds uri, mg_event_handler_t fn, bool stream)
 
void forward_backend_to_frontend_stream (struct mg_connection *nc, int ev, void *ev_data)
 
void forward_backend_to_frontend_covercache (struct mg_connection *nc, int ev, void *ev_data)
 

Detailed Description

HTTP proxy functions.

Function Documentation

◆ create_backend_connection()

struct mg_connection * create_backend_connection ( struct mg_connection *  nc,
struct mg_connection *  backend_nc,
sds  uri,
mg_event_handler_t  fn,
bool  stream 
)

Creates the backend connection

Parameters
ncmongoose frontend connection
backend_ncpointer to use for backend connection
uriuri to connection
fnevent handler function
streamis the backend connection a stream?
Returns
backend connection on success, else NULL

◆ forward_backend_to_frontend_covercache()

void forward_backend_to_frontend_covercache ( struct mg_connection *  nc,
int  ev,
void *  ev_data 
)

Gets images from the backend, caches and forwards the response

Parameters
ncmongoose backend connection
evmongoose event
ev_datamongoose ev_data (not used)

◆ forward_backend_to_frontend_stream()

void forward_backend_to_frontend_stream ( struct mg_connection *  nc,
int  ev,
void *  ev_data 
)

Send the request to the backend and forwards the raw data from backend response to frontend connection

Parameters
ncmongoose backend connection
evmongoose event
ev_datamongoose ev_data (not used)

◆ free_backend_nc_data()

void free_backend_nc_data ( struct t_backend_nc_data data)

Frees the backend data struct

Parameters
databackend data to free

◆ handle_backend_close()

void handle_backend_close ( struct mg_connection *  nc)

Handles the connection close on backend side

Parameters
ncmongoose connection

◆ is_allowed_proxy_uri()

bool is_allowed_proxy_uri ( const char *  uri)

Public functions Checks if uri is in proxy whitelist

Parameters
uriuri to check
Returns
true if allowed, else false

◆ send_backend_request()

void send_backend_request ( struct mg_connection *  nc)

Sends the request to the backend connection

Parameters
ncmongoose backend connection