You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/05/08 05:37:04 UTC
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10 HttpConnector.java HttpRequestImpl.java
craigmcc 01/05/07 20:37:04
Modified: catalina/src/conf server.xml
catalina/src/share/org/apache/catalina Connector.java
catalina/src/share/org/apache/catalina/connector/http
HttpConnector.java HttpRequestImpl.java
catalina/src/share/org/apache/catalina/connector/http10
HttpConnector.java HttpRequestImpl.java
Log:
Make it possible to disable DNS lookups of the remote host name, for
Tomcat used stand-alone, even when the web app calls
request.getRemoteHost(). Lookups are enabled by default -- disable them
by modifying the <Connector ... disableLookups .../> attribute.
Submitted by: Roy T. Fielding <fi...@ebuilt.com>
Revision Changes Path
1.22 +3 -0 jakarta-tomcat-4.0/catalina/src/conf/server.xml
Index: server.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/conf/server.xml,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- server.xml 2001/04/27 00:34:00 1.21
+++ server.xml 2001/05/08 03:37:01 1.22
@@ -45,6 +45,7 @@
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
+ disableLookups="false"
acceptCount="10" debug="0" connectionTimeout="60000"/>
<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->
@@ -53,6 +54,7 @@
<!--
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8443" minProcessors="5" maxProcessors="75"
+ disableLookups="false"
acceptCount="10" debug="0" scheme="https" secure="true">
<Factory className="org.apache.catalina.net.SSLServerSocketFactory"
clientAuth="false" protocol="TLS"/>
@@ -72,6 +74,7 @@
<!--
<Connector className="org.apache.catalina.connector.http10.HttpConnector"
port="8082" minProcessors="5" maxProcessors="75"
+ disableLookups="false"
acceptCount="10" debug="0"/>
-->
1.3 +18 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Connector.java
Index: Connector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Connector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Connector.java 2000/09/08 22:29:34 1.2
+++ Connector.java 2001/05/08 03:37:02 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Connector.java,v 1.2 2000/09/08 22:29:34 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/09/08 22:29:34 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Connector.java,v 1.3 2001/05/08 03:37:02 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/05/08 03:37:02 $
*
* ====================================================================
*
@@ -117,7 +117,7 @@
* normative.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/09/08 22:29:34 $
+ * @version $Revision: 1.3 $ $Date: 2001/05/08 03:37:02 $
*/
public interface Connector {
@@ -140,6 +140,20 @@
* @param container The new Container to use
*/
public void setContainer(Container container);
+
+
+ /**
+ * Return the "disable DNS lookups" flag.
+ */
+ public boolean getDisableLookups();
+
+
+ /**
+ * Set the "disable DNS lookups" flag.
+ *
+ * @param disableLookups The new "disable DNS lookups" flag value
+ */
+ public void setDisableLookups(boolean disableLookups);
/**
1.13 +32 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java
Index: HttpConnector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- HttpConnector.java 2001/04/12 01:06:12 1.12
+++ HttpConnector.java 2001/05/08 03:37:02 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.12 2001/04/12 01:06:12 craigmcc Exp $
- * $Revision: 1.12 $
- * $Date: 2001/04/12 01:06:12 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.13 2001/05/08 03:37:02 craigmcc Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/05/08 03:37:02 $
*
* ====================================================================
*
@@ -95,7 +95,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.12 $ $Date: 2001/04/12 01:06:12 $
+ * @version $Revision: 1.13 $ $Date: 2001/05/08 03:37:02 $
*/
@@ -150,6 +150,12 @@
/**
+ * The "disable DNS lookups" flag for this Connector.
+ */
+ private boolean disableLookups = false;
+
+
+ /**
* The server socket factory for this component.
*/
private ServerSocketFactory factory = null;
@@ -456,6 +462,28 @@
public void setDebug(int debug) {
this.debug = debug;
+
+ }
+
+
+ /**
+ * Return the "disable DNS lookups" flag.
+ */
+ public boolean getDisableLookups() {
+
+ return (this.disableLookups);
+
+ }
+
+
+ /**
+ * Set the "disable DNS lookups" flag.
+ *
+ * @param disableLookups The new "disable DNS lookups" flag value
+ */
+ public void setDisableLookups(boolean disableLookups) {
+
+ this.disableLookups = disableLookups;
}
1.8 +8 -5 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java
Index: HttpRequestImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HttpRequestImpl.java 2001/02/04 02:23:54 1.7
+++ HttpRequestImpl.java 2001/05/08 03:37:03 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.7 2001/02/04 02:23:54 craigmcc Exp $
- * $Revision: 1.7 $
- * $Date: 2001/02/04 02:23:54 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.8 2001/05/08 03:37:03 craigmcc Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/05/08 03:37:03 $
*
* ====================================================================
*
@@ -81,7 +81,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.7 $ $Date: 2001/02/04 02:23:54 $
+ * @version $Revision: 1.8 $ $Date: 2001/05/08 03:37:03 $
*/
final class HttpRequestImpl
@@ -339,7 +339,10 @@
*/
public String getRemoteHost() {
- return (inet.getHostName());
+ if (connector.getDisableLookups())
+ return (getRemoteAddr());
+ else
+ return (inet.getHostName());
}
1.4 +32 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpConnector.java
Index: HttpConnector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpConnector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpConnector.java 2001/04/12 01:06:13 1.3
+++ HttpConnector.java 2001/05/08 03:37:03 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpConnector.java,v 1.3 2001/04/12 01:06:13 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2001/04/12 01:06:13 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpConnector.java,v 1.4 2001/05/08 03:37:03 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/05/08 03:37:03 $
*
* ====================================================================
*
@@ -94,7 +94,7 @@
* purposes. Not intended to be the final solution.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2001/04/12 01:06:13 $
+ * @version $Revision: 1.4 $ $Date: 2001/05/08 03:37:03 $
*/
@@ -149,6 +149,12 @@
/**
+ * The "disable DNS lookups" flag for this Connector.
+ */
+ private boolean disableLookups = false;
+
+
+ /**
* The server socket factory for this component.
*/
private ServerSocketFactory factory = null;
@@ -427,6 +433,28 @@
public void setDebug(int debug) {
this.debug = debug;
+
+ }
+
+
+ /**
+ * Return the "disable DNS lookups" flag.
+ */
+ public boolean getDisableLookups() {
+
+ return (this.disableLookups);
+
+ }
+
+
+ /**
+ * Set the "disable DNS lookups" flag.
+ *
+ * @param disableLookups The new "disable DNS lookups" flag value
+ */
+ public void setDisableLookups(boolean disableLookups) {
+
+ this.disableLookups = disableLookups;
}
1.2 +7 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java
Index: HttpRequestImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpRequestImpl.java 2001/01/23 03:55:54 1.1
+++ HttpRequestImpl.java 2001/05/08 03:37:03 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java,v 1.1 2001/01/23 03:55:54 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/01/23 03:55:54 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java,v 1.2 2001/05/08 03:37:03 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/05/08 03:37:03 $
*
* ====================================================================
*
@@ -73,7 +73,7 @@
* Implementation of <b>HttpRequest</b> specific to the HTTP connector.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2001/01/23 03:55:54 $
+ * @version $Revision: 1.2 $ $Date: 2001/05/08 03:37:03 $
*/
final class HttpRequestImpl
@@ -170,7 +170,10 @@
*/
public String getRemoteHost() {
- return (inet.getHostName());
+ if (connector.getDisableLookups())
+ return (getRemoteAddr());
+ else
+ return (inet.getHostName());
}
Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/htt
p10 HttpConnector.java HttpRequestImpl.java
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 8 May 2001, Kief Morris wrote:
> craigmcc@apache.org typed the following on 03:37 AM 5/8/2001 +0000
> > Make it possible to disable DNS lookups of the remote host name, for
> > Tomcat used stand-alone, even when the web app calls
> > request.getRemoteHost(). Lookups are enabled by default -- disable them
> > by modifying the <Connector ... disableLookups .../> attribute.
>
> I think it would be better to have DNS lookups _disabled_ by default (doesn't
> Apache httpd do this?). If someone really needs to get the hostname for
> their app, they can take the trouble to enable it, but the "out of the box
> experience" for Tomcat shouldn't be pig-slow for a probably unnecessary
> feature. IMHO of course. ;-)
>
I can see your point (having been brow-beaten in a discussion on this
topic late last night :-). However, the counter-arguments are:
* Changing it to disabled by default would change behavior versus
current Tomcats (of all generations), and possibly break apps that
depend on host lookups.
* Newbie servlet developers expect the API calls to work the way that
the name implies - disabled by default would lead to lots of questions.
I added a note in the default server.xml file with regards to potential
performance impacts.
> Kief
>
>
Craig
Re: cvs commit:
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/htt
p10 HttpConnector.java HttpRequestImpl.java
Posted by Kief Morris <ki...@bitbull.com>.
craigmcc@apache.org typed the following on 03:37 AM 5/8/2001 +0000
> Make it possible to disable DNS lookups of the remote host name, for
> Tomcat used stand-alone, even when the web app calls
> request.getRemoteHost(). Lookups are enabled by default -- disable them
> by modifying the <Connector ... disableLookups .../> attribute.
I think it would be better to have DNS lookups _disabled_ by default (doesn't
Apache httpd do this?). If someone really needs to get the hostname for
their app, they can take the trouble to enable it, but the "out of the box
experience" for Tomcat shouldn't be pig-slow for a probably unnecessary
feature. IMHO of course. ;-)
Kief