proxy_util.c revision 0e43ad0d6c23825c2c37e67087471e361347ee41
aa0b2780958e9b1467c9d0153a05738e399811a5nd/* Licensed to the Apache Software Foundation (ASF) under one or more
aa0b2780958e9b1467c9d0153a05738e399811a5nd * contributor license agreements. See the NOTICE file distributed with
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * this work for additional information regarding copyright ownership.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * The ASF licenses this file to You under the Apache License, Version 2.0
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * (the "License"); you may not use this file except in compliance with
aa0b2780958e9b1467c9d0153a05738e399811a5nd * the License. You may obtain a copy of the License at
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * Unless required by applicable law or agreed to in writing, software
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd * distributed under the License is distributed on an "AS IS" BASIS,
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
2e545ce2450a9953665f701bb05350f0d3f26275nd * limitations under the License.
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd/* Utility routines for Apache proxy */
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung/* Global balancer counter */
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4ndstatic int lb_workers_limit = 0;
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4ndstatic int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
b09fcdfc59ada4712150e7bcc7b502bb9e4601d8rjungstatic int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4ndstatic int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4ndstatic int proxy_match_word(struct dirconn_entry *This, request_rec *r);
aa0b2780958e9b1467c9d0153a05738e399811a5ndAPR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
aa0b2780958e9b1467c9d0153a05738e399811a5nd/* already called in the knowledge that the characters are hex digits */
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin#else /*APR_CHARSET_EBCDIC*/
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * we assume that the hex value refers to an ASCII character
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * so convert to EBCDIC so that it makes sense locally;
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * client specifies %20 in URL to refer to a space char;
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * at this point we're called with EBCDIC "20"; after turning
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * EBCDIC "20" into binary 0x20, we then need to assume that 0x20
d8c20b2218b1aff46358f67ae5e9c66a67982efbminfrin * represents an ASCII char and convert 0x20 to EBCDIC, yielding
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd return buf[0];
727872d18412fc021f03969b8641810d8896820bhumbedooh#endif /*APR_CHARSET_EBCDIC*/
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedoohPROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x)
0d0ba3a410038e179b695446bb149cce6264e0abnd x[0] = '%';
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh if (i >= 10) {
205f749042ed530040a4f0080dbcb47ceae8a374rjung if (i >= 10) {
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd#else /*APR_CHARSET_EBCDIC*/
int proxyreq)
int i, j, ch;
if (t == enc_path) {
else if (t == enc_search) {
else if (t == enc_user) {
else if (t == enc_fpath) {
if (t == enc_path) {
else if (t == enc_search) {
for (i = 0, j = 0; i < len; i++, j++) {
ch = x[i];
y[j] = ch;
return NULL;
y[j] = ch;
PROXY_DECLARE(char *)
return NULL;
PROXY_DECLARE(const char *)
return rp;
int len, i;
if (p != NULL) {
i = p - list;
} while (apr_isspace(*p));
list = p;
int len, i;
if (p != NULL) {
i = p - list;
} while (apr_isspace(*p));
if (new) {
list = p;
return new;
int i, ch;
ch = x[i];
int i, ch;
return statuscode;
return r->hostname;
return NULL;
url = apr_pstrdup(r->pool, &url[1]); /* make it point to "//", which is what proxy_canon_netloc expects */
int i, quads;
long bits;
char *tmp;
char *tmp;
++addr;
--quads;
/* "IP Address should be given in dotted-quad form, optionally followed by a netmask (e.g., 192.168.111.0/24)"; */
#if DEBUGGING
#if DEBUGGING
!= APR_SUCCESS) {
#if DEBUGGING
while (reqaddr) {
#if DEBUGGING
#if DEBUGGING
--d_len;
--h_len;
int h2_len;
int h1_len;
while (addr) {
--h2_len;
--h1_len;
return HTTP_FORBIDDEN;
while (conf_addr) {
while (uri_addr) {
char *conf_ip;
char *uri_ip;
return HTTP_FORBIDDEN;
return OK;
return OK;
* ap_rgetline() in protocol.c. Deprecate this function and use ap_rgetline()
apr_bucket *e;
char *response;
int found = 0;
buff[0] = 0;
*eos = 0;
while (!found) {
return rv;
while (!found) {
return APR_ECONNABORTED;
if (APR_BUCKET_IS_EOS(e)) {
(const char **)&response,
&len,
APR_BLOCK_READ))) {
return rv;
if (len > 0) {
return APR_SUCCESS;
if (!initial) {
count++;
return url;
return url;
&proxy_module);
const char *pathp;
const char *domainp;
int ddiff = 0;
int pdiff = 0;
char *ret;
return str;
if (newpath) {
if (newdomain) {
if (newdomain) {
return ret;
const char *url)
return NULL;
return balancer;
balancer++;
return NULL;
apr_pool_t *p,
const char *url)
if (!lbmethod) {
#if APR_HAS_THREADS
return NULL;
const char *url)
int max_match = 0;
int url_length;
int min_match;
int worker_name_length;
char *url_copy;
return NULL;
char *pathstart;
worker++;
return max_worker;
#if APR_HAS_THREADS
return APR_SUCCESS;
apr_pool_t *p,
const char *url)
int rv;
#if APR_HAS_THREADS
return NULL;
return worker;
PROXY_DECLARE(void)
request_rec *r,
int access_status;
if (*worker) {
*url);
*url);
*url);
return access_status;
request_rec *r,
int access_status;
if (balancer) {
return access_status;
const char *proxy_function,
const char *backend_name,
server_rec *s,
apr_pool_t *p)
int connected = 0;
int loglevel;
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
#if APR_HAS_THREADS
return APR_SUCCESS;
return APR_SUCCESS;
server_rec *s)
if (ap_scoreboard_image) {
if (!score) {
if (!score) {
#if APR_HAS_THREADS
int mpm_threads;
return APR_SUCCESS;
#if APR_HAS_THREADS
#if (APR_MAJOR_VERSION > 0)
void *conn;
return rv;
server_rec *s)
return OK;
return DECLINED;
return OK;
server_rec *s)
return HTTP_SERVICE_UNAVAILABLE;
#if APR_HAS_THREADS
return HTTP_SERVICE_UNAVAILABLE;
#if APR_HAS_THREADS
return OK;
server_rec *s)
return OK;
PROXY_DECLARE(int)
char **url,
const char *proxyname,
char *server_portstr,
int server_portstr_size)
int server_port;
NULL));
if (!proxyname) {
if (proxyname) {
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
server_rec *s)
int connected = 0;
int loglevel;
conn_rec *c,
server_rec *s)
int rc;
c->bucket_alloc);
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
return rc;
return OK;
int ap_proxy_lb_workers(void)
if (!lb_workers_limit)
return lb_workers_limit;
apr_bucket *e;
if (r->main)
c->bucket_alloc);