Commit 01e6c13b authored by Jeff Trawick's avatar Jeff Trawick
Browse files

tweak ap_get_remote_host() so that the caller can find out if she got

back an IP address

mod_access needed to know this, but the old code didn't handle IPv6


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88484 13f79535-47bb-0310-9956-ffa450edef68
parent e12ad27f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -184,10 +184,12 @@ AP_DECLARE(const char *) ap_document_root(request_rec *r);
 *                   setting.  The result is the (double reverse checked) 
 *                   hostname, or NULL if any of the lookups fail.
 * </PRE>
 * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address 
 *        string is returned
 * @return The remote hostname
 * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type)
 * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip)
 */
AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type);
AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip);

/**
 * Retrieve the login name of the remote user.  Undef if it could not be
+4 −2
Original line number Diff line number Diff line
@@ -341,10 +341,12 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method)

	case T_HOST:
	    if (!gothost) {
                int remotehost_is_ip;

		remotehost = ap_get_remote_host(r->connection, r->per_dir_config,
					    REMOTE_DOUBLE_REV);
                                                REMOTE_DOUBLE_REV, &remotehost_is_ip);

		if ((remotehost == NULL) || is_ip(remotehost))
		if ((remotehost == NULL) || remotehost_is_ip)
		    gothost = 1;
		else
		    gothost = 2;
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ static const char *constant_item(request_rec *dummy, char *stuff)
static const char *log_remote_host(request_rec *r, char *a)
{
    return ap_get_remote_host(r->connection, r->per_dir_config,
                                    REMOTE_NAME);
                                    REMOTE_NAME, NULL);
}

static const char *log_remote_address(request_rec *r, char *a)
+2 −2
Original line number Diff line number Diff line
@@ -3138,7 +3138,7 @@ static void rewritelog(request_rec *r, int level, const char *text, ...)
    }

    rhost = ap_get_remote_host(conn, r->server->module_config, 
                               REMOTE_NOLOOKUP);
                               REMOTE_NOLOOKUP, NULL);
    if (rhost == NULL) {
        rhost = "UNKNOWN-HOST";
    }
@@ -3409,7 +3409,7 @@ static char *lookup_variable(request_rec *r, char *var)
    }
    else if (strcasecmp(var, "REMOTE_HOST") == 0) {
        result = (char *)ap_get_remote_host(r->connection,
                                         r->per_dir_config, REMOTE_NAME);
                                            r->per_dir_config, REMOTE_NAME, NULL);
    }
    else if (strcasecmp(var, "REMOTE_USER") == 0) {
        result = r->user;
+1 −1
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ static int match_headers(request_rec *r)
		break;
	    case SPECIAL_REMOTE_HOST:
		val =  ap_get_remote_host(r->connection, r->per_dir_config,
					  REMOTE_NAME);
					  REMOTE_NAME, NULL);
		break;
	    case SPECIAL_REMOTE_USER:
		val = r->user;
Loading