Merge branch 'jetty-7' into jetty-8

This commit is contained in:
Jesse McConnell 2013-01-29 15:51:56 -06:00
commit f0c6b9bc82
2 changed files with 21 additions and 4 deletions

View File

@ -68,7 +68,8 @@
#
# JETTY_RUN
# Where the jetty.pid file should be stored. It defaults to the
# first available of /var/run, /usr/var/run, and /tmp if not set.
# first available of /var/run, /usr/var/run, JETTY_HOME and /tmp
# if not set.
#
# JETTY_PID
# The Jetty PID file, defaults to $JETTY_RUN/jetty.pid

View File

@ -22,6 +22,8 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@ -89,7 +91,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 +113,20 @@ public class StatisticsServlet extends HttpServlet
}
private boolean isLoopbackAddress(String address)
{
try
{
InetAddress addr = InetAddress.getByName(address);
return addr.isLoopbackAddress();
}
catch (UnknownHostException e )
{
LOG.warn("Warning: attempt to access statistics servlet from " + address, e);
return false;
}
}
private void sendXmlResponse(HttpServletResponse response) throws IOException
{
StringBuilder sb = new StringBuilder();
@ -132,7 +148,7 @@ public class StatisticsServlet extends HttpServlet
sb.append(" <dispatchedActive>").append(_statsHandler.getDispatchedActive()).append("</dispatchedActive>\n");
sb.append(" <dispatchedActiveMax>").append(_statsHandler.getDispatchedActiveMax()).append("</dispatchedActiveMax>\n");
sb.append(" <dispatchedTimeTotal>").append(_statsHandler.getDispatchedTimeTotal()).append("</dispatchedTimeTotal>\n");
sb.append(" <dispatchedTimeMean").append(_statsHandler.getDispatchedTimeMean()).append("</dispatchedTimeMean>\n");
sb.append(" <dispatchedTimeMean>").append(_statsHandler.getDispatchedTimeMean()).append("</dispatchedTimeMean>\n");
sb.append(" <dispatchedTimeMax>").append(_statsHandler.getDispatchedTimeMax()).append("</dispatchedTimeMax>\n");
sb.append(" <dispatchedTimeStdDev").append(_statsHandler.getDispatchedTimeStdDev()).append("</dispatchedTimeStdDev>\n");
@ -201,7 +217,7 @@ public class StatisticsServlet extends HttpServlet
{
sb.append("Statistics gathering started ").append(connector.getStatsOnMs()).append("ms ago").append("<br />\n");
sb.append("Total connections: ").append(connector.getConnections()).append("<br />\n");
sb.append("Current connections open: ").append(connector.getConnectionsOpen());
sb.append("Current connections open: ").append(connector.getConnectionsOpen()).append("<br />\n");
sb.append("Max concurrent connections open: ").append(connector.getConnectionsOpenMax()).append("<br />\n");
sb.append("Total connections duration: ").append(connector.getConnectionsDurationTotal()).append("<br />\n");
sb.append("Mean connection duration: ").append(connector.getConnectionsDurationMean()).append("<br />\n");