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 f63d3f291d2..cde02cc8ffa 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();