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 77eaa8cba892ecb4dd1539a8237f74390cef5fba..6405e98d41ae7f87ae364681e7a26eef99e5bf21 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java @@ -260,7 +260,7 @@ public class GeneralHelper { public String getSpoofedHost(int tunnel) { TunnelController tun = getController(tunnel); - return (tun != null && tun.getSpoofedHost() != null) ? tun.getSpoofedHost() :""; + return (tun != null && tun.getSpoofedHost() != null) ? tun.getSpoofedHost() : ""; } public String getPrivateKeyFile(int tunnel) { @@ -286,6 +286,18 @@ public class GeneralHelper { return "127.0.0.1"; } + public int getClientPort(int tunnel) { + TunnelController tun = getController(tunnel); + if (tun != null && tun.getListenPort() != null) { + try { + return Integer.parseInt(tun.getListenPort()); + } catch (NumberFormatException e) { + return -1; + } + } else + return -1; + } + public int getTunnelStatus(int tunnel) { TunnelController tun = getController(tunnel); if (tun == null) return NOT_RUNNING; @@ -463,6 +475,10 @@ public class GeneralHelper { return getBooleanProperty(tunnel, I2PTunnelIRCClient.PROP_DCC); } + public boolean isSSLEnabled(int tunnel) { + return getBooleanProperty(tunnel, I2PTunnelServer.PROP_USE_SSL); + } + public String getEncryptKey(int tunnel) { return getProperty(tunnel, "i2cp.leaseSetKey", ""); } @@ -608,6 +624,10 @@ public class GeneralHelper { return getProperty(tunnel, I2PTunnelHTTPServer.OPT_POST_TOTAL_BAN_TIME, I2PTunnelHTTPServer.DEFAULT_POST_TOTAL_BAN_TIME) / 60; } + public boolean getRejectInproxy(int tunnel) { + return getBooleanProperty(tunnel, I2PTunnelHTTPServer.OPT_REJECT_INPROXY); + } + public boolean getUniqueLocal(int tunnel) { return getBooleanProperty(tunnel, I2PTunnelServer.PROP_UNIQUE_LOCAL); } 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 3f7c6c01e083f480bc258fcb8f3534312db632be..ebc4950981bd07735da6707ac06be43010c375af 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -60,11 +60,7 @@ public class EditBean extends IndexBean { } public String getSpoofedHost(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null && tun.getSpoofedHost() != null) - return DataHelper.escapeHTML(tun.getSpoofedHost()); - else - return ""; + return DataHelper.escapeHTML(_helper.getSpoofedHost(tunnel)); } public String getPrivateKeyFile(int tunnel) { @@ -97,19 +93,11 @@ public class EditBean extends IndexBean { } public boolean startAutomatically(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null) - return tun.getStartOnLoad(); - else - return false; + return _helper.shouldStartAutomatically(tunnel); } public boolean isSharedClient(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null) - return Boolean.parseBoolean(tun.getSharedClient()); - else - return false; + return _helper.isSharedClient(tunnel); } public boolean shouldDelay(int tunnel) { 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 81511e89cb25466239a8a1f0de492e6926978d90..0480527f4a7a0056a7abdfda2f979689604747e2 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -329,11 +329,8 @@ public class IndexBean { * No validation */ public String getClientPort(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null && tun.getListenPort() != null) - return tun.getListenPort(); - else - return ""; + int port = _helper.getClientPort(tunnel); + return port > 0 ? Integer.toString(port) : ""; } /** @@ -667,12 +664,7 @@ public class IndexBean { /** @since 0.9.9 */ public boolean isSSLEnabled(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null) { - Properties opts = tun.getClientOptionProps(); - return Boolean.parseBoolean(opts.getProperty(I2PTunnelServer.PROP_USE_SSL)); - } - return false; + return _helper.isSSLEnabled(tunnel); } /** @since 0.9.12 */ @@ -682,12 +674,7 @@ public class IndexBean { /** @since 0.9.12 */ public boolean isRejectInproxy(int tunnel) { - TunnelController tun = getController(tunnel); - if (tun != null) { - Properties opts = tun.getClientOptionProps(); - return Boolean.parseBoolean(opts.getProperty(I2PTunnelHTTPServer.OPT_REJECT_INPROXY)); - } - return false; + return _helper.getRejectInproxy(tunnel); } /** @since 0.9.13 */