From 75652fc2c404e9a97719bf1a1dbecc6a5e95d2f4 Mon Sep 17 00:00:00 2001 From: jrandom Date: Sat, 31 Jul 2004 03:34:00 +0000 Subject: [PATCH] config clients handler implemented --- .../i2p/router/web/ConfigClientsHandler.java | 74 +++++++++++++++++++ apps/routerconsole/jsp/configclients.jsp | 9 ++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java new file mode 100644 index 000000000..b44b29bc9 --- /dev/null +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java @@ -0,0 +1,74 @@ +package net.i2p.router.web; + +import net.i2p.router.ClientTunnelSettings; + +/** + * Handler to deal with form submissions from the client config form and act + * upon the values. + * + */ +public class ConfigClientsHandler extends FormHandler { + private String _numClients; + private String _numTunnels; + private String _numHops; + private boolean _shouldSave; + + public void ConfigNetHandler() { + _shouldSave = false; + } + + protected void processForm() { + if (_shouldSave) { + saveChanges(); + } else { + // noop + } + } + + public void setShouldsave(String moo) { _shouldSave = true; } + + public void setClientcount(String num) { + _numClients = (num != null ? num.trim(): null); + } + public void setTunnelcount(String num) { + _numTunnels = (num != null ? num.trim() : null); + } + public void setTunneldepth(String num) { + _numHops = (num != null ? num.trim() : null); + } + + /** + * The user made changes to the network config and wants to save them, so + * lets go ahead and do so. + * + */ + private void saveChanges() { + boolean saveRequired = false; + + if ( (_numClients != null) && (_numClients.length() > 0) ) { + _context.router().setConfigSetting("router.targetClients", _numClients); + addFormNotice("Updating estimated number of clients to " + _numClients); + saveRequired = true; + } + + if ( (_numTunnels != null) && (_numTunnels.length() > 0) ) { + _context.router().setConfigSetting(ClientTunnelSettings.PROP_NUM_INBOUND, _numTunnels); + addFormNotice("Updating default number of tunnels per client to " + _numTunnels); + saveRequired = true; + } + + if ( (_numHops != null) && (_numHops.length() > 0) ) { + _context.router().setConfigSetting(ClientTunnelSettings.PROP_DEPTH_INBOUND, _numHops); + addFormNotice("Updating default tunnel length to " + _numHops); + saveRequired = true; + } + + if (saveRequired) { + boolean saved = _context.router().saveConfig(); + if (saved) + addFormNotice("Configuration saved successfully"); + else + addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs"); + } + } +} diff --git a/apps/routerconsole/jsp/configclients.jsp b/apps/routerconsole/jsp/configclients.jsp index e1f0db493..9ec0afbba 100644 --- a/apps/routerconsole/jsp/configclients.jsp +++ b/apps/routerconsole/jsp/configclients.jsp @@ -15,6 +15,13 @@
<%@include file="confignav.jsp" %> + + + + " /> + + +
Estimated number of clients/destinations:
@@ -23,7 +30,7 @@ Default number of hops per tunnel:

- +