[Bug 391248] fixing localhost checking in statistics servlet
Signed-off-by: Jesse McConnell <jesse.mcconnell@gmail.com>
This commit is contained in:
parent
1910fb8ce4
commit
840f147019
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue