* new configservice.jsp page that shuts down the router (and has hooks for a few other things)

* new safer way of shutting down the router per discussions with oOo (dealing with a graceful
shutdown where the user updates their config before the shutdown is complete, etc)
* graceful shutdown implemented in the router - shutdownGracefully(), cancelGracefulShutdown(), shutdownInProgress()
This commit is contained in:
jrandom
2004-08-23 07:33:14 +00:00
committed by zzz
parent e9310ee8dd
commit 9f7320fa67
5 changed files with 180 additions and 3 deletions

View File

@ -0,0 +1,46 @@
package net.i2p.router.web;
import net.i2p.router.ClientTunnelSettings;
/**
* Handler to deal with form submissions from the service config form and act
* upon the values.
*
*/
public class ConfigServiceHandler extends FormHandler {
private String _action;
private String _nonce;
public void ConfigNetHandler() {
_action = null;
_nonce = null;
}
protected void processForm() {
if (_action == null) return;
if (_nonce == null) {
addFormError("You trying to mess with me? Huh? Are you?");
return;
}
String nonce = System.getProperty(ConfigServiceHandler.class.getName() + ".nonce");
String noncePrev = System.getProperty(ConfigServiceHandler.class.getName() + ".noncePrev");
if ( (!_nonce.equals(nonce)) && (!_nonce.equals(noncePrev)) ) {
addFormError("Invalid nonce? Hmmm, someone is spoofing you. prev=["+ noncePrev + "] nonce=[" + nonce + "] param=[" + _nonce + "]");
return;
}
if ("Shutdown gracefully".equals(_action)) {
_context.router().shutdownGracefully();
addFormNotice("Graceful shutdown initiated");
} else if ("Shutdown immediately".equals(_action)) {
_context.router().shutdown();
addFormNotice("Shutdown immediately! boom bye bye bad bwoy");
} else if ("Cancel graceful shutdown".equals(_action)) {
_context.router().cancelGracefulShutdown();
addFormNotice("Graceful shutdown cancelled");
} else {
addFormNotice("Blah blah blah. whatever. I'm not going to " + _action);
}
}
public void setAction(String action) { _action = action; }
public void setNonce(String nonce) { _nonce = nonce; }
}

View File

@ -1,5 +1,7 @@
<h4><% if (request.getRequestURI().indexOf("config.jsp") != -1) {
%>Network | <% } else { %><a href="config.jsp">Network</a> | <% }
if (request.getRequestURI().indexOf("configservice.jsp") != -1) {
%>Service | <% } else { %><a href="configservice.jsp">Service</a> | <% }
if (request.getRequestURI().indexOf("configclients.jsp") != -1) {
%>Clients | <% } else { %><a href="configclients.jsp">Clients</a> | <% }
if (request.getRequestURI().indexOf("configlogging.jsp") != -1) {

View File

@ -0,0 +1,55 @@
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Router Console - config clients</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head><body>
<%@include file="nav.jsp" %>
<%@include file="summary.jsp" %>
<div class="main" id="main">
<%@include file="confignav.jsp" %>
<jsp:useBean class="net.i2p.router.web.ConfigServiceHandler" id="formhandler" scope="request" />
<jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
<i><jsp:getProperty name="formhandler" property="notices" /></i>
<form action="configservice.jsp" method="POST">
<% String prev = System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce");
if (prev != null) System.setProperty("net.i2p.router.web.ConfigServiceHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.ConfigServiceHandler.nonce", new java.util.Random().nextLong()+""); %>
<input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce")%>" />
<h4>Shutdown the router</h4>
Graceful shutdown lets the router satisfy the agreements it has already made
before shutting down, but may take a few minutes. If you need to kill the
router immediately, that option is available as well.<br />
<input type="submit" name="action" value="Shutdown gracefully" />
<input type="submit" name="action" value="Shutdown immediately" />
<input type="submit" name="action" value="Cancel graceful shutdown" />
<h4>Systray integration</h4>
On the windows platform, there is a small application to sit in the system
tray, allowing you to view the router's status (later on, I2P client applications
will be able to integrate their own functionality into the system tray as well).
If you are on windows, you can either enable or disable that icon here. <br />
<input type="submit" name="action" value="Enable systray icon" />
<input type="submit" name="action" value="Disable systray icon" />
<h4>Run on startup</h4>
On the windows platform, you can control whether I2P is run on startup or not by
selecting one of the following options - I2P will install (or remove) a service
accordingly. On *nix machines, you need root permissions to add a script
to be run on startup (we hope you know better than to run I2P as root ;). To
have I2P run (or not run) at startup on *nix machines, please run
<code>install_i2p_service_unix</code> or <code>install_i2p_service_unix</code>
as root.<br />
<input type="submit" name="action" value="Run I2P on startup" />
<input type="submit" name="action" value="Don't run I2P on startup" />
</form>
</div>
</body>
</html>