]> granicus.if.org Git - apache/commitdiff
More local/remote changes and tidy up http_vhost a bit.
authorDavid Reid <dreid@apache.org>
Fri, 10 Nov 2000 16:11:14 +0000 (16:11 +0000)
committerDavid Reid <dreid@apache.org>
Fri, 10 Nov 2000 16:11:14 +0000 (16:11 +0000)
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
server/vhost.c

index dcbfe2aece84d12803c8911fb80e6c704e5656f5..46f5c74ef274dffba1555374f5ae6f38102ae0da 100644 (file)
@@ -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 */
index be492e6fb0c5768f77708bff2cfac53d97c29873..69fb6fb5cf4e78a68577cfee38469a7e0009c0da 100644 (file)
@@ -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;
 }