Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
proxy_util.c File Reference
#include "mod_proxy.h"
#include "ap_mpm.h"
#include "scoreboard.h"
#include "apr_version.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_atomic.h"
#include "http_core.h"
#include "proxy_util.h"
#include "ajp.h"
#include "scgi.h"
#include "mpm_common.h"
#include "mod_http2.h"
#include "apr_support.h"

Go to the source code of this file.

Classes

struct  forward_info
 
struct  proxy_address
 
struct  header_connection
 
struct  proxy_schemes_t
 
struct  proxy_tunnel_conn
 

Macros

#define MAX_IP_STR_LEN   (46)
 
#define PROXY_UNSET_NONCE   '\n'
 
#define IS_REF(x)   (x[0] == '$' && apr_isdigit(x[1]))
 
#define USE_ALTERNATE_IS_CONNECTED   1
 
#define PROXY_TRANSFER_MAX_READS   10000
 

Typedefs

typedef struct proxy_address proxy_address
 
typedef struct header_connection header_connection
 
typedef struct proxy_schemes_t proxy_schemes_t
 

Functions

static int proxy_match_ipaddr (struct dirconn_entry *This, request_rec *r)
 
static int proxy_match_domainname (struct dirconn_entry *This, request_rec *r)
 
static int proxy_match_hostname (struct dirconn_entry *This, request_rec *r)
 
static int proxy_match_word (struct dirconn_entry *This, request_rec *r)
 
static int ap_proxy_retry_worker (const char *proxy_function, proxy_worker *worker, server_rec *s)
 
static proxy_workerproxy_balancer_get_best_worker (proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton)
 
int proxy_run_create_req (request_rec *r, request_rec *pr)
 
apr_status_t ap_proxy_strncpy (char *dst, const char *src, apr_size_t dlen)
 
int ap_proxy_hex2c (const char *x)
 
void ap_proxy_c2hex (int ch, char *x)
 
charap_proxy_canonenc_ex (apr_pool_t *p, const char *x, int len, enum enctype t, int flags, int proxyreq)
 
charap_proxy_canonenc (apr_pool_t *p, const char *x, int len, enum enctype t, int forcedec, int proxyreq)
 
charap_proxy_canon_netloc (apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, apr_port_t *port)
 
static int proxyerror_core (request_rec *r, int statuscode, const char *message, apr_status_t rv)
 
int ap_proxyerror (request_rec *r, int statuscode, const char *message)
 
static const charproxy_get_host_of_request (request_rec *r)
 
int ap_proxy_is_ipaddr (struct dirconn_entry *This, apr_pool_t *p)
 
int ap_proxy_is_domainname (struct dirconn_entry *This, apr_pool_t *p)
 
int ap_proxy_is_hostname (struct dirconn_entry *This, apr_pool_t *p)
 
int ap_proxy_is_word (struct dirconn_entry *This, apr_pool_t *p)
 
int ap_proxy_checkproxyblock (request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr)
 
int ap_proxy_checkproxyblock2 (request_rec *r, proxy_server_conf *conf, const char *hostname, apr_sockaddr_t *addr)
 
int ap_proxy_pre_http_request (conn_rec *c, request_rec *r)
 
const charap_proxy_location_reverse_map (request_rec *r, proxy_dir_conf *conf, const char *url)
 
const charap_proxy_cookie_reverse_map (request_rec *r, proxy_dir_conf *conf, const char *str)
 
int ap_proxy_valid_balancer_name (char *name, int i)
 
proxy_balancerap_proxy_get_balancer (apr_pool_t *p, proxy_server_conf *conf, const char *url, int care)
 
charap_proxy_update_balancer (apr_pool_t *p, proxy_balancer *balancer, const char *url)
 
charap_proxy_define_balancer (apr_pool_t *p, proxy_balancer **balancer, proxy_server_conf *conf, const char *url, const char *alias, int do_malloc)
 
apr_status_t ap_proxy_share_balancer (proxy_balancer *balancer, proxy_balancer_shared *shm, int i)
 
apr_status_t ap_proxy_initialize_balancer (proxy_balancer *balancer, server_rec *s, apr_pool_t *p)
 
proxy_workerap_proxy_balancer_get_best_worker (proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton)
 
static void socket_cleanup (proxy_conn_rec *conn)
 
static void conn_cleanup (proxy_conn_rec *conn)
 
static apr_status_t conn_pool_cleanup (void *theworker)
 
static apr_pool_tmake_conn_subpool (apr_pool_t *p, const char *tag, server_rec *s)
 
static void init_conn_pool (apr_pool_t *p, proxy_worker *worker, server_rec *s)
 
int ap_proxy_connection_reusable (proxy_conn_rec *conn)
 
static proxy_conn_recconnection_make (apr_pool_t *p, proxy_worker *worker)
 
static void connection_cleanup (void *theconn)
 
apr_status_t ap_proxy_ssl_connection_cleanup (proxy_conn_rec *conn, request_rec *r)
 
static apr_status_t connection_constructor (void **resource, void *params, apr_pool_t *pool)
 
static apr_status_t connection_destructor (void *resource, void *params, apr_pool_t *pool)
 
charap_proxy_worker_name (apr_pool_t *p, proxy_worker *worker)
 
int ap_proxy_worker_can_upgrade (apr_pool_t *p, const proxy_worker *worker, const char *upgrade, const char *dflt)
 
static int ap_proxy_strcmp_ematch (const char *str, const char *expected)
 
proxy_workerap_proxy_get_worker_ex (apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask)
 
proxy_workerap_proxy_get_worker (apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url)
 
charap_proxy_define_worker_ex (apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask)
 
charap_proxy_define_worker (apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc)
 
charap_proxy_define_match_worker (apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc)
 
apr_status_t ap_proxy_share_worker (proxy_worker *worker, proxy_worker_shared *shm, int i)
 
apr_status_t ap_proxy_initialize_worker (proxy_worker *worker, server_rec *s, apr_pool_t *p)
 
static int fixup_uds_filename (request_rec *r)
 
int ap_proxy_fixup_uds_filename (request_rec *r)
 
const charap_proxy_interpolate (request_rec *r, const char *str)
 
static apr_array_header_tproxy_vars (request_rec *r, apr_array_header_t *hdr)
 
int ap_proxy_canon_url (request_rec *r)
 
int ap_proxy_pre_request (proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url)
 
int ap_proxy_post_request (proxy_worker *worker, proxy_balancer *balancer, request_rec *r, proxy_server_conf *conf)
 
int ap_proxy_connect_to_backend (apr_socket_t **newsock, const char *proxy_function, apr_sockaddr_t *backend_addr, const char *backend_name, proxy_server_conf *conf, request_rec *r)
 
int ap_proxy_acquire_connection (const char *proxy_function, proxy_conn_rec **conn, proxy_worker *worker, server_rec *s)
 
int ap_proxy_release_connection (const char *proxy_function, proxy_conn_rec *conn, server_rec *s)
 
static APR_INLINE void proxy_address_inc (proxy_address *address)
 
static APR_INLINE void proxy_address_dec (proxy_address *address)
 
static apr_status_t proxy_address_cleanup (void *address)
 
static APR_INLINE proxy_addressworker_address_get (proxy_worker *worker)
 
static APR_INLINE void worker_address_set (proxy_worker *worker, proxy_address *to)
 
static apr_status_t worker_address_resolve (proxy_worker *worker, apr_sockaddr_t **paddr, const char *hostname, apr_port_t hostport, const char *proxy_function, request_rec *r, server_rec *s)
 
static int proxy_addrs_equal (const apr_sockaddr_t *addr1, const apr_sockaddr_t *addr2)
 
apr_status_t ap_proxy_determine_address (const char *proxy_function, proxy_conn_rec *conn, const char *hostname, apr_port_t hostport, unsigned int flags, request_rec *r, server_rec *s)
 
int ap_proxy_determine_connection (apr_pool_t *p, request_rec *r, proxy_server_conf *conf, proxy_worker *worker, proxy_conn_rec *conn, apr_uri_t *uri, char **url, const char *proxyname, apr_port_t proxyport, char *server_portstr, int server_portstr_size)
 
int ap_proxy_is_socket_connected (apr_socket_t *sock)
 
static apr_status_t send_http_connect (proxy_conn_rec *backend, server_rec *s)
 
apr_status_t ap_proxy_connect_uds (apr_socket_t *sock, const char *uds_path, apr_pool_t *p)
 
apr_status_t ap_proxy_check_connection (const char *scheme, proxy_conn_rec *conn, server_rec *server, unsigned max_blank_lines, int flags)
 
int ap_proxy_connect_backend (const char *proxy_function, proxy_conn_rec *conn, proxy_worker *worker, server_rec *s)
 
static apr_status_t connection_shutdown (void *theconn)
 
static int proxy_connection_create (const char *proxy_function, proxy_conn_rec *conn, request_rec *r, server_rec *s)
 
int ap_proxy_connection_create_ex (const char *proxy_function, proxy_conn_rec *conn, request_rec *r)
 
int ap_proxy_connection_create (const char *proxy_function, proxy_conn_rec *conn, conn_rec *c, server_rec *s)
 
int ap_proxy_lb_workers (void)
 
static APR_INLINE int error_code_overridden (const int *elts, int nelts, int code)
 
int ap_proxy_should_override (proxy_dir_conf *conf, int code)
 
void ap_proxy_backend_broke (request_rec *r, apr_bucket_brigade *brigade)
 
unsigned int ap_proxy_hashfunc (const char *str, proxy_hash_t method)
 
apr_status_t ap_proxy_set_wstatus (char c, int set, proxy_worker *w)
 
charap_proxy_parse_wstatus (apr_pool_t *p, proxy_worker *w)
 
apr_status_t ap_proxy_sync_balancer (proxy_balancer *b, server_rec *s, proxy_server_conf *conf)
 
proxy_worker_sharedap_proxy_find_workershm (ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_worker *worker, unsigned int *index)
 
proxy_balancer_sharedap_proxy_find_balancershm (ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_balancer *balancer, unsigned int *index)
 
static int find_conn_headers (void *data, const char *key, const char *val)
 
static int ap_proxy_clear_connection (request_rec *r, apr_table_t *headers)
 
int ap_proxy_create_hdrbrgd (apr_pool_t *p, apr_bucket_brigade *header_brigade, request_rec *r, proxy_conn_rec *p_conn, proxy_worker *worker, proxy_server_conf *conf, apr_uri_t *uri, char *url, char *server_portstr, char **old_cl_val, char **old_te_val)
 
int ap_proxy_prefetch_input (request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_read_type_e block, apr_off_t *bytes_read, apr_off_t max_read)
 
int ap_proxy_read_input (request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *bb, apr_off_t max_read)
 
int ap_proxy_spool_input (request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_off_t *bytes_spooled, apr_off_t max_mem_spool)
 
int ap_proxy_pass_brigade (apr_bucket_alloc_t *bucket_alloc, request_rec *r, proxy_conn_rec *p_conn, conn_rec *origin, apr_bucket_brigade *bb, int flush)
 
apr_port_t ap_proxy_port_of_scheme (const char *scheme)
 
static APR_INLINE int ap_filter_should_yield (ap_filter_t *f)
 
static APR_INLINE int ap_filter_output_pending (conn_rec *c)
 
apr_status_t ap_proxy_buckets_lifetime_transform (request_rec *r, apr_bucket_brigade *from, apr_bucket_brigade *to)
 
apr_status_t ap_proxy_transfer_between_connections (request_rec *r, conn_rec *c_i, conn_rec *c_o, apr_bucket_brigade *bb_i, apr_bucket_brigade *bb_o, const char *name, int *sent, apr_off_t bsize, int flags)
 
apr_status_t ap_proxy_tunnel_create (proxy_tunnel_rec **ptunnel, request_rec *r, conn_rec *c_o, const char *scheme)
 
static void add_pollset (apr_pollset_t *pollset, apr_pollfd_t *pfd, apr_int16_t events)
 
static void del_pollset (apr_pollset_t *pollset, apr_pollfd_t *pfd, apr_int16_t events)
 
static int proxy_tunnel_forward (proxy_tunnel_rec *tunnel, struct proxy_tunnel_conn *in)
 
int ap_proxy_tunnel_run (proxy_tunnel_rec *tunnel)
 
const charap_proxy_show_hcmethod (hcmethod_t method)
 
void proxy_util_register_hooks (apr_pool_t *p)
 

Variables

static int *const aplog_module_index = &( proxy_module.module_index)
 
int proxy_lb_workers = 0
 
static int lb_workers_limit = 0
 
const apr_strmatch_patternap_proxy_strmatch_path
 
const apr_strmatch_patternap_proxy_strmatch_domain
 
apr_global_mutex_tproxy_mutex
 
static const apr_time_tproxy_start_time
 
static proxy_schemes_t pschemes []
 

Macro Definition Documentation

◆ IS_REF

#define IS_REF (   x)    (x[0] == '$' && apr_isdigit(x[1]))

◆ MAX_IP_STR_LEN

#define MAX_IP_STR_LEN   (46)

Definition at line 822 of file proxy_util.c.

◆ PROXY_TRANSFER_MAX_READS

#define PROXY_TRANSFER_MAX_READS   10000

Definition at line 5203 of file proxy_util.c.

◆ PROXY_UNSET_NONCE

#define PROXY_UNSET_NONCE   '\n'

Definition at line 1190 of file proxy_util.c.

◆ USE_ALTERNATE_IS_CONNECTED

#define USE_ALTERNATE_IS_CONNECTED   1

Definition at line 3456 of file proxy_util.c.

Typedef Documentation

◆ header_connection

◆ proxy_address

◆ proxy_schemes_t

Function Documentation

◆ add_pollset()

static void add_pollset ( apr_pollset_t pollset,
apr_pollfd_t pfd,
apr_int16_t  events 
)
static

< Can read without blocking

< Hangup occurred

< Pending error

Definition at line 5490 of file proxy_util.c.

◆ ap_filter_output_pending()

static APR_INLINE int ap_filter_output_pending ( conn_rec c)
static

< Module has handled this stage.

< Module declines to handle

Definition at line 5145 of file proxy_util.c.

◆ ap_filter_should_yield()

static APR_INLINE int ap_filter_should_yield ( ap_filter_t f)
static

Definition at line 5140 of file proxy_util.c.

◆ ap_proxy_canon_url()

int ap_proxy_canon_url ( request_rec r)

< Module declines to handle

< Reverse proxy

< Reverse proxy

< Module has handled this stage.

Definition at line 2547 of file proxy_util.c.

◆ ap_proxy_clear_connection()

static int ap_proxy_clear_connection ( request_rec r,
apr_table_t headers 
)
static

Remove all headers referred to by the Connection header.

Definition at line 4495 of file proxy_util.c.

◆ ap_proxy_interpolate()

const char * ap_proxy_interpolate ( request_rec r,
const char str 
)

Definition at line 2492 of file proxy_util.c.

◆ ap_proxy_is_domainname()

int ap_proxy_is_domainname ( struct dirconn_entry This,
apr_pool_t p 
)

Definition at line 675 of file proxy_util.c.

◆ ap_proxy_is_hostname()

int ap_proxy_is_hostname ( struct dirconn_entry This,
apr_pool_t p 
)

Definition at line 736 of file proxy_util.c.

◆ ap_proxy_is_ipaddr()

int ap_proxy_is_ipaddr ( struct dirconn_entry This,
apr_pool_t p 
)

Definition at line 466 of file proxy_util.c.

◆ ap_proxy_is_word()

int ap_proxy_is_word ( struct dirconn_entry This,
apr_pool_t p 
)

Definition at line 802 of file proxy_util.c.

◆ ap_proxy_retry_worker()

static int ap_proxy_retry_worker ( const char proxy_function,
proxy_worker worker,
server_rec s 
)
static

< Module declines to handle

< Module has handled this stage.

< Module declines to handle

< Module has handled this stage.

Definition at line 2391 of file proxy_util.c.

◆ ap_proxy_strcmp_ematch()

static int ap_proxy_strcmp_ematch ( const char str,
const char expected 
)
static

Definition at line 1797 of file proxy_util.c.

◆ conn_cleanup()

static void conn_cleanup ( proxy_conn_rec conn)
static

Definition at line 1513 of file proxy_util.c.

◆ conn_pool_cleanup()

static apr_status_t conn_pool_cleanup ( void *  theworker)
static

Definition at line 1526 of file proxy_util.c.

◆ connection_cleanup()

static void connection_cleanup ( void *  theconn)
static

Definition at line 1637 of file proxy_util.c.

◆ connection_constructor()

static apr_status_t connection_constructor ( void **  resource,
void *  params,
apr_pool_t pool 
)
static

Definition at line 1722 of file proxy_util.c.

◆ connection_destructor()

static apr_status_t connection_destructor ( void *  resource,
void *  params,
apr_pool_t pool 
)
static

Definition at line 1744 of file proxy_util.c.

◆ connection_make()

static proxy_conn_rec * connection_make ( apr_pool_t p,
proxy_worker worker 
)
static

Definition at line 1612 of file proxy_util.c.

◆ connection_shutdown()

static apr_status_t connection_shutdown ( void *  theconn)
static

Definition at line 4048 of file proxy_util.c.

◆ del_pollset()

static void del_pollset ( apr_pollset_t pollset,
apr_pollfd_t pfd,
apr_int16_t  events 
)
static

< Can read without blocking

< Hangup occurred

< Pending error

Definition at line 5514 of file proxy_util.c.

◆ error_code_overridden()

static APR_INLINE int error_code_overridden ( const int elts,
int  nelts,
int  code 
)
static

Definition at line 4200 of file proxy_util.c.

◆ find_conn_headers()

static int find_conn_headers ( void *  data,
const char key,
const char val 
)
static

Definition at line 4463 of file proxy_util.c.

◆ fixup_uds_filename()

static int fixup_uds_filename ( request_rec r)
static

< Module has handled this stage.

< Module declines to handle

Definition at line 2430 of file proxy_util.c.

◆ init_conn_pool()

static void init_conn_pool ( apr_pool_t p,
proxy_worker worker,
server_rec s 
)
static

Definition at line 1564 of file proxy_util.c.

◆ make_conn_subpool()

static apr_pool_t * make_conn_subpool ( apr_pool_t p,
const char tag,
server_rec s 
)
static

Definition at line 1532 of file proxy_util.c.

◆ proxy_address_cleanup()

static apr_status_t proxy_address_cleanup ( void *  address)
static

Definition at line 2838 of file proxy_util.c.

◆ proxy_address_dec()

static APR_INLINE void proxy_address_dec ( proxy_address address)
static

Definition at line 2828 of file proxy_util.c.

◆ proxy_address_inc()

static APR_INLINE void proxy_address_inc ( proxy_address address)
static

Definition at line 2822 of file proxy_util.c.

◆ proxy_addrs_equal()

static int proxy_addrs_equal ( const apr_sockaddr_t addr1,
const apr_sockaddr_t addr2 
)
static

Definition at line 2919 of file proxy_util.c.

◆ proxy_balancer_get_best_worker()

static proxy_worker * proxy_balancer_get_best_worker ( proxy_balancer balancer,
request_rec r,
proxy_is_best_callback_fn_t is_best,
void *  baton 
)
static

Definition at line 1375 of file proxy_util.c.

◆ proxy_connection_create()

static int proxy_connection_create ( const char proxy_function,
proxy_conn_rec conn,
request_rec r,
server_rec s 
)
static

< Module has handled this stage.

< Module has handled this stage.

< Module has served the response completely * - it's safe to die() with no more output

< Module has handled this stage.

Definition at line 4075 of file proxy_util.c.

◆ proxy_get_host_of_request()

static const char * proxy_get_host_of_request ( request_rec r)
static

Definition at line 438 of file proxy_util.c.

◆ proxy_match_domainname()

static int proxy_match_domainname ( struct dirconn_entry This,
request_rec r 
)
static

Definition at line 712 of file proxy_util.c.

◆ proxy_match_hostname()

static int proxy_match_hostname ( struct dirconn_entry This,
request_rec r 
)
static

Definition at line 765 of file proxy_util.c.

◆ proxy_match_ipaddr()

static int proxy_match_ipaddr ( struct dirconn_entry This,
request_rec r 
)
static

Definition at line 587 of file proxy_util.c.

◆ proxy_match_word()

static int proxy_match_word ( struct dirconn_entry This,
request_rec r 
)
static

Definition at line 809 of file proxy_util.c.

◆ proxy_tunnel_forward()

static int proxy_tunnel_forward ( proxy_tunnel_rec tunnel,
struct proxy_tunnel_conn in 
)
static

< Module has served the response completely * - it's safe to die() with no more output

< Can read without blocking

< Can write without blocking

< Module has handled this stage.

Definition at line 5543 of file proxy_util.c.

◆ proxy_vars()

static apr_array_header_t * proxy_vars ( request_rec r,
apr_array_header_t hdr 
)
static

Definition at line 2530 of file proxy_util.c.

◆ proxyerror_core()

static int proxyerror_core ( request_rec r,
int  statuscode,
const char message,
apr_status_t  rv 
)
static

Definition at line 412 of file proxy_util.c.

◆ send_http_connect()

static apr_status_t send_http_connect ( proxy_conn_rec backend,
server_rec s 
)
static

Definition at line 3532 of file proxy_util.c.

◆ socket_cleanup()

static void socket_cleanup ( proxy_conn_rec conn)
static

Definition at line 1504 of file proxy_util.c.

◆ worker_address_get()

static APR_INLINE proxy_address * worker_address_get ( proxy_worker worker)
static

Definition at line 2844 of file proxy_util.c.

◆ worker_address_resolve()

static apr_status_t worker_address_resolve ( proxy_worker worker,
apr_sockaddr_t **  paddr,
const char hostname,
apr_port_t  hostport,
const char proxy_function,
request_rec r,
server_rec s 
)
static

Definition at line 2860 of file proxy_util.c.

◆ worker_address_set()

static APR_INLINE void worker_address_set ( proxy_worker worker,
proxy_address to 
)
static

Definition at line 2851 of file proxy_util.c.

Variable Documentation

◆ aplog_module_index

int* const aplog_module_index = &( proxy_module.module_index)
static

Definition at line 45 of file proxy_util.c.

◆ lb_workers_limit

int lb_workers_limit = 0
static

Definition at line 72 of file proxy_util.c.

◆ proxy_mutex

apr_global_mutex_t* proxy_mutex
extern

Definition at line 78 of file mod_proxy.c.

◆ proxy_start_time

const apr_time_t* proxy_start_time
static

Definition at line 78 of file proxy_util.c.

◆ pschemes

proxy_schemes_t pschemes[]
static
Initial value:
=
{
{"fcgi", 8000},
{"ajp", 8009 },
{"scgi", 4000 },
{"h2c", 80 },
{"h2", 443 },
{"ws", 80 },
{"wss", 443 },
{ NULL, 0xFFFF }
}
return NULL
Definition mod_so.c:359

Definition at line 5110 of file proxy_util.c.