I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit b8b272a5 authored by str4d's avatar str4d
Browse files

Better multi-mode setters

parent a570e091
No related branches found
No related tags found
No related merge requests found
...@@ -223,11 +223,28 @@ public class TunnelConfig { ...@@ -223,11 +223,28 @@ public class TunnelConfig {
protected static final String PROP_ENABLE_ACCESS_LIST = "i2cp.enableAccessList"; protected static final String PROP_ENABLE_ACCESS_LIST = "i2cp.enableAccessList";
protected static final String PROP_ENABLE_BLACKLIST = "i2cp.enableBlackList"; protected static final String PROP_ENABLE_BLACKLIST = "i2cp.enableBlackList";
public void setAccessMode(String val) { /**
if ("1".equals(val)) * Controls how other tunnels are checked for access.
* <p/>
* The list used for whitelisting/blacklisting can be set with
* {@link #setAccessList(String)}.
*
* @param mode 0 for no control, 1 for whitelist, 2 for blacklist
*/
public void setAccessMode(int mode) {
switch (mode) {
case 1:
_booleanOptions.add(PROP_ENABLE_ACCESS_LIST); _booleanOptions.add(PROP_ENABLE_ACCESS_LIST);
else if ("2".equals(val)) _booleanOptions.remove(PROP_ENABLE_BLACKLIST);
break;
case 2:
_booleanOptions.remove(PROP_ENABLE_ACCESS_LIST);
_booleanOptions.add(PROP_ENABLE_BLACKLIST); _booleanOptions.add(PROP_ENABLE_BLACKLIST);
break;
default:
_booleanOptions.remove(PROP_ENABLE_ACCESS_LIST);
_booleanOptions.remove(PROP_ENABLE_BLACKLIST);
}
} }
public void setDelayOpen(boolean val) { public void setDelayOpen(boolean val) {
...@@ -236,11 +253,28 @@ public class TunnelConfig { ...@@ -236,11 +253,28 @@ public class TunnelConfig {
else else
_booleanOptions.remove("i2cp.delayOpen"); _booleanOptions.remove("i2cp.delayOpen");
} }
public void setNewDest(String val) {
if ("1".equals(val)) /**
* Controls how ephemeral the I2P Destination of a client tunnel is.
* <p/>
* If {@link #setClose(boolean)} is set to true then mode 1 == mode 0.
*
* @param mode 0 for new dest on restart, 1 for new dest on resume from idle, 2 for persistent key
*/
public void setNewDest(int mode) {
switch (mode) {
case 1:
_booleanOptions.add("i2cp.newDestOnResume"); _booleanOptions.add("i2cp.newDestOnResume");
else if ("2".equals(val)) _booleanOptions.remove("persistentClientKey");
break;
case 2:
_booleanOptions.remove("i2cp.newDestOnResume");
_booleanOptions.add("persistentClientKey"); _booleanOptions.add("persistentClientKey");
break;
default:
_booleanOptions.remove("i2cp.newDestOnResume");
_booleanOptions.remove("persistentClientKey");
}
} }
public void setReduceTime(int val) { public void setReduceTime(int val) {
......
...@@ -864,14 +864,22 @@ public class IndexBean { ...@@ -864,14 +864,22 @@ public class IndexBean {
protected static final String PROP_ENABLE_BLACKLIST = "i2cp.enableBlackList"; protected static final String PROP_ENABLE_BLACKLIST = "i2cp.enableBlackList";
public void setAccessMode(String val) { public void setAccessMode(String val) {
_config.setAccessMode(val); if (val != null) {
try {
_config.setAccessMode(Integer.parseInt(val.trim()));
} catch (NumberFormatException nfe) {}
}
} }
public void setDelayOpen(String moo) { public void setDelayOpen(String moo) {
_config.setDelayOpen(true); _config.setDelayOpen(true);
} }
public void setNewDest(String val) { public void setNewDest(String val) {
_config.setNewDest(val); if (val != null) {
try {
_config.setNewDest(Integer.parseInt(val.trim()));
} catch (NumberFormatException nfe) {}
}
} }
public void setReduceTime(String val) { public void setReduceTime(String val) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment