summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorKARASZI István2012-10-08 07:33:16 (EDT)
committer Jesse McConnell2013-01-29 16:41:39 (EST)
commit840f1470196e8fd99fa4b31d8ef965eb8d8f1fa1 (patch)
tree708ad2bc2533a0079ad51beaf5ba132a8a3a4086
parent1910fb8ce42a41e0dba9a7aa742d7534038a852a (diff)
downloadorg.eclipse.jetty.project-840f1470196e8fd99fa4b31d8ef965eb8d8f1fa1.zip
org.eclipse.jetty.project-840f1470196e8fd99fa4b31d8ef965eb8d8f1fa1.tar.gz
org.eclipse.jetty.project-840f1470196e8fd99fa4b31d8ef965eb8d8f1fa1.tar.bz2
[Bug 391248] fixing localhost checking in statistics servlet
Signed-off-by: Jesse McConnell <jesse.mcconnell@gmail.com>
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java
index f63d3f2..cde02cc 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java
@@ -89,7 +89,7 @@ public class StatisticsServlet extends HttpServlet
}
if (_restrictToLocalhost)
{
- if (!"127.0.0.1".equals(req.getRemoteAddr()))
+ if (!isLoopbackAddress(req.getRemoteAddr()))
{
resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
return;
@@ -111,6 +111,12 @@ public class StatisticsServlet extends HttpServlet
}
+ private boolean isLoopbackAddress(String address)
+ {
+ InetAddress address = InetAddress.getByName(address);
+ return address.isLoopbackAddress();
+ }
+
private void sendXmlResponse(HttpServletResponse response) throws IOException
{
StringBuilder sb = new StringBuilder();