On Sat, 1 Mar 2003, Chris Monson wrote:Patch is included as an attachment.
Done. Where shall I submit the patch? Is it kosher to send it to this
list?
Absolutely.
(Well, sometimes if the patch is really really big, we have people post it to a webpage somewhere and just mail the URL to the list, but most of the time just go ahead and mail the patch to the list. You can either paste it inline or attach it, though if you attach it try to use mime type "text/plain".)
C
*** server/core.c 2003-03-01 08:12:10.000000000 -0700
--- server/new/core.c 2003-03-01 09:56:08.000000000 -0700
***************
*** 144,149 ****
--- 144,150 ----
conf->use_canonical_name = USE_CANONICAL_NAME_UNSET;
conf->hostname_lookups = HOSTNAME_LOOKUP_UNSET;
+ conf->ip_lookups = IP_LOOKUP_DEFAULT;
conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */
conf->satisfy = SATISFY_NOSPEC;
***************
*** 620,625 ****
--- 621,653 ----
* here...
*/
+ AP_DECLARE(apr_int32_t) ap_get_iplookup_flags(request_rec *r)
+ {
+ apr_int32_t flags;
+
+ core_dir_config *conf;
+ conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
+ &core_module);
+
+ switch (conf->ip_lookups) {
+ default:
+ /* falls through */
+ case IP_LOOKUP_DEFAULT:
+ /* falls through */
+ case IP_LOOKUP_ALL:
+ flags = 0;
+ break;
+ case IP_LOOKUP_IPV4OKAY:
+ flags = APR_IPV4_ADDR_OK;
+ break;
+ case IP_LOOKUP_IPV6OKAY:
+ flags = APR_IPV6_ADDR_OK;
+ break;
+ }
+
+ return flags;
+ }
+
AP_DECLARE(int) ap_allow_options(request_rec *r)
{
core_dir_config *conf =
***************
*** 2113,2118 ****
--- 2141,2172 ----
return NULL;
}
+ static const char *set_ip_lookups(cmd_parms *cmd, void *d_,
+ const char *arg)
+ {
+ core_dir_config *d = d_;
+ const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
+
+ if (err != NULL) {
+ return err;
+ }
+
+ if (!strcasecmp(arg, "all")) {
+ d->ip_lookups = IP_LOOKUP_ALL;
+ }
+ else if (!strcasecmp(arg, "ipv4okay")) {
+ d->ip_lookups = IP_LOOKUP_IPV4OKAY;
+ }
+ else if (!strcasecmp(arg, "ipv6okay")) {
+ d->ip_lookups = IP_LOOKUP_IPV6OKAY;
+ }
+ else {
+ return "parameter must be 'all', 'ipv4okay', or 'ipv6okay'";
+ }
+
+ return NULL;
+ }
+
static const char *set_serverpath(cmd_parms *cmd, void *dummy,
const char *arg)
{
***************
*** 2982,2987 ****
--- 3036,3043 ----
ACCESS_CONF|RSRC_CONF,
"\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
"enable double-reverse DNS lookups"),
+ AP_INIT_TAKE1("IPLookups", set_ip_lookups, NULL, ACCESS_CONF | RSRC_CONF,
+ "Set the IP lookup order (All|IPv4Okay|IPv6Okay)"),
AP_INIT_TAKE1("ServerAdmin", set_server_string_slot,
(void *)APR_OFFSETOF(server_rec, server_admin), RSRC_CONF,
"The email address of the server administrator"),
*** include/http_core.h 2003-03-01 08:53:31.000000000 -0700
--- include/new/http_core.h 2003-03-01 09:54:56.000000000 -0700
***************
*** 135,140 ****
--- 135,148 ----
#define AP_MIN_BYTES_TO_WRITE 8000
/**
+ * Retrieve the value of IPLookups as flags for apr_sockaddr_info_get
+ * @param r The current request
+ * @return the flags bitmask for apr_sockaddr_info_get
+ * @deffunc apr_int32_t ap_get_iplookup_flags(request_rec *r)
+ */
+ AP_DECLARE(apr_int32_t) ap_get_iplookup_flags(request_rec *r);
+
+ /**
* Retrieve the value of Options for this request
* @param r The current request
* @return the Options bitmask
***************
*** 464,469 ****
--- 472,483 ----
#define HOSTNAME_LOOKUP_UNSET 3
unsigned int hostname_lookups : 4;
+ #define IP_LOOKUP_DEFAULT 0
+ #define IP_LOOKUP_ALL 1
+ #define IP_LOOKUP_IPV4OKAY 2
+ #define IP_LOOKUP_IPV6OKAY 3
+ unsigned int ip_lookups : 4;
+
signed int do_rfc1413 : 2; /* See if client is advertising a username? */
signed int content_md5 : 2; /* calculate Content-MD5? */
*** modules/proxy/proxy_http.c 2003-03-01 09:54:27.000000000 -0700
--- modules/proxy/new/proxy_http.c 2003-03-01 09:53:24.000000000 -0700
***************
*** 204,209 ****
--- 204,210 ----
int server_port;
apr_status_t err;
apr_sockaddr_t *uri_addr;
+ apr_int32_t lookup_flags;
/*
* Break up the URL to determine the host to connect to
*/
***************
*** 222,231 ****
"proxy: HTTP connecting %s to %s:%d", *url, uri->hostname,
uri->port);
/* do a DNS lookup for the destination host */
/* see memory note above */
err = apr_sockaddr_info_get(&uri_addr, apr_pstrdup(c->pool, uri->hostname),
! APR_UNSPEC, uri->port, 0, c->pool);
/* allocate these out of the connection pool - the check on
* r->connection->id makes sure that this string does not get accessed
--- 223,234 ----
"proxy: HTTP connecting %s to %s:%d", *url, uri->hostname,
uri->port);
+ lookup_flags = ap_get_iplookup_flags(r);
+
/* do a DNS lookup for the destination host */
/* see memory note above */
err = apr_sockaddr_info_get(&uri_addr, apr_pstrdup(c->pool, uri->hostname),
! APR_UNSPEC, uri->port, lookup_flags, c->pool);
/* allocate these out of the connection pool - the check on
* r->connection->id makes sure that this string does not get accessed
***************
*** 236,242 ****
p_conn->port = proxyport;
/* see memory note above */
err = apr_sockaddr_info_get(&p_conn->addr, p_conn->name, APR_UNSPEC,
! p_conn->port, 0, c->pool);
} else {
p_conn->name = apr_pstrdup(c->pool, uri->hostname);
p_conn->port = uri->port;
--- 239,245 ----
p_conn->port = proxyport;
/* see memory note above */
err = apr_sockaddr_info_get(&p_conn->addr, p_conn->name, APR_UNSPEC,
! p_conn->port, lookup_flags, c->pool);
} else {
p_conn->name = apr_pstrdup(c->pool, uri->hostname);
p_conn->port = uri->port;
*** modules/proxy/proxy_ftp.c 2003-03-01 09:54:27.000000000 -0700
--- modules/proxy/new/proxy_ftp.c 2003-03-01 09:53:24.000000000 -0700
***************
*** 801,806 ****
--- 801,807 ----
#if defined(USE_MDTM) && (defined(HAVE_TIMEGM) || defined(HAVE_GMTOFF))
apr_time_t mtime = 0L;
#endif
+ apr_int32_t lookup_flags;
/* stuff for PASV mode */
int connect = 0, use_port = 0;
***************
*** 820,825 ****
--- 821,829 ----
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: FTP: serving URL %s", url);
+ /* Get the appropriate DNS lookup flags */
+ lookup_flags = ap_get_iplookup_flags(r);
+
/* create space for state information */
backend = (proxy_conn_rec *) ap_get_module_config(c->conn_config,
&proxy_ftp_module);
if (!backend) {
***************
*** 914,920 ****
"proxy: FTP: connecting %s to %s:%d", url, connectname, connectport);
/* do a DNS lookup for the destination host */
! err = apr_sockaddr_info_get(&connect_addr, connectname, APR_UNSPEC, connectport,
0, p);
/* check if ProxyBlock directive on this host */
if (OK != ap_proxy_checkproxyblock(r, conf, connect_addr)) {
--- 918,924 ----
"proxy: FTP: connecting %s to %s:%d", url, connectname, connectport);
/* do a DNS lookup for the destination host */
! err = apr_sockaddr_info_get(&connect_addr, connectname, APR_UNSPEC, connectport,
lookup_flags, p);
/* check if ProxyBlock directive on this host */
if (OK != ap_proxy_checkproxyblock(r, conf, connect_addr)) {
***************
*** 1288,1294 ****
/* make the connection */
apr_socket_addr_get(&data_addr, APR_REMOTE, sock);
apr_sockaddr_ip_get(&data_ip, data_addr);
! apr_sockaddr_info_get(&epsv_addr, data_ip, connect_addr->family,
data_port, 0, p);
rv = apr_connect(data_sock, epsv_addr);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
--- 1292,1298 ----
/* make the connection */
apr_socket_addr_get(&data_addr, APR_REMOTE, sock);
apr_sockaddr_ip_get(&data_ip, data_addr);
! apr_sockaddr_info_get(&epsv_addr, data_ip, connect_addr->family,
data_port, lookup_flags, p);
rv = apr_connect(data_sock, epsv_addr);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
***************
*** 1373,1379 ****
#endif
/* make the connection */
! apr_sockaddr_info_get(&pasv_addr, apr_psprintf(p, "%d.%d.%d.%d", h3,
h2, h1, h0), connect_addr->family, pasvport, 0, p);
rv = apr_connect(data_sock, pasv_addr);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
--- 1377,1383 ----
#endif
/* make the connection */
! apr_sockaddr_info_get(&pasv_addr, apr_psprintf(p, "%d.%d.%d.%d", h3,
h2, h1, h0), connect_addr->family, pasvport, lookup_flags, p);
rv = apr_connect(data_sock, pasv_addr);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
***************
*** 1418,1424 ****
#endif /* _OSD_POSIX */
}
! apr_sockaddr_info_get(&local_addr, local_ip, APR_UNSPEC, local_port, 0,
r->pool);
if ((rv = apr_bind(local_sock, local_addr)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
--- 1422,1428 ----
#endif /* _OSD_POSIX */
}
! apr_sockaddr_info_get(&local_addr, local_ip, APR_UNSPEC, local_port,
lookup_flags, r->pool);
if ((rv = apr_bind(local_sock, local_addr)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
*** modules/proxy/proxy_connect.c 2003-03-01 09:54:27.000000000 -0700
--- modules/proxy/new/proxy_connect.c 2003-03-01 09:53:24.000000000 -0700
***************
*** 135,140 ****
--- 135,141 ----
apr_int32_t pollcnt;
apr_int16_t pollevent;
apr_sockaddr_t *uri_addr, *connect_addr;
+ apr_int32_t lookup_flags;
apr_uri_t uri;
const char *connectname;
***************
*** 165,178 ****
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: CONNECT: connecting %s to %s:%d", url, uri.hostname,
uri.port);
/* do a DNS lookup for the destination host */
! err = apr_sockaddr_info_get(&uri_addr, uri.hostname, APR_UNSPEC, uri.port, 0, p);
/* are we connecting directly, or via a proxy? */
if (proxyname) {
connectname = proxyname;
connectport = proxyport;
! err = apr_sockaddr_info_get(&connect_addr, proxyname, APR_UNSPEC, proxyport,
0, p);
}
else {
connectname = uri.hostname;
--- 166,181 ----
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy: CONNECT: connecting %s to %s:%d", url, uri.hostname,
uri.port);
+ lookup_flags = ap_get_iplookup_flags(r);
+
/* do a DNS lookup for the destination host */
! err = apr_sockaddr_info_get(&uri_addr, uri.hostname, APR_UNSPEC, uri.port,
lookup_flags, p);
/* are we connecting directly, or via a proxy? */
if (proxyname) {
connectname = proxyname;
connectport = proxyport;
! err = apr_sockaddr_info_get(&connect_addr, proxyname, APR_UNSPEC, proxyport,
lookup_flags, p);
}
else {
connectname = uri.hostname;
