* I2PTunnel Edit Pages:

- Change default length to 2+0
      - Cleanup helper code
      - Stub out the following new options (C=client, S=server):
        + Access list (S)
        + Certificate type (S)
        + Encrypted LeaseSet (S)
        + New dest on idle restart (C)
        + Tunnel closure on idle (C)
        + Tunnel reduction on idle (C,S)
This commit is contained in:
zzz
2009-01-20 17:24:28 +00:00
parent 6be54942ec
commit c620420a6f
3 changed files with 276 additions and 110 deletions

View File

@ -8,9 +8,12 @@ package net.i2p.i2ptunnel.web;
* *
*/ */
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.i2p.i2ptunnel.TunnelController; import net.i2p.i2ptunnel.TunnelController;
@ -82,119 +85,100 @@ public class EditBean extends IndexBean {
} }
public boolean shouldDelay(int tunnel) { public boolean shouldDelay(int tunnel) {
TunnelController tun = getController(tunnel); return getProperty(tunnel, "i2p.streaming.connectDelay", 0) > 0;
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null) {
String delay = opts.getProperty("i2p.streaming.connectDelay");
if ( (delay == null) || ("0".equals(delay)) )
return false;
else
return true;
} else {
return false;
}
} else {
return false;
}
} }
public boolean isInteractive(int tunnel) { public boolean isInteractive(int tunnel) {
TunnelController tun = getController(tunnel); return getProperty(tunnel, "i2p.streaming.maxWindowSize", 128) == 12;
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null) {
String wsiz = opts.getProperty("i2p.streaming.maxWindowSize");
if ( (wsiz == null) || (!"1".equals(wsiz)) )
return false;
else
return true;
} else {
return false;
}
} else {
return false;
}
} }
public int getTunnelDepth(int tunnel, int defaultLength) { public int getTunnelDepth(int tunnel, int defaultLength) {
TunnelController tun = getController(tunnel); return getProperty(tunnel, "inbound.length", defaultLength);
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null) {
String len = opts.getProperty("inbound.length");
if (len == null) return defaultLength;
try {
return Integer.parseInt(len);
} catch (NumberFormatException nfe) {
return defaultLength;
}
} else {
return defaultLength;
}
} else {
return defaultLength;
}
} }
public int getTunnelQuantity(int tunnel, int defaultQuantity) { public int getTunnelQuantity(int tunnel, int defaultQuantity) {
TunnelController tun = getController(tunnel); return getProperty(tunnel, "inbound.quantity", defaultQuantity);
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null) {
String len = opts.getProperty("inbound.quantity");
if (len == null) return defaultQuantity;
try {
return Integer.parseInt(len);
} catch (NumberFormatException nfe) {
return defaultQuantity;
}
} else {
return defaultQuantity;
}
} else {
return defaultQuantity;
}
} }
public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity) { public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity) {
TunnelController tun = getController(tunnel); return getProperty(tunnel, "inbound.backupQuantity", defaultBackupQuantity);
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null) {
String len = opts.getProperty("inbound.backupQuantity");
if (len == null) return defaultBackupQuantity;
try {
return Integer.parseInt(len);
} catch (NumberFormatException nfe) {
return defaultBackupQuantity;
}
} else {
return defaultBackupQuantity;
}
} else {
return defaultBackupQuantity;
}
} }
public int getTunnelVariance(int tunnel, int defaultVariance) { public int getTunnelVariance(int tunnel, int defaultVariance) {
return getProperty(tunnel, "inbound.lengthVariance", defaultVariance);
}
public boolean getReduce(int tunnel) {
return false;
}
public int getReduceCount(int tunnel) {
return getProperty(tunnel, "inbound.reduceQuantity", 1);
}
public int getReduceTime(int tunnel) {
return getProperty(tunnel, "reduceIdleTime", 20);
}
public int getCert(int tunnel) {
return 0;
}
public int getEffort(int tunnel) {
return 23;
}
public String getSigner(int tunnel) {
return "";
}
public boolean getEncrypt(int tunnel) {
return false;
}
public String getEncryptKey(int tunnel) {
return getProperty(tunnel, "encryptKey", "");
}
public boolean getAccess(int tunnel) {
return false;
}
public String getAccessList(int tunnel) {
return getProperty(tunnel, "accessList", "");
}
public boolean getClose(int tunnel) {
return false;
}
public boolean getNewDest(int tunnel) {
return false;
}
private int getProperty(int tunnel, String prop, int def) {
TunnelController tun = getController(tunnel); TunnelController tun = getController(tunnel);
if (tun != null) { if (tun != null) {
Properties opts = getOptions(tun); Properties opts = getOptions(tun);
if (opts != null) { if (opts != null) {
String len = opts.getProperty("inbound.lengthVariance"); String s = opts.getProperty(prop);
if (len == null) return defaultVariance; if (s == null) return def;
try { try {
return Integer.parseInt(len); return Integer.parseInt(s);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {}
return defaultVariance;
}
} else {
return defaultVariance;
} }
} else {
return defaultVariance;
} }
return def;
}
private String getProperty(int tunnel, String prop, String def) {
TunnelController tun = getController(tunnel);
if (tun != null) {
Properties opts = getOptions(tun);
if (opts != null)
return opts.getProperty(prop, def);
}
return def;
} }
public String getI2CPHost(int tunnel) { public String getI2CPHost(int tunnel) {
@ -213,6 +197,14 @@ public class EditBean extends IndexBean {
return "7654"; return "7654";
} }
private static final String noShowProps[] = {
"inbound.length", "outbound.length", "inbound.lengthVariance", "outbound.lengthVariance",
"inbound.backupQuantity", "outbound.backupQuantity", "inbound.quantity", "outbound.quantity",
"inbound.nickname", "outbound.nickname", "i2p.streaming.connectDelay", "i2p.streaming.maxWindowSize"
};
private static final Set noShowSet = new HashSet(noShowProps.length);
static { noShowSet.addAll(Arrays.asList(noShowProps)); }
public String getCustomOptions(int tunnel) { public String getCustomOptions(int tunnel) {
TunnelController tun = getController(tunnel); TunnelController tun = getController(tunnel);
if (tun != null) { if (tun != null) {
@ -222,19 +214,9 @@ public class EditBean extends IndexBean {
int i = 0; int i = 0;
for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) { for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next(); String key = (String)iter.next();
if (noShowSet.contains(key))
continue;
String val = opts.getProperty(key); String val = opts.getProperty(key);
if ("inbound.length".equals(key)) continue;
if ("outbound.length".equals(key)) continue;
if ("inbound.lengthVariance".equals(key)) continue;
if ("outbound.lengthVariance".equals(key)) continue;
if ("inbound.backupQuantity".equals(key)) continue;
if ("outbound.backupQuantity".equals(key)) continue;
if ("inbound.quantity".equals(key)) continue;
if ("outbound.quantity".equals(key)) continue;
if ("inbound.nickname".equals(key)) continue;
if ("outbound.nickname".equals(key)) continue;
if ("i2p.streaming.connectDelay".equals(key)) continue;
if ("i2p.streaming.maxWindowSize".equals(key)) continue;
if (i != 0) buf.append(' '); if (i != 0) buf.append(' ');
buf.append(key).append('=').append(val); buf.append(key).append('=').append(val);
i++; i++;

View File

@ -207,10 +207,10 @@
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox"> <select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
<% int tunnelVariance = editBean.getTunnelVariance(curTunnel, -1); <% int tunnelVariance = editBean.getTunnelVariance(curTunnel, -1);
%><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option> %><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option>
<option value="-1"<%=(tunnelVariance == -1 ? " selected=\"selected\"" : "") %>>+/- 0-1 hop variance (standard randomisation, standard performance)</option>
<option value="-2"<%=(tunnelVariance == -2 ? " selected=\"selected\"" : "") %>>+/- 0-2 hop variance (high randomisation, variable performance)</option>
<option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option> <option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option>
<option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option> <option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option>
<option value="-1"<%=(tunnelVariance == -1 ? " selected=\"selected\"" : "") %>>+/- 0-1 hop variance (standard randomisation, standard performance)</option>
<option value="-2"<%=(tunnelVariance == -2 ? " selected=\"selected\"" : "") %>>+/- 0-2 hop variance (not recommended)</option>
<% if (tunnelVariance > 2 || tunnelVariance < -2) { <% if (tunnelVariance > 2 || tunnelVariance < -2) {
%> <option value="<%=tunnelVariance%>" selected="selected"><%= (tunnelVariance > 2 ? "+ " : "+/- ") %>0-<%=tunnelVariance%> hop variance</option> %> <option value="<%=tunnelVariance%>" selected="selected"><%= (tunnelVariance > 2 ? "+ " : "+/- ") %>0-<%=tunnelVariance%> hop variance</option>
<% } <% }
@ -270,6 +270,62 @@
<hr /> <hr />
</div> </div>
<div id="optionsField" class="rowItem">
<label for="reduce" accesskey="c">
<span class="accessKey">C</span>lose tunnels when idle:
</label>
</div>
<div id="portField" class="rowItem">
<label for="access" accesskey="c">
Enable:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="close" title="Close Tunnels"<%=(editBean.getClose(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="portField" class="rowItem">
<label for="access" accesskey="c">
Generate New Destination Keys On Reopen:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="newDest" title="New Destination"<%=(editBean.getNewDest(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="portField" class="rowItem">
<label for="reduceTime" accesskey="c">
Reduce when idle (minutes):
</label>
<input type="text" id="port" name="reduceTime" size="4" maxlength="4" title="Reduced Tunnel Idle Time" value="<%=editBean.getReduceTime(curTunnel)%>" class="freetext" />
</div>
<div class="subdivider">
<hr />
</div>
<div id="optionsField" class="rowItem">
<label for="reduce" accesskey="d">
Re<span class="accessKey">d</span>uce tunnel quantity when idle:
</label>
</div>
<div id="portField" class="rowItem">
<label for="access" accesskey="d">
Enable:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="reduce" title="Reduce Tunnels"<%=(editBean.getReduce(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="portField" class="rowItem">
<label for="reduceCount" accesskey="d">
Reduced tunnel count:
</label>
<input type="text" id="port" name="reduceCount" size="1" maxlength="1" title="Reduced Tunnel Count" value="<%=editBean.getReduceCount(curTunnel)%>" class="freetext" />
</div>
<div id="portField" class="rowItem">
<label for="reduceTime" accesskey="d">
Reduce when idle (minutes):
</label>
<input type="text" id="port" name="reduceTime" size="4" maxlength="4" title="Reduced Tunnel Idle Time" value="<%=editBean.getReduceTime(curTunnel)%>" class="freetext" />
</div>
<div class="subdivider">
<hr />
</div>
<div id="customOptionsField" class="rowItem"> <div id="customOptionsField" class="rowItem">
<label for="customOptions" accesskey="u"> <label for="customOptions" accesskey="u">
C<span class="accessKey">u</span>stom options: C<span class="accessKey">u</span>stom options:
@ -284,8 +340,10 @@
<div class="header"></div> <div class="header"></div>
<div class="footer"> <div class="footer">
<div class="toolbox"> <div class="toolbox">
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted</span>
<input type="hidden" value="true" name="removeConfirm" /> <input type="hidden" value="true" name="removeConfirm" />
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button><button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button> <button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button>
<button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -177,12 +177,12 @@
<span class="accessKey">V</span>ariance: <span class="accessKey">V</span>ariance:
</label> </label>
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox"> <select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
<% int tunnelVariance = editBean.getTunnelVariance(curTunnel, -1); <% int tunnelVariance = editBean.getTunnelVariance(curTunnel, 0);
%><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option> %><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option>
<option value="-1"<%=(tunnelVariance == -1 ? " selected=\"selected\"" : "") %>>+/- 0-1 hop variance (standard randomisation, standard performance)</option>
<option value="-2"<%=(tunnelVariance == -2 ? " selected=\"selected\"" : "") %>>+/- 0-2 hop variance (high randomisation, variable performance)</option>
<option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option> <option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option>
<option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option> <option value="2"<%=(tunnelVariance == 2 ? " selected=\"selected\"" : "") %>>+ 0-2 hop variance (high additive randomisation, subtractive performance)</option>
<option value="-1"<%=(tunnelVariance == -1 ? " selected=\"selected\"" : "") %>>+/- 0-1 hop variance (standard randomisation, standard performance)</option>
<option value="-2"<%=(tunnelVariance == -2 ? " selected=\"selected\"" : "") %>>+/- 0-2 hop variance (not recommended)</option>
<% if (tunnelVariance > 2 || tunnelVariance < -2) { <% if (tunnelVariance > 2 || tunnelVariance < -2) {
%> <option value="<%=tunnelVariance%>" selected="selected"><%= (tunnelVariance > 2 ? "+ " : "+/- ") %>0-<%=tunnelVariance%> hop variance</option> %> <option value="<%=tunnelVariance%>" selected="selected"><%= (tunnelVariance > 2 ? "+ " : "+/- ") %>0-<%=tunnelVariance%> hop variance</option>
<% } <% }
@ -242,6 +242,130 @@
<hr /> <hr />
</div> </div>
<div id="optionsField" class="rowItem">
<label for="encrypt" accesskey="e">
<span class="accessKey">E</span>ncrypt Leaseset:
</label>
</div>
<div id="portField" class="rowItem">
<label for="encrypt" accesskey="e">
Enable:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="encrypt" title="Encrypt LeaseSet"<%=(editBean.getEncrypt(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="hostField" class="rowItem">
<label for="encrypt" accesskey="e">
Leaseset Encryption Key:
</label>
<input type="text" id="hostField" name="encryptKey" size="60" title="Encrypt Key" value="<%=editBean.getEncryptKey(curTunnel)%>" class="freetext" />
<span class="comment">(Users will require this key)</span>
</div>
<div class="subdivider">
<hr />
</div>
<div id="optionsField" class="rowItem">
<label for="access" accesskey="s">
Restricted Acce<span class="accessKey">s</span>s List:
</label>
</div>
<div id="portField" class="rowItem">
<label for="access" accesskey="s">
Enable:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="access" title="Enable Access List"<%=(editBean.getAccess(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="hostField" class="rowItem">
<label for="accessList" accesskey="s">
Access List:
</label>
<textarea rows="2" cols="60" id="hostField" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea>
<span class="comment">(Restrict to these clients only)</span>
</div>
<div class="subdivider">
<hr />
</div>
<div id="optionsField" class="rowItem">
<label for="reduce" accesskey="d">
Re<span class="accessKey">d</span>uce tunnel quantity when idle:
</label>
</div>
<div id="portField" class="rowItem">
<label for="access" accesskey="d">
Enable:
</label>
<input value="1" type="checkbox" id="startOnLoad" name="reduce" title="Reduce Tunnels"<%=(editBean.getReduce(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
</div>
<div id="portField" class="rowItem">
<label for="reduceCount" accesskey="d">
Reduced tunnel count:
</label>
<input type="text" id="port" name="reduceCount" size="1" maxlength="1" title="Reduced Tunnel Count" value="<%=editBean.getReduceCount(curTunnel)%>" class="freetext" />
</div>
<div id="portField" class="rowItem">
<label for="reduceTime" accesskey="d">
Reduce when idle (minutes):
</label>
<input type="text" id="port" name="reduceTime" size="4" maxlength="4" title="Reduced Tunnel Idle Time" value="<%=editBean.getReduceTime(curTunnel)%>" class="freetext" />
</div>
<div class="subdivider">
<hr />
</div>
<div id="tunnelOptionsField" class="rowItem">
<label for="cert" accesskey="c">
<span class="accessKey">C</span>ertificate type:
</label>
</div>
<div id="hostField" class="rowItem">
<div id="portField" class="rowItem">
<label>None</label>
<input value="0" type="radio" id="startOnLoad" name="cert" title="No Certificate"<%=(editBean.getCert(curTunnel)==0 ? " checked=\"checked\"" : "")%> class="tickbox" />
<span class="comment"></span>
</div>
<div id="portField" class="rowItem">
<label>Hashcash (effort)</label>
<input value="1" type="radio" id="startOnLoad" name="cert" title="Hashcash Certificate"<%=(editBean.getCert(curTunnel)==1 ? " checked=\"checked\"" : "")%> class="tickbox" />
<input type="text" id="port" name="effort" size="2" title="Hashcash Effort" value="<%=editBean.getEffort(curTunnel)%>" class="freetext" />
</div>
</div>
<div id="portField" class="rowItem">
<label for="force" accesskey="c">
Estimate Hashcash Calc Time:
</label>
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Estimate Calculation Time" title="Estimate Calculation Time">Estimate</button>
</div>
<div id="hostField" class="rowItem">
<div id="portField" class="rowItem">
<label>Hidden</label>
<input value="2" type="radio" id="startOnLoad" name="cert" title="Hidden Certificate"<%=(editBean.getCert(curTunnel)==2 ? " checked=\"checked\"" : "")%> class="tickbox" />
<span class="comment"></span>
</div>
<div id="portField" class="rowItem">
<label for="signer" accesskey="c">
Signed (signed by):
</label>
<input value="3" type="radio" id="startOnLoad" name="cert" title="Signed Certificate"<%=(editBean.getCert(curTunnel)==3 ? " checked=\"checked\"" : "")%> class="tickbox" />
<input type="text" id="port" name="signer" size="50" title="Cert Signer" value="<%=editBean.getSigner(curTunnel)%>" class="freetext" />
<span class="comment"></span>
</div>
</div>
<div id="portField" class="rowItem">
<label for="force" accesskey="c">
Modify Certificate:
</label>
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Modify Cert Now" title="Force New Cert Now">Modify</button>
<span class="comment">(Tunnel must be stopped first)</span>
</div>
<div class="subdivider">
<hr />
</div>
<div id="customOptionsField" class="rowItem"> <div id="customOptionsField" class="rowItem">
<label for="customOptions" accesskey="u"> <label for="customOptions" accesskey="u">
C<span class="accessKey">u</span>stom options: C<span class="accessKey">u</span>stom options:
@ -256,8 +380,10 @@
<div class="header"></div> <div class="header"></div>
<div class="footer"> <div class="footer">
<div class="toolbox"> <div class="toolbox">
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted</span>
<input type="hidden" value="true" name="removeConfirm" /> <input type="hidden" value="true" name="removeConfirm" />
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button><button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button> <button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button>
<button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button>
</div> </div>
</div> </div>
</div> </div>