From 87112b9ed318480dfbf1ac51df89b46ff1a7a30f Mon Sep 17 00:00:00 2001 From: David Reid Date: Fri, 10 Nov 2000 16:11:14 +0000 Subject: [PATCH] More local/remote changes and tidy up http_vhost a bit. Also add a new function to get an ap_ina_addr_t from a socket. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86910 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_core.c | 22 +++++------------ server/vhost.c | 52 ++++++---------------------------------- 2 files changed, 13 insertions(+), 61 deletions(-) diff --git a/modules/http/http_core.c b/modules/http/http_core.c index dcbfe2aece..46f5c74ef2 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -631,7 +631,7 @@ AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, && conn->remote_host == NULL && (type == REMOTE_DOUBLE_REV || hostname_lookups != HOSTNAME_LOOKUP_OFF)) { - if (apr_get_remote_hostname(&conn->remote_host, conn->client_socket) + if (apr_get_hostname(&conn->remote_host, APR_REMOTE, conn->client_socket) == APR_SUCCESS){ ap_str_tolower(conn->remote_host); @@ -718,21 +718,11 @@ AP_DECLARE(const char *) ap_get_server_name(request_rec *r) } if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) { if (conn->local_host == NULL) { - struct in_addr *iaddr; - struct hostent *hptr; - iaddr = &(conn->local_addr.sin_addr); - hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), - AF_INET); - if (hptr != NULL) { - conn->local_host = apr_pstrdup(conn->pool, - (void *)hptr->h_name); - ap_str_tolower(conn->local_host); - } - else { - conn->local_host = apr_pstrdup(conn->pool, - r->server->server_hostname); - } - } + if (apr_get_hostname(&conn->local_host, APR_LOCAL, conn->client_socket) != APR_SUCCESS) + conn->local_host = apr_pstrdup(conn->pool, r->server->server_hostname); + else + ap_str_tolower(conn->local_host); + } return conn->local_host; } /* default */ diff --git a/server/vhost.c b/server/vhost.c index be492e6fb0..69fb6fb5cf 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -186,11 +186,10 @@ void ap_init_vhost_config(apr_pool_t *p) static const char *get_addresses(apr_pool_t *p, const char *w_, server_addr_rec ***paddr, apr_port_t port) { - struct hostent *hep; apr_in_addr_t my_addr; server_addr_rec *sar; char *t; - int i, is_an_ip_addr; + int i; char *w; if (*w_ == 0) @@ -222,49 +221,12 @@ static const char *get_addresses(apr_pool_t *p, const char *w_, } } -/* - is_an_ip_addr = 0; - if (strcmp(w, "*") == 0) { - my_addr.s_addr = htonl(INADDR_ANY); - is_an_ip_addr = 1; - } - else if (strcasecmp(w, "_default_") == 0 - || strcmp(w, "255.255.255.255") == 0) { - my_addr.s_addr = DEFAULT_VHOST_ADDR; - is_an_ip_addr = 1; - } - else if ((my_addr.s_addr = apr_inet_addr(w)) != INADDR_NONE) { - is_an_ip_addr = 1; - } - if (is_an_ip_addr) { -*/ - sar = apr_pcalloc(p, sizeof(server_addr_rec)); - **paddr = sar; - *paddr = &sar->next; - sar->host_addr = my_addr; - sar->host_port = port; - sar->virthost = apr_pstrdup(p, w); - return NULL; -/* - } - - hep = gethostbyname(w); - - if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL, - "Cannot resolve host name %s --- ignoring!", w); - return NULL; - } - - for (i = 0; hep->h_addr_list[i]; ++i) { - sar = apr_pcalloc(p, sizeof(server_addr_rec)); - **paddr = sar; - *paddr = &sar->next; - sar->host_addr = *(struct in_addr *) hep->h_addr_list[i]; - sar->host_port = port; - sar->virthost = apr_pstrdup(p, w); - } -*/ + sar = apr_pcalloc(p, sizeof(server_addr_rec)); + **paddr = sar; + *paddr = &sar->next; + sar->host_addr = my_addr; + sar->host_port = port; + sar->virthost = apr_pstrdup(p, w); return NULL; } -- 2.50.1