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 980ba017d..e0d719c42 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java @@ -55,10 +55,16 @@ public class GeneralHelper { private final I2PAppContext _context; protected final TunnelControllerGroup _group; + /** + * @param tcg may be null ??? + */ public GeneralHelper(TunnelControllerGroup tcg) { this(I2PAppContext.getGlobalContext(), tcg); } + /** + * @param tcg may be null ??? + */ public GeneralHelper(I2PAppContext context, TunnelControllerGroup tcg) { _context = context; _group = tcg; @@ -68,6 +74,10 @@ public class GeneralHelper { return getController(_group, tunnel); } + /** + * @param tcg may be null + * @return null if not found or tcg is null + */ public static TunnelController getController(TunnelControllerGroup tcg, int tunnel) { if (tunnel < 0) return null; if (tcg == null) return null; @@ -696,6 +706,21 @@ public class GeneralHelper { return type.getCode(); } + /** + * @param encType code + * @since 0.9.44 + */ + public boolean hasEncType(int tunnel, int encType) { + String senc = getProperty(tunnel, "i2cp.leaseSetEncType", "0"); + String[] senca = DataHelper.split(senc, ","); + String se = Integer.toString(encType); + for (int i = 0; i < senca.length; i++) { + if (se.equals(senca[i])) + return true; + } + return false; + } + /** * Random keys */ 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 01289da93..fb072c129 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java @@ -632,6 +632,19 @@ public class TunnelConfig { _otherOptions.put(I2PClient.PROP_SIGTYPE, val.trim()); } + /** + * Adds to existing, comma separated + * @since 0.9.44 + */ + public void setEncType(String val) { + if (val != null) { + String p = _otherOptions.get("i2cp.leaseSetEncType"); + if (p != null) + val = p + ',' + val; + _otherOptions.put("i2cp.leaseSetEncType", val); + } + } + /** * Random keys */ @@ -837,6 +850,7 @@ public class TunnelConfig { p = OPT + "i2cp.leaseSetPrivateKey"; keys = KeyGenerator.getInstance().generatePKIKeys(); config.setProperty(p, "ELGAMAL_2048:" + keys[1].toBase64()); + // TODO ECIES key } catch (GeneralSecurityException gse) { // so much for that } @@ -1062,7 +1076,8 @@ public class TunnelConfig { I2PClient.PROP_SIGTYPE, I2PTunnelHTTPClient.PROP_SSL_OUTPROXIES, // following are mostly server but could also be persistent client - "inbound.randomKey", "outbound.randomKey", "i2cp.leaseSetSigningPrivateKey", "i2cp.leaseSetPrivateKey" + "inbound.randomKey", "outbound.randomKey", "i2cp.leaseSetSigningPrivateKey", "i2cp.leaseSetPrivateKey", + "i2cp.leaseSetEncType" }; private static final String _otherServerOpts[] = { "i2cp.reduceIdleTime", "i2cp.reduceQuantity", "i2cp.leaseSetKey", "i2cp.accessList", @@ -1071,7 +1086,8 @@ public class TunnelConfig { PROP_MAX_STREAMS, I2PClient.PROP_SIGTYPE, "inbound.randomKey", "outbound.randomKey", "i2cp.leaseSetSigningPrivateKey", "i2cp.leaseSetPrivateKey", I2PTunnelServer.PROP_ALT_PKF, - "i2cp.leaseSetSecret", "i2cp.leaseSetType", "i2cp.leaseSetAuthType", "i2cp.leaseSetPrivKey" + "i2cp.leaseSetSecret", "i2cp.leaseSetType", "i2cp.leaseSetAuthType", "i2cp.leaseSetPrivKey", + "i2cp.leaseSetEncType" }; private static final String _httpServerOpts[] = { I2PTunnelHTTPServer.OPT_POST_WINDOW, 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 a3599e3fe..8dbed7335 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -259,6 +259,14 @@ public class EditBean extends IndexBean { return getTunnelStatus(tunnel) == GeneralHelper.NOT_RUNNING; } + /** + * @param encType code + * @since 0.9.44 + */ + public boolean hasEncType(int tunnel, int encType) { + return _helper.hasEncType(tunnel, encType); + } + /** * Random keys, hidden in forms * @since 0.9.18 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 b09beceaa..85fcd595b 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -1239,6 +1239,14 @@ public class IndexBean { // Otherwise this only works on a new tunnel... } + /** + * Adds to existing, comma separated + * @since 0.9.44 + */ + public void setEncType(String s) { + _config.setEncType(s); + } + /** * Random keys, hidden in forms * @since 0.9.18 diff --git a/apps/i2ptunnel/jsp/editClient.jsi b/apps/i2ptunnel/jsp/editClient.jsi index 2ece40a25..666bfc789 100644 --- a/apps/i2ptunnel/jsp/editClient.jsi +++ b/apps/i2ptunnel/jsp/editClient.jsi @@ -487,13 +487,12 @@ <% } // if httpclient - if (true /* editBean.isAdvanced() */ ) { - int currentSigType = editBean.getSigType(curTunnel, tunnelType); - String disabled = editBean.canChangeSigType(curTunnel) ? "" : " disabled=\"disabled\" "; + int currentSigType = editBean.getSigType(curTunnel, tunnelType); + String disabled = editBean.canChangeSigType(curTunnel) ? "" : " disabled=\"disabled\" "; %>