28#define APR_WANT_STRFUNC
40#if APR_HAVE_ARPA_INET_H
45#undef APLOG_MODULE_INDEX
46#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
83#ifndef IPHASH_TABLE_SIZE
84#define IPHASH_TABLE_SIZE 256
167 if (w[
wlen - 1] ==
'*') {
171 else if (w[
wlen - 2] ==
':') {
181 return "The address or port is invalid";
184 return "Missing address for VirtualHost";
186#if !APR_VERSION_AT_LEAST(1,7,0)
189 "Scope ID in address '", w,
201 return "Could not determine a wildcard address ('0.0.0.0') -- "
202 "check resolver configuration.";
209 "Could not resolve host name %s -- ignoring!",
host);
212#if APR_VERSION_AT_LEAST(1,7,0)
217 "Could not set scope ID %s for %pI -- ignoring!",
261 if (
s->addrs->host_port) {
277 "NameVirtualHost has no effect and will be removed in the "
278 "next release %s:%d",
279 cmd->directive->filename,
280 cmd->directive->line_num);
290#ifdef IPHASH_STATISTICS
293 return (*(
const int *)
b - *(
const int *)
a);
319 APLOGNO(03235)
"iphash: total hashed = %u, avg chain = %u, "
320 "chain lengths (count x len):",
377 new->initialnames =
NULL;
446#define IS_IN6_ANYADDR(ad) ((ad)->family == APR_INET6 \
447 && IN6_IS_ADDR_UNSPECIFIED(&(ad)->sa.sin6.sin6_addr))
449#define IS_IN6_ANYADDR(ad) (0)
467 if (
ic->sar->host_port == 0) {
472 ic->server->server_hostname,
473 ic->server->defn_name,
ic->server->defn_line_number);
477 "%8s default server %s (%s:%u)\n",
478 buf,
"",
ic->server->server_hostname,
479 ic->server->defn_name,
ic->server->defn_line_number);
481 if (
nc->sar->host_port) {
488 nc->server->server_hostname,
489 nc->server->defn_name,
nc->server->defn_line_number);
490 if (
nc->server->names) {
494 for (
i = 0;
i <
names->nelts; ++
i) {
500 if (
nc->server->wild_names) {
504 for (
i = 0;
i <
names->nelts; ++
i) {
545 nc->next =
ic->names;
551 if (
ic->initialnames ==
NULL) {
555 ic->initialnames =
nc;
561 nc->next =
ic->initialnames;
584 if (!
s->server_hostname) {
602 for (sar =
s->addrs; sar; sar = sar->
next) {
650 if (!
s->server_hostname) {
652 s->server_hostname =
main_s->server_hostname;
654 else if (!
s->addrs) {
677 "Failed to resolve server name "
678 "for %s (check DNS) -- or specify an explicit "
688#ifdef IPHASH_STATISTICS
719 else if (*
dst ==
':') {
720 if (*(
dst + 1) ==
':') {
725 else if (*(
dst + 1) ==
'.') {
729 else if (*
dst ==
'.') {
731 if (*(
dst + 1) ==
':' || *(
dst + 1) ==
'.')
749 else if (*
dst ==
'.') {
750 if (*(
dst + 1) ==
'.') {
757 else if (*
dst ==
'/' || *
dst ==
'\\') {
781 else if (
ch[0] ==
'.') {
810 "[strict] Invalid host name '%s'%s%.6s",
811 host, *
ch ?
", problem near: " :
"",
ch);
829 unsigned http_conformance)
855 "[strict] purely numeric host names not allowed: %s",
905 "Client sent malformed Host header: %s",
927 for (
i = 0;
i <
names->nelts; ++
i) {
928 if (!
name[
i])
continue;
936 for (
i = 0;
i <
names->nelts; ++
i) {
937 if (!
name[
i])
continue;
977 for (sar =
s->addrs; sar; sar = sar->
next) {
986 if (
port !=
s->port) {
1115 if (
src->sar->host_port != 0 &&
port !=
src->sar->host_port) {
1126 (
s->path[
s->pathlen - 1] ==
'/' ||
1127 r->
uri[
s->pathlen] ==
'/' ||
1128 r->
uri[
s->pathlen] ==
'\0')) {
1206 "Replacing host header '%s' with host '%s' given "
Symbol export macros and hook functions.
#define AP_DECLARE_NONSTD(type)
const char apr_size_t len
APR general purpose library routines.
APR Versioning Interface.
#define APR_VERSION_STRING
APR Standard Headers Support.
void ap_hook_check_config(ap_HOOK_check_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
int ap_exists_config_define(const char *name)
#define ap_get_core_module_config(v)
const unsigned char * buf
const char apr_port_t port
ap_vhost_iterate_conn_cb func_cb
ap_vhost_iterate_conn_cb void * baton
int(* ap_vhost_iterate_conn_cb)(void *baton, conn_rec *conn, server_rec *s)
const char * ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s)
apr_bucket apr_bucket_brigade * a
int ap_strcasecmp_match(const char *str, const char *expected)
char * ap_get_local_host(apr_pool_t *p)
char * ap_getword_conf(apr_pool_t *p, const char **line)
const struct iovec apr_size_t nvec
int strcasecmp(const char *a, const char *b)
apr_vformatter_buff_t * c
#define apr_pcalloc(p, size)
apr_int32_t apr_int32_t apr_int32_t err
#define AP_HTTP_CONFORMANCE_UNSAFE
Structure to store things which are per connection.
apr_sockaddr_t * local_addr
name_chain * initialnames
A structure that represents the current request.
A structure to be used for Per-vhost config.
apr_sockaddr_t * host_addr
A structure to store information for each virtual server.
struct ap_conf_vector_t * module_config
int ap_matches_request_vhost(request_rec *r, const char *host, apr_port_t port)
#define IS_IN6_ANYADDR(ad)
static int vhost_check_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
static int fix_hostname(request_rec *r, const char *host_header, unsigned http_conformance)
static name_chain * new_name_chain(apr_pool_t *p, server_rec *s, server_addr_rec *sar)
static ipaddr_chain * find_default_server(apr_port_t port)
static APR_INLINE unsigned hash_inaddr(unsigned key)
void ap_fini_vhost_config(apr_pool_t *p, server_rec *main_s)
void ap_init_vhost_config(apr_pool_t *p)
static void check_serverpath(request_rec *r)
static APR_INLINE ipaddr_chain * find_ipaddr(apr_sockaddr_t *sa)
static ipaddr_chain * default_list
static void dump_vhost_config(apr_file_t *f)
static ipaddr_chain * iphash_table[256]
static int update_server_from_aliases(request_rec *r)
static APR_INLINE const char * construct_host_header(request_rec *r, int is_v6literal)
static const char * get_addresses(apr_pool_t *p, const char *w_, server_addr_rec ***paddr, apr_port_t default_port)
int ap_vhost_iterate_given_conn(conn_rec *conn, ap_vhost_iterate_conn_cb func_cb, void *baton)
static ipaddr_chain * new_ipaddr_chain(apr_pool_t *p, server_rec *s, server_addr_rec *sar)
int ap_update_vhost_from_headers_ex(request_rec *r, int require_match)
#define IPHASH_TABLE_SIZE
static apr_status_t fix_hostname_v6_literal(request_rec *r, char *host)
static apr_status_t fix_hostname_non_v6(request_rec *r, char *host)
void ap_update_vhost_given_ip(conn_rec *conn)
void ap_update_vhost_from_headers(request_rec *r)
const char * ap_set_name_virtual_host(cmd_parms *cmd, void *dummy, const char *arg)
static int matches_aliases(server_rec *s, const char *host)
static void dump_a_vhost(apr_file_t *f, ipaddr_chain *ic)
static void add_name_vhost_config(apr_pool_t *p, server_rec *main_s, server_rec *s, server_addr_rec *sar, ipaddr_chain *ic)
static apr_status_t strict_hostname_check(request_rec *r, char *host)
static APR_INLINE unsigned hash_addr(struct apr_sockaddr_t *sa)