[Bug 391248] fixing localhost checking in statistics servlet

Signed-off-by: Jesse McConnell <jesse.mcconnell@gmail.com>
This commit is contained in:
KARASZI István 2012-10-08 13:33:16 +02:00 committed by Jesse McConnell
parent 1910fb8ce4
commit 840f147019
1 changed files with 7 additions and 1 deletions

View File

@ -89,7 +89,7 @@ public class StatisticsServlet extends HttpServlet
} }
if (_restrictToLocalhost) if (_restrictToLocalhost)
{ {
if (!"127.0.0.1".equals(req.getRemoteAddr())) if (!isLoopbackAddress(req.getRemoteAddr()))
{ {
resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
return; 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 private void sendXmlResponse(HttpServletResponse response) throws IOException
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();