From 276d1c907e5e7f514d024a92caba592fdd0e1645 Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 26 Jan 2018 14:28:41 +0000 Subject: [PATCH] i2ptunnel: Fix duplicate tunnels on create Fix null tunnel name Javadoc fixes --- .../java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java | 10 +++++++++- .../java/src/net/i2p/i2ptunnel/web/IndexBean.java | 12 +++++++----- apps/i2ptunnel/jsp/index.jsp | 2 +- router/java/src/net/i2p/router/RouterVersion.java | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) 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 83c7fca4b..3f6e83245 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java @@ -98,7 +98,8 @@ public class GeneralHelper { boolean created = SSLClientUtil.verifyKeyStore(props, OPT); if (created) { // config now contains new keystore props - msgs.add("Created new self-signed certificate for tunnel " + getTunnelName(tcg, tunnel)); + String name = props.getProperty(TunnelController.PROP_NAME, ""); + msgs.add("Created new self-signed certificate for tunnel " + name); } } catch (IOException ioe) { msgs.add("Failed to create new self-signed certificate for tunnel " + @@ -225,9 +226,16 @@ public class GeneralHelper { return (tun != null && tun.getType() != null) ? tun.getType() : ""; } + /** + * @return null if unset + */ public String getTunnelName(int tunnel) { return getTunnelName(_group, tunnel); } + + /** + * @return null if unset + */ public static String getTunnelName(TunnelControllerGroup tcg, int tunnel) { TunnelController tun = getController(tcg, tunnel); return tun != null ? tun.getName() : null; 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 02ad183e7..c191bede0 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -283,6 +283,8 @@ public class IndexBean { * Executes any action requested (start/stop/etc) and dump out the * messages. * + * Only call this ONCE! Or you will get duplicate tunnels on save. + * * @return HTML escaped or "" if empty */ public String getMessages() { @@ -363,7 +365,7 @@ public class IndexBean { public String getTunnelName(int tunnel) { String name = _helper.getTunnelName(tunnel); - if (name != null) + if (name != null && name.length() > 0) return DataHelper.escapeHTML(name); else return _t("New Tunnel"); @@ -666,7 +668,7 @@ public class IndexBean { } } - /** how many hops to use for inbound tunnels + /** how many hops to use for outbound tunnels * @since 0.9.33 */ public void setTunnelDepthOut(String tunnelDepth) { @@ -677,7 +679,7 @@ public class IndexBean { } } - /** how many parallel inbound tunnels to use + /** how many parallel outbound tunnels to use * @since 0.9.33 */ public void setTunnelQuantityOut(String tunnelQuantity) { @@ -688,7 +690,7 @@ public class IndexBean { } } - /** how much randomisation to apply to the depth of tunnels + /** how much randomisation to apply to the depth of outbound tunnels * @since 0.9.33 */ public void setTunnelVarianceOut(String tunnelVariance) { @@ -699,7 +701,7 @@ public class IndexBean { } } - /** how many tunnels to hold in reserve to guard against failures + /** how many outbound tunnels to hold in reserve to guard against failures * @since 0.9.33 */ public void setTunnelBackupQuantityOut(String tunnelBackupQuantity) { diff --git a/apps/i2ptunnel/jsp/index.jsp b/apps/i2ptunnel/jsp/index.jsp index b0b1f5f6e..82628b1ad 100644 --- a/apps/i2ptunnel/jsp/index.jsp +++ b/apps/i2ptunnel/jsp/index.jsp @@ -48,7 +48,7 @@ diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 0e04b1445..33006bcb1 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 26; + public final static long BUILD = 27; /** for example "-test" */ public final static String EXTRA = "-rc";
- +