forked from I2P_Developers/i2p.i2p
i2ptunnel: Add encrytion type selection to form
This commit is contained in:
@ -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
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user