propagate from branch 'i2p.i2p' (head 96b4e09e85e0947d0b9df188f4861664073f07a6)

to branch 'i2p.i2p.zzz.jetty6' (head 4024ef4f6e6c5e4ca6a7803614dc769ca654ac5f)
This commit is contained in:
zzz
2012-01-10 04:06:23 +00:00
27 changed files with 457 additions and 248 deletions

View File

@@ -140,7 +140,8 @@ public class ConfigNetHandler extends FormHandler {
if (!_ratesOnly) {
// IP Settings
String oldUdp = _context.getProperty(UDPTransport.PROP_SOURCES, UDPTransport.DEFAULT_SOURCES);
String oldUdp = _context.getProperty(UDPTransport.PROP_SOURCES,
_context.router().isHidden() ? "hidden" : UDPTransport.DEFAULT_SOURCES);
String oldUHost = _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
if (_udpAutoIP != null) {
String uhost = "";

View File

@@ -8,12 +8,9 @@ import net.i2p.apps.systray.UrlLauncher;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.startup.ClientAppConfig;
import net.i2p.util.Log;
import net.i2p.util.VersionComparator;
import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.event.WrapperControlEvent;
import org.tanukisoftware.wrapper.event.WrapperEvent;
import org.tanukisoftware.wrapper.event.WrapperEventListener;
/**
* Handler to deal with form submissions from the service config form and act
@@ -22,9 +19,9 @@ import org.tanukisoftware.wrapper.event.WrapperEventListener;
*/
public class ConfigServiceHandler extends FormHandler {
private static WrapperEventListener _signalHandler;
private static WrapperListener _wrapperListener;
private static final String PROP_GRACEFUL_HUP = "router.gracefulHUP";
private static final String LISTENER_AVAILABLE = "3.2.0";
/**
* Register two shutdown hooks, one to rekey and/or tell the wrapper we are stopping,
@@ -137,16 +134,19 @@ public class ConfigServiceHandler extends FormHandler {
/**
* Register a handler for signals,
* so we can handle HUP from the wrapper (non-Windows only)
* so we can handle HUP from the wrapper (non-Windows only, wrapper 3.2.0 or higher)
*
* @since 0.8.13
*/
synchronized static void registerSignalHandler(RouterContext ctx) {
if (ctx.hasWrapper() && _signalHandler == null &&
if (ctx.hasWrapper() && _wrapperListener == null &&
!System.getProperty("os.name").startsWith("Win")) {
_signalHandler = new SignalHandler(ctx);
long mask = WrapperEventListener.EVENT_FLAG_CONTROL;
WrapperManager.addWrapperEventListener(_signalHandler, mask);
String wv = System.getProperty("wrapper.version");
if (wv != null && (new VersionComparator()).compare(wv, LISTENER_AVAILABLE) >= 0) {
try {
_wrapperListener = new WrapperListener(ctx);
} catch (Throwable t) {}
}
}
}
@@ -156,55 +156,9 @@ public class ConfigServiceHandler extends FormHandler {
* @since 0.8.13
*/
public synchronized static void unregisterSignalHandler() {
if (_signalHandler != null) {
WrapperManager.removeWrapperEventListener(_signalHandler);
_signalHandler = null;
}
}
/**
* Catch signals.
* The wrapper will potentially forward HUP, USR1, and USR2.
* But USR1 and USR2 are used by the JVM GC and cannot be trapped.
* So we will only get HUP.
*
* @since 0.8.13
*/
private static class SignalHandler implements WrapperEventListener {
private final RouterContext _ctxt;
public SignalHandler(RouterContext ctx) {
_ctxt = ctx;
}
public void fired(WrapperEvent event) {
if (!(event instanceof WrapperControlEvent))
return;
WrapperControlEvent wce = (WrapperControlEvent) event;
Log log = _ctxt.logManager().getLog(ConfigServiceHandler.class);
if (log.shouldLog(Log.WARN))
log.warn("Got signal: " + wce.getControlEventName());
int sig = wce.getControlEvent();
switch (sig) {
case WrapperManager.WRAPPER_CTRL_HUP_EVENT:
if (_ctxt.getBooleanProperty(PROP_GRACEFUL_HUP)) {
wce.consume();
if (!(_ctxt.router().gracefulShutdownInProgress() ||
_ctxt.router().isFinalShutdownInProgress())) {
System.err.println("WARN: Graceful shutdown initiated by SIGHUP");
log.logAlways(Log.WARN, "Graceful shutdown initiated by SIGHUP");
registerWrapperNotifier(_ctxt, Router.EXIT_GRACEFUL, false);
_ctxt.router().shutdownGracefully();
}
} else {
log.log(Log.CRIT, "Hard shutdown initiated by SIGHUP");
// JVM will call ShutdownHook if we don't do it ourselves
//wce.consume();
//registerWrapperNotifier(_ctxt, Router.EXIT_HARD, false);
//_ctxt.router().shutdown(Router.EXIT_HARD);
}
break;
}
if (_wrapperListener != null) {
_wrapperListener.unregister();
_wrapperListener = null;
}
}

View File

@@ -101,6 +101,8 @@ public class SummaryHelper extends HelperBase {
}
private String reachability() {
if (_context.commSystem().isDummy())
return "VM Comm System";
if (_context.router().getUptime() > 60*1000 && (!_context.router().gracefulShutdownInProgress()) &&
!_context.clientManager().isAlive())
return _("ERR-Client Manager I2CP Error - check logs"); // not a router problem but the user should know
@@ -180,6 +182,7 @@ public class SummaryHelper extends HelperBase {
return _context != null &&
_context.netDb().isInitialized() &&
_context.router().getUptime() > 2*60*1000 &&
(!_context.commSystem().isDummy()) &&
_context.commSystem().countActivePeers() <= 0 &&
_context.netDb().getKnownRouters() > 5;
}

View File

@@ -0,0 +1,89 @@
package net.i2p.router.web;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.event.WrapperControlEvent;
import org.tanukisoftware.wrapper.event.WrapperEvent;
import org.tanukisoftware.wrapper.event.WrapperEventListener;
/**
* Listen for events. Requires wrapper 3.2.0 or higher.
* Hides the actual listener so that
* ConfigServiceHandler can have a static field and not die on
* class not found error with wrapper 3.1.1.
*
* @since 0.8.13
*/
class WrapperListener {
private final RouterContext _context;
private final WrapperEventListener _listener;
private static final String PROP_GRACEFUL_HUP = "router.gracefulHUP";
/**
* Wrapper must be 3.2.0 or higher, or will throw class not found error.
* Registers with the wrapper in the constructor.
*/
public WrapperListener(RouterContext ctx) {
_context = ctx;
_listener = new SignalHandler(ctx);
long mask = WrapperEventListener.EVENT_FLAG_CONTROL;
WrapperManager.addWrapperEventListener(_listener, mask);
}
/**
* Unregister the handler for signals
*/
public void unregister() {
WrapperManager.removeWrapperEventListener(_listener);
}
/**
* Catch signals.
* The wrapper will potentially forward HUP, USR1, and USR2.
* But USR1 and USR2 are used by the JVM GC and cannot be trapped.
* So we will only get HUP.
*
* @since 0.8.13
*/
private static class SignalHandler implements WrapperEventListener {
private final RouterContext _ctxt;
public SignalHandler(RouterContext ctx) {
_ctxt = ctx;
}
public void fired(WrapperEvent event) {
if (!(event instanceof WrapperControlEvent))
return;
WrapperControlEvent wce = (WrapperControlEvent) event;
Log log = _ctxt.logManager().getLog(ConfigServiceHandler.class);
if (log.shouldLog(Log.WARN))
log.warn("Got signal: " + wce.getControlEventName());
int sig = wce.getControlEvent();
switch (sig) {
case WrapperManager.WRAPPER_CTRL_HUP_EVENT:
if (_ctxt.getBooleanPropertyDefaultTrue(PROP_GRACEFUL_HUP)) {
wce.consume();
if (!(_ctxt.router().gracefulShutdownInProgress() ||
_ctxt.router().isFinalShutdownInProgress())) {
System.err.println("WARN: Graceful shutdown initiated by SIGHUP");
log.logAlways(Log.WARN, "Graceful shutdown initiated by SIGHUP");
ConfigServiceHandler.registerWrapperNotifier(_ctxt, Router.EXIT_GRACEFUL, false);
_ctxt.router().shutdownGracefully();
}
} else {
log.log(Log.CRIT, "Hard shutdown initiated by SIGHUP");
// JVM will call ShutdownHook if we don't do it ourselves
//wce.consume();
//registerWrapperNotifier(_ctxt, Router.EXIT_HARD, false);
//_ctxt.router().shutdown(Router.EXIT_HARD);
}
break;
}
}
}
}

View File

@@ -157,6 +157,7 @@
<%=intl._("The router is currently testing whether your UDP port is firewalled.")%>
<li class="tidylist"><b><%=intl._("Hidden")%></b> -
<%=intl._("The router is not configured to publish its address, therefore it does not expect incoming connections.")%>
<%=intl._("Hidden mode is automatically enabled for added protection in certain countries.")%>
<li class="tidylist"><b><%=intl._("WARN - Firewalled and Fast")%></b> -
<%=intl._("You have configured I2P to share more than 128KBps of bandwidth, but you are firewalled.")%>
<%=intl._("While I2P will work fine in this configuration, if you really have over 128KBps of bandwidth to share, it will be much more helpful to the network if you open your firewall.")%>

View File

@@ -55,9 +55,14 @@
<p>
<b>I2P version:</b> <%=net.i2p.router.RouterVersion.FULL_VERSION%><br>
<b>Java version:</b> <%=System.getProperty("java.vendor")%> <%=System.getProperty("java.version")%> (<%=System.getProperty("java.runtime.name")%> <%=System.getProperty("java.runtime.version")%>)<br>
<b>Wrapper version:</b> <%=System.getProperty("wrapper.version", "none")%><br>
<jsp:useBean class="net.i2p.router.web.LogsHelper" id="logsHelper" scope="request" />
<jsp:setProperty name="logsHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<b>Server version:</b> <jsp:getProperty name="logsHelper" property="jettyVersion" /><br>
<b>Platform:</b> <%=System.getProperty("os.name")%> <%=System.getProperty("os.arch")%> <%=System.getProperty("os.version")%><br>
<b>Processor:</b> <%=net.i2p.util.NativeBigInteger.cpuModel()%> (<%=net.i2p.util.NativeBigInteger.cpuType()%>)<br>
<b>Jbigi:</b> <%=net.i2p.util.NativeBigInteger.loadStatus()%><br>
<b>Encoding:</b> <%=System.getProperty("file.encoding")%></p>
<b>Encoding:</b> <%=System.getProperty("file.encoding")%><br>
<b>Charset:</b> <%=java.nio.charset.Charset.defaultCharset().name()%></p>
<p><%=intl._("Note that system information, log timestamps, and log messages may provide clues to your location; please review everything you include in a bug report.")%></p>
</div></body></html>