diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java index 2a684c7e40..aee75e0215 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java @@ -429,22 +429,46 @@ public class GeneralHelper { return getProperty(tunnel, "i2p.streaming.maxWindowSize", 128) == 16; } + /** Inbound or both in/out */ public int getTunnelDepth(int tunnel, int defaultLength) { return getProperty(tunnel, "inbound.length", defaultLength); } + /** Inbound or both in/out */ public int getTunnelQuantity(int tunnel, int defaultQuantity) { return getProperty(tunnel, "inbound.quantity", defaultQuantity); } + /** Inbound or both in/out */ public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity) { return getProperty(tunnel, "inbound.backupQuantity", defaultBackupQuantity); } + /** Inbound or both in/out */ public int getTunnelVariance(int tunnel, int defaultVariance) { return getProperty(tunnel, "inbound.lengthVariance", defaultVariance); } + /** @since 0.9.33 */ + public int getTunnelDepthOut(int tunnel, int defaultLength) { + return getProperty(tunnel, "outbound.length", defaultLength); + } + + /** @since 0.9.33 */ + public int getTunnelQuantityOut(int tunnel, int defaultQuantity) { + return getProperty(tunnel, "outbound.quantity", defaultQuantity); + } + + /** @since 0.9.33 */ + public int getTunnelBackupQuantityOut(int tunnel, int defaultBackupQuantity) { + return getProperty(tunnel, "outbound.backupQuantity", defaultBackupQuantity); + } + + /** @since 0.9.33 */ + public int getTunnelVarianceOut(int tunnel, int defaultVariance) { + return getProperty(tunnel, "outbound.lengthVariance", defaultVariance); + } + public boolean getReduceOnIdle(int tunnel, boolean def) { return getBooleanProperty(tunnel, "i2cp.reduceOnIdle", def); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java index d381939a11..e53a28ce56 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java @@ -50,6 +50,10 @@ public class TunnelConfig { // -2 or higher is valid private int _tunnelVariance = -3; private int _tunnelBackupQuantity = -1; + private int _tunnelDepthOut = -1; + private int _tunnelQuantityOut = -1; + private int _tunnelVarianceOut = -3; + private int _tunnelBackupQuantityOut = -1; private boolean _connectDelay; private String _customOptions; private String _proxyList; @@ -104,22 +108,63 @@ public class TunnelConfig { public void setClientPort(String port) { _i2cpPort = (port != null ? port.trim() : null); } - /** how many hops to use for inbound tunnels */ + + /** how many hops to use for inbound tunnels + * In or both in/out + */ public void setTunnelDepth(int tunnelDepth) { _tunnelDepth = tunnelDepth; } - /** how many parallel inbound tunnels to use */ + + /** how many parallel inbound tunnels to use + * In or both in/out + */ public void setTunnelQuantity(int tunnelQuantity) { _tunnelQuantity = tunnelQuantity; } - /** how much randomisation to apply to the depth of tunnels */ + + /** how much randomisation to apply to the depth of tunnels + * In or both in/out + */ public void setTunnelVariance(int tunnelVariance) { _tunnelVariance = tunnelVariance; } - /** how many tunnels to hold in reserve to guard against failures */ + + /** how many tunnels to hold in reserve to guard against failures + * In or both in/out + */ public void setTunnelBackupQuantity(int tunnelBackupQuantity) { _tunnelBackupQuantity = tunnelBackupQuantity; } + + /** how many hops to use for outbound tunnels + * @since 0.9.33 + */ + public void setTunnelDepthOut(int tunnelDepth) { + _tunnelDepthOut = tunnelDepth; + } + + /** how many parallel outbound tunnels to use + * @since 0.9.33 + */ + public void setTunnelQuantityOut(int tunnelQuantity) { + _tunnelQuantityOut = tunnelQuantity; + } + + /** how much randomisation to apply to the depth of tunnels + * @since 0.9.33 + */ + public void setTunnelVarianceOut(int tunnelVariance) { + _tunnelVarianceOut = tunnelVariance; + } + + /** how many tunnels to hold in reserve to guard against failures + * @since 0.9.33 + */ + public void setTunnelBackupQuantityOut(int tunnelBackupQuantity) { + _tunnelBackupQuantityOut = tunnelBackupQuantity; + } + /** what I2P session overrides should be used */ public void setCustomOptions(String customOptions) { _customOptions = (customOptions != null ? customOptions.trim() : null); @@ -840,19 +885,27 @@ public class TunnelConfig { public void updateTunnelQuantities(Properties config) { if (_tunnelQuantity >= 0) { config.setProperty("option.inbound.quantity", Integer.toString(_tunnelQuantity)); - config.setProperty("option.outbound.quantity", Integer.toString(_tunnelQuantity)); + if (_tunnelQuantityOut < 0) + _tunnelQuantityOut = _tunnelQuantity; + config.setProperty("option.outbound.quantity", Integer.toString(_tunnelQuantityOut)); } if (_tunnelDepth >= 0) { config.setProperty("option.inbound.length", Integer.toString(_tunnelDepth)); - config.setProperty("option.outbound.length", Integer.toString(_tunnelDepth)); + if (_tunnelDepthOut < 0) + _tunnelDepthOut = _tunnelDepth; + config.setProperty("option.outbound.length", Integer.toString(_tunnelDepthOut)); } if (_tunnelVariance >= -2) { config.setProperty("option.inbound.lengthVariance", Integer.toString(_tunnelVariance)); - config.setProperty("option.outbound.lengthVariance", Integer.toString(_tunnelVariance)); + if (_tunnelVarianceOut < -2) + _tunnelVarianceOut = _tunnelVariance; + config.setProperty("option.outbound.lengthVariance", Integer.toString(_tunnelVarianceOut)); } if (_tunnelBackupQuantity >= 0) { config.setProperty("option.inbound.backupQuantity", Integer.toString(_tunnelBackupQuantity)); - config.setProperty("option.outbound.backupQuantity", Integer.toString(_tunnelBackupQuantity)); + if (_tunnelBackupQuantityOut < 0) + _tunnelBackupQuantityOut = _tunnelBackupQuantity; + config.setProperty("option.outbound.backupQuantity", Integer.toString(_tunnelBackupQuantityOut)); } } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 29daf558a9..6e63732260 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -142,22 +142,46 @@ public class EditBean extends IndexBean { return _helper.isInteractive(tunnel); } + /** in or both in/out */ public int getTunnelDepth(int tunnel, int defaultLength) { return _helper.getTunnelDepth(tunnel, defaultLength); } + /** in or both in/out */ public int getTunnelQuantity(int tunnel, int defaultQuantity) { return _helper.getTunnelQuantity(tunnel, defaultQuantity); } + /** in or both in/out */ public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity) { return _helper.getTunnelBackupQuantity(tunnel, defaultBackupQuantity); } + /** in or both in/out */ public int getTunnelVariance(int tunnel, int defaultVariance) { return _helper.getTunnelVariance(tunnel, defaultVariance); } + /** @since 0.9.33 */ + public int getTunnelDepthOut(int tunnel, int defaultLength) { + return _helper.getTunnelDepthOut(tunnel, defaultLength); + } + + /** @since 0.9.33 */ + public int getTunnelQuantityOut(int tunnel, int defaultQuantity) { + return _helper.getTunnelQuantityOut(tunnel, defaultQuantity); + } + + /** @since 0.9.33 */ + public int getTunnelBackupQuantityOut(int tunnel, int defaultBackupQuantity) { + return _helper.getTunnelBackupQuantityOut(tunnel, defaultBackupQuantity); + } + + /** @since 0.9.33 */ + public int getTunnelVarianceOut(int tunnel, int defaultVariance) { + return _helper.getTunnelVarianceOut(tunnel, defaultVariance); + } + public boolean getReduce(int tunnel) { return _helper.getReduceOnIdle(tunnel, false); } @@ -426,10 +450,12 @@ public class EditBean extends IndexBean { private static final int MAX_ADVANCED_QUANTITY = 16; /** + * @param mode 0=both, 1=in, 2=out * @since 0.9.7 */ - public String getQuantityOptions(int tunnel) { - int tunnelQuantity = getTunnelQuantity(tunnel, DFLT_QUANTITY); + public String getQuantityOptions(int tunnel, int mode) { + int tunnelQuantity = mode == 2 ? getTunnelQuantityOut(tunnel, DFLT_QUANTITY) + : getTunnelQuantity(tunnel, DFLT_QUANTITY); boolean advanced = _context.getBooleanProperty(PROP_ADVANCED); int maxQuantity = advanced ? MAX_ADVANCED_QUANTITY : (isClient(tunnel) ? MAX_CLIENT_QUANTITY : MAX_SERVER_QUANTITY); @@ -441,7 +467,12 @@ public class EditBean extends IndexBean { if (i == tunnelQuantity) buf.append(" selected=\"selected\""); buf.append('>'); - buf.append(ngettext("{0} inbound, {0} outbound tunnel", "{0} inbound, {0} outbound tunnels", i)); + if (mode == 1) + buf.append(ngettext("{0} inbound tunnel", "{0} inbound tunnels", i)); + else if (mode == 2) + buf.append(ngettext("{0} outbound tunnel", "{0} outbound tunnels", i)); + else + buf.append(ngettext("{0} inbound, {0} outbound tunnel", "{0} inbound, {0} outbound tunnels", i)); if (i <= 3) { buf.append(" ("); if (i == 1) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java index 30507cb1ac..02ad183e7f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -621,7 +621,10 @@ public class IndexBean { public void setClientport(String port) { _config.setClientPort(port); } - /** how many hops to use for inbound tunnels */ + + /** how many hops to use for inbound tunnels + * In or both in/out + */ public void setTunnelDepth(String tunnelDepth) { if (tunnelDepth != null) { try { @@ -629,7 +632,10 @@ public class IndexBean { } catch (NumberFormatException nfe) {} } } - /** how many parallel inbound tunnels to use */ + + /** how many parallel inbound tunnels to use + * In or both in/out + */ public void setTunnelQuantity(String tunnelQuantity) { if (tunnelQuantity != null) { try { @@ -637,7 +643,10 @@ public class IndexBean { } catch (NumberFormatException nfe) {} } } - /** how much randomisation to apply to the depth of tunnels */ + + /** how much randomisation to apply to the depth of tunnels + * In or both in/out + */ public void setTunnelVariance(String tunnelVariance) { if (tunnelVariance != null) { try { @@ -645,7 +654,10 @@ public class IndexBean { } catch (NumberFormatException nfe) {} } } - /** how many tunnels to hold in reserve to guard against failures */ + + /** how many tunnels to hold in reserve to guard against failures + * In or both in/out + */ public void setTunnelBackupQuantity(String tunnelBackupQuantity) { if (tunnelBackupQuantity != null) { try { @@ -653,6 +665,51 @@ public class IndexBean { } catch (NumberFormatException nfe) {} } } + + /** how many hops to use for inbound tunnels + * @since 0.9.33 + */ + public void setTunnelDepthOut(String tunnelDepth) { + if (tunnelDepth != null) { + try { + _config.setTunnelDepthOut(Integer.parseInt(tunnelDepth.trim())); + } catch (NumberFormatException nfe) {} + } + } + + /** how many parallel inbound tunnels to use + * @since 0.9.33 + */ + public void setTunnelQuantityOut(String tunnelQuantity) { + if (tunnelQuantity != null) { + try { + _config.setTunnelQuantityOut(Integer.parseInt(tunnelQuantity.trim())); + } catch (NumberFormatException nfe) {} + } + } + + /** how much randomisation to apply to the depth of tunnels + * @since 0.9.33 + */ + public void setTunnelVarianceOut(String tunnelVariance) { + if (tunnelVariance != null) { + try { + _config.setTunnelVarianceOut(Integer.parseInt(tunnelVariance.trim())); + } catch (NumberFormatException nfe) {} + } + } + + /** how many tunnels to hold in reserve to guard against failures + * @since 0.9.33 + */ + public void setTunnelBackupQuantityOut(String tunnelBackupQuantity) { + if (tunnelBackupQuantity != null) { + try { + _config.setTunnelBackupQuantityOut(Integer.parseInt(tunnelBackupQuantity.trim())); + } catch (NumberFormatException nfe) {} + } + } + /** what I2P session overrides should be used */ public void setNofilter_customOptions(String customOptions) { _config.setCustomOptions(customOptions); diff --git a/apps/i2ptunnel/jsp/editClient.jsp b/apps/i2ptunnel/jsp/editClient.jsp index d176b1e72a..a0f0d40d11 100644 --- a/apps/i2ptunnel/jsp/editClient.jsp +++ b/apps/i2ptunnel/jsp/editClient.jsp @@ -369,7 +369,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; }