* I2PTunnel:

- Add persistent key option for clients (not hooked in yet)
      - I2PSink: Send protocol byte
This commit is contained in:
zzz
2009-03-01 19:25:49 +00:00
parent 3733b78ccf
commit bfa02f3b82
8 changed files with 77 additions and 38 deletions

View File

@@ -230,6 +230,9 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
I2PSocketManager sockManager = null;
while (sockManager == null) {
// if persistent dest
// sockManager = I2PSocketManagerFactory.createManager(privData, tunnel.host, portNum, props);
// else
sockManager = I2PSocketManagerFactory.createManager(tunnel.host, portNum, props);
if (sockManager == null) {

View File

@@ -58,7 +58,7 @@ public class TunnelController implements Logging {
setConfig(config, prefix);
_messages = new ArrayList(4);
_running = false;
if (createKey && getType().endsWith("server"))
if (createKey && (getType().endsWith("server") || getPersistentClientKey()))
createPrivateKey();
_starting = getStartOnLoad();
}
@@ -395,6 +395,7 @@ public class TunnelController implements Logging {
public String getProxyList() { return _config.getProperty("proxyList"); }
public String getSharedClient() { return _config.getProperty("sharedClient", "true"); }
public boolean getStartOnLoad() { return "true".equalsIgnoreCase(_config.getProperty("startOnLoad", "true")); }
public boolean getPersistentClientKey() { return Boolean.valueOf(_config.getProperty("persistentClientKey")).booleanValue(); }
public String getMyDestination() {
if (_tunnel != null) {
List sessions = _tunnel.getSessions();

View File

@@ -44,7 +44,8 @@ public class I2PSink implements Sink {
// send message
try {
this.sess.sendMessage(this.dest, payload);
this.sess.sendMessage(this.dest, payload, I2PSession.PROTO_DATAGRAM,
I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
} catch(I2PSessionException exc) {
// TODO: handle better
exc.printStackTrace();

View File

@@ -42,7 +42,8 @@ public class I2PSinkAnywhere implements Sink {
// send message
try {
this.sess.sendMessage(to, payload);
this.sess.sendMessage(to, payload, I2PSession.PROTO_DATAGRAM,
I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
} catch(I2PSessionException exc) {
// TODO: handle better
exc.printStackTrace();

View File

@@ -156,6 +156,10 @@ public class EditBean extends IndexBean {
return getBooleanProperty(tunnel, "i2cp.newDestOnResume");
}
public boolean getPersistentClientKey(int tunnel) {
return getBooleanProperty(tunnel, "persistentClientKey");
}
private int getProperty(int tunnel, String prop, int def) {
TunnelController tun = getController(tunnel);
if (tun != null) {

View File

@@ -614,8 +614,11 @@ public class IndexBean {
public void setAccess(String moo) {
_booleanOptions.add("i2cp.enableAccessList");
}
public void setNewDest(String moo) {
_booleanOptions.add("i2cp.newDestOnResume");
public void setNewDest(String val) {
if ("1".equals(val))
_booleanOptions.add("i2cp.newDestOnResume");
else if ("2".equals(val))
_booleanOptions.add("persistentClientKey");
}
public void setReduceTime(String val) {
@@ -790,8 +793,6 @@ public class IndexBean {
config.setProperty("targetHost", _targetHost);
if (_targetPort != null)
config.setProperty("targetPort", _targetPort);
if (_privKeyFile != null)
config.setProperty("privKeyFile", _privKeyFile);
for (String p : _booleanServerOpts)
config.setProperty("option." + p, "" + _booleanOptions.contains(p));
for (String p : _otherServerOpts)
@@ -819,7 +820,7 @@ public class IndexBean {
"inbound.nickname", "outbound.nickname", "i2p.streaming.connectDelay", "i2p.streaming.maxWindowSize"
};
private static final String _booleanClientOpts[] = {
"i2cp.reduceOnIdle", "i2cp.closeOnIdle", "i2cp.newDestOnResume"
"i2cp.reduceOnIdle", "i2cp.closeOnIdle", "i2cp.newDestOnResume", "persistentClientKey"
};
private static final String _booleanServerOpts[] = {
"i2cp.reduceOnIdle", "i2cp.encryptLeaseSet", "i2cp.enableAccessList"
@@ -852,6 +853,8 @@ public class IndexBean {
} else {
config.setProperty("i2cpPort", "7654");
}
if (_privKeyFile != null)
config.setProperty("privKeyFile", _privKeyFile);
if (_customOptions != null) {
StringTokenizer tok = new StringTokenizer(_customOptions);