2004-04-08 04:41:54 +00:00
|
|
|
package net.i2p.data.i2np;
|
|
|
|
/*
|
|
|
|
* free (adj.): unencumbered; not under the control of others
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
* Written by jrandom in 2003 and released into the public domain
|
|
|
|
* with no warranty of any kind, either expressed or implied.
|
|
|
|
* It probably won't make your computer catch on fire, or eat
|
2004-04-08 04:41:54 +00:00
|
|
|
* your children, but it might. Use at your own risk.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.IOException;
|
2004-05-17 03:38:53 +00:00
|
|
|
import net.i2p.I2PAppContext;
|
2004-04-08 04:41:54 +00:00
|
|
|
import net.i2p.data.DataFormatException;
|
|
|
|
import net.i2p.data.DataHelper;
|
|
|
|
import net.i2p.data.Hash;
|
|
|
|
import net.i2p.data.LeaseSet;
|
|
|
|
import net.i2p.data.RouterInfo;
|
2004-05-20 11:06:25 +00:00
|
|
|
import net.i2p.data.TunnelId;
|
2004-04-08 04:41:54 +00:00
|
|
|
import net.i2p.util.Log;
|
|
|
|
|
|
|
|
/**
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
* Defines the message a router sends to another router to test the network
|
2004-04-08 04:41:54 +00:00
|
|
|
* database reachability, as well as the reply message sent back.
|
|
|
|
*
|
|
|
|
* @author jrandom
|
|
|
|
*/
|
|
|
|
public class DatabaseStoreMessage extends I2NPMessageImpl {
|
|
|
|
private final static Log _log = new Log(DatabaseStoreMessage.class);
|
|
|
|
public final static int MESSAGE_TYPE = 1;
|
|
|
|
private Hash _key;
|
|
|
|
private int _type;
|
|
|
|
private LeaseSet _leaseSet;
|
|
|
|
private RouterInfo _info;
|
2004-10-07 19:19:51 +00:00
|
|
|
private byte[] _leaseSetCache;
|
|
|
|
private byte[] _routerInfoCache;
|
2004-05-20 11:06:25 +00:00
|
|
|
private long _replyToken;
|
|
|
|
private TunnelId _replyTunnel;
|
|
|
|
private Hash _replyGateway;
|
2004-04-08 04:41:54 +00:00
|
|
|
|
|
|
|
public final static int KEY_TYPE_ROUTERINFO = 0;
|
|
|
|
public final static int KEY_TYPE_LEASESET = 1;
|
|
|
|
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
public DatabaseStoreMessage(I2PAppContext context) {
|
|
|
|
super(context);
|
|
|
|
setValueType(-1);
|
|
|
|
setKey(null);
|
|
|
|
setLeaseSet(null);
|
|
|
|
setRouterInfo(null);
|
2004-05-20 11:06:25 +00:00
|
|
|
setReplyToken(0);
|
|
|
|
setReplyTunnel(null);
|
|
|
|
setReplyGateway(null);
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the key in the network database being stored
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public Hash getKey() { return _key; }
|
|
|
|
public void setKey(Hash key) { _key = key; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the router info value in the network database being stored
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public RouterInfo getRouterInfo() { return _info; }
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
public void setRouterInfo(RouterInfo routerInfo) {
|
|
|
|
_info = routerInfo;
|
|
|
|
if (_info != null)
|
|
|
|
setValueType(KEY_TYPE_ROUTERINFO);
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the lease set value in the network database being stored
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public LeaseSet getLeaseSet() { return _leaseSet; }
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
public void setLeaseSet(LeaseSet leaseSet) {
|
|
|
|
_leaseSet = leaseSet;
|
|
|
|
if (_leaseSet != null)
|
|
|
|
setValueType(KEY_TYPE_LEASESET);
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
* Defines type of key being stored in the network database -
|
2004-04-08 04:41:54 +00:00
|
|
|
* either KEY_TYPE_ROUTERINFO or KEY_TYPE_LEASESET
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public int getValueType() { return _type; }
|
|
|
|
public void setValueType(int type) { _type = type; }
|
|
|
|
|
2004-05-20 11:06:25 +00:00
|
|
|
/**
|
|
|
|
* If a reply is desired, this token specifies the message ID that should
|
|
|
|
* be used for a DeliveryStatusMessage to be sent to the reply tunnel on the
|
|
|
|
* reply gateway.
|
|
|
|
*
|
|
|
|
* @return positive reply token ID, or 0 if no reply is necessary.
|
|
|
|
*/
|
|
|
|
public long getReplyToken() { return _replyToken; }
|
2004-06-29 19:28:40 +00:00
|
|
|
/**
|
|
|
|
* Update the reply token.
|
|
|
|
*
|
|
|
|
* @throws IllegalArgumentException if the token is out of range (min=0, max=I2NPMessage.MAX_ID_VALUE)
|
|
|
|
*/
|
|
|
|
public void setReplyToken(long token) throws IllegalArgumentException {
|
|
|
|
if (token > I2NPMessage.MAX_ID_VALUE)
|
|
|
|
throw new IllegalArgumentException("Token too large: " + token + " (max=" + I2NPMessage.MAX_ID_VALUE + ")");
|
|
|
|
else if (token < 0)
|
|
|
|
throw new IllegalArgumentException("Token too small: " + token);
|
|
|
|
_replyToken = token;
|
|
|
|
}
|
2004-05-20 11:06:25 +00:00
|
|
|
|
|
|
|
public TunnelId getReplyTunnel() { return _replyTunnel; }
|
|
|
|
public void setReplyTunnel(TunnelId id) { _replyTunnel = id; }
|
|
|
|
|
|
|
|
public Hash getReplyGateway() { return _replyGateway; }
|
|
|
|
public void setReplyGateway(Hash peer) { _replyGateway = peer; }
|
|
|
|
|
2004-10-08 02:08:10 +00:00
|
|
|
public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException {
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message");
|
2004-10-08 02:08:10 +00:00
|
|
|
int curIndex = offset;
|
|
|
|
|
|
|
|
byte keyData[] = new byte[Hash.HASH_LENGTH];
|
|
|
|
System.arraycopy(data, curIndex, keyData, 0, Hash.HASH_LENGTH);
|
|
|
|
curIndex += Hash.HASH_LENGTH;
|
|
|
|
_key = new Hash(keyData);
|
|
|
|
|
|
|
|
_type = (int)DataHelper.fromLong(data, curIndex, 1);
|
|
|
|
curIndex++;
|
|
|
|
|
|
|
|
_replyToken = DataHelper.fromLong(data, curIndex, 4);
|
|
|
|
curIndex += 4;
|
|
|
|
|
|
|
|
if (_replyToken > 0) {
|
2005-09-13 00:11:56 +00:00
|
|
|
long tunnel = DataHelper.fromLong(data, curIndex, 4);
|
|
|
|
if (tunnel > 0)
|
|
|
|
_replyTunnel = new TunnelId(tunnel);
|
2004-10-08 02:08:10 +00:00
|
|
|
curIndex += 4;
|
|
|
|
|
|
|
|
byte gw[] = new byte[Hash.HASH_LENGTH];
|
|
|
|
System.arraycopy(data, curIndex, gw, 0, Hash.HASH_LENGTH);
|
|
|
|
curIndex += Hash.HASH_LENGTH;
|
|
|
|
_replyGateway = new Hash(gw);
|
|
|
|
} else {
|
|
|
|
_replyTunnel = null;
|
|
|
|
_replyGateway = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_type == KEY_TYPE_LEASESET) {
|
|
|
|
_leaseSet = new LeaseSet();
|
|
|
|
try {
|
|
|
|
_leaseSet.readBytes(new ByteArrayInputStream(data, curIndex, data.length-curIndex));
|
|
|
|
} catch (DataFormatException dfe) {
|
|
|
|
throw new I2NPMessageException("Error reading the leaseSet", dfe);
|
2004-05-20 11:06:25 +00:00
|
|
|
}
|
2004-10-08 02:08:10 +00:00
|
|
|
} else if (_type == KEY_TYPE_ROUTERINFO) {
|
|
|
|
_info = new RouterInfo();
|
|
|
|
int compressedSize = (int)DataHelper.fromLong(data, curIndex, 2);
|
|
|
|
curIndex += 2;
|
|
|
|
|
|
|
|
try {
|
2005-08-27 22:46:22 +00:00
|
|
|
byte decompressed[] = DataHelper.decompress(data, curIndex, compressedSize);
|
2004-10-08 02:08:10 +00:00
|
|
|
_info.readBytes(new ByteArrayInputStream(decompressed));
|
|
|
|
} catch (DataFormatException dfe) {
|
|
|
|
throw new I2NPMessageException("Error reading the routerInfo", dfe);
|
2005-08-27 22:46:22 +00:00
|
|
|
} catch (IOException ioe) {
|
|
|
|
throw new I2NPMessageException("Compressed routerInfo was corrupt", ioe);
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
}
|
2004-10-08 02:08:10 +00:00
|
|
|
} else {
|
|
|
|
throw new I2NPMessageException("Invalid type of key read from the structure - " + _type);
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-08 02:08:10 +00:00
|
|
|
|
2004-10-07 19:19:51 +00:00
|
|
|
/** calculate the message body's length (not including the header and footer */
|
|
|
|
protected int calculateWrittenLength() {
|
|
|
|
int len = Hash.HASH_LENGTH + 1 + 4; // key+type+replyToken
|
|
|
|
if (_replyToken > 0)
|
|
|
|
len += 4 + Hash.HASH_LENGTH; // replyTunnel+replyGateway
|
|
|
|
if (_type == KEY_TYPE_LEASESET) {
|
|
|
|
_leaseSetCache = _leaseSet.toByteArray();
|
|
|
|
len += _leaseSetCache.length;
|
|
|
|
} else if (_type == KEY_TYPE_ROUTERINFO) {
|
|
|
|
byte uncompressed[] = _info.toByteArray();
|
|
|
|
byte compressed[] = DataHelper.compress(uncompressed);
|
|
|
|
_routerInfoCache = compressed;
|
|
|
|
len += compressed.length + 2;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
/** write the message body to the output array, starting at the given index */
|
|
|
|
protected int writeMessageBody(byte out[], int curIndex) throws I2NPMessageException {
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
if (_key == null) throw new I2NPMessageException("Invalid key");
|
|
|
|
if ( (_type != KEY_TYPE_LEASESET) && (_type != KEY_TYPE_ROUTERINFO) ) throw new I2NPMessageException("Invalid key type");
|
|
|
|
if ( (_type == KEY_TYPE_LEASESET) && (_leaseSet == null) ) throw new I2NPMessageException("Missing lease set");
|
|
|
|
if ( (_type == KEY_TYPE_ROUTERINFO) && (_info == null) ) throw new I2NPMessageException("Missing router info");
|
|
|
|
|
2004-10-07 19:19:51 +00:00
|
|
|
System.arraycopy(_key.getData(), 0, out, curIndex, Hash.HASH_LENGTH);
|
|
|
|
curIndex += Hash.HASH_LENGTH;
|
|
|
|
byte type[] = DataHelper.toLong(1, _type);
|
|
|
|
out[curIndex++] = type[0];
|
|
|
|
byte tok[] = DataHelper.toLong(4, _replyToken);
|
|
|
|
System.arraycopy(tok, 0, out, curIndex, 4);
|
|
|
|
curIndex += 4;
|
|
|
|
|
|
|
|
if (_replyToken > 0) {
|
2005-09-13 00:11:56 +00:00
|
|
|
long replyTunnel = 0;
|
|
|
|
if (_replyTunnel != null)
|
|
|
|
replyTunnel = _replyTunnel.getTunnelId();
|
|
|
|
byte id[] = DataHelper.toLong(4, replyTunnel);
|
2004-10-07 19:19:51 +00:00
|
|
|
System.arraycopy(id, 0, out, curIndex, 4);
|
|
|
|
curIndex += 4;
|
|
|
|
System.arraycopy(_replyGateway.getData(), 0, out, curIndex, Hash.HASH_LENGTH);
|
|
|
|
curIndex += Hash.HASH_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_type == KEY_TYPE_LEASESET) {
|
|
|
|
// initialized in calculateWrittenLength
|
|
|
|
System.arraycopy(_leaseSetCache, 0, out, curIndex, _leaseSetCache.length);
|
|
|
|
curIndex += _leaseSetCache.length;
|
|
|
|
} else if (_type == KEY_TYPE_ROUTERINFO) {
|
|
|
|
byte len[] = DataHelper.toLong(2, _routerInfoCache.length);
|
|
|
|
out[curIndex++] = len[0];
|
|
|
|
out[curIndex++] = len[1];
|
|
|
|
System.arraycopy(_routerInfoCache, 0, out, curIndex, _routerInfoCache.length);
|
|
|
|
curIndex += _routerInfoCache.length;
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
2004-10-07 19:19:51 +00:00
|
|
|
return curIndex;
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getType() { return MESSAGE_TYPE; }
|
|
|
|
|
|
|
|
public int hashCode() {
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
return DataHelper.hashCode(getKey()) +
|
|
|
|
DataHelper.hashCode(getLeaseSet()) +
|
|
|
|
DataHelper.hashCode(getRouterInfo()) +
|
2004-05-20 11:06:25 +00:00
|
|
|
getValueType() +
|
|
|
|
(int)getReplyToken() +
|
|
|
|
DataHelper.hashCode(getReplyTunnel()) +
|
|
|
|
DataHelper.hashCode(getReplyGateway());
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object object) {
|
|
|
|
if ( (object != null) && (object instanceof DatabaseStoreMessage) ) {
|
|
|
|
DatabaseStoreMessage msg = (DatabaseStoreMessage)object;
|
|
|
|
return DataHelper.eq(getKey(),msg.getKey()) &&
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
DataHelper.eq(getLeaseSet(),msg.getLeaseSet()) &&
|
|
|
|
DataHelper.eq(getRouterInfo(),msg.getRouterInfo()) &&
|
2004-05-20 11:06:25 +00:00
|
|
|
DataHelper.eq(getValueType(),msg.getValueType()) &&
|
|
|
|
getReplyToken() == msg.getReplyToken() &&
|
|
|
|
DataHelper.eq(getReplyTunnel(), msg.getReplyTunnel()) &&
|
|
|
|
DataHelper.eq(getReplyGateway(), msg.getReplyGateway());
|
2004-04-08 04:41:54 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
public String toString() {
|
2004-04-08 04:41:54 +00:00
|
|
|
StringBuffer buf = new StringBuffer();
|
|
|
|
buf.append("[DatabaseStoreMessage: ");
|
big ol' update to strip out the singletons, replacing them with
a rooted app context. The core itself has its own I2PAppContext
(see its javadoc for, uh, docs), and the router extends that to
expose the router's singletons. The main point of this is to
make it so that we can run multiple routers in the same JVM, even
to allow different apps in the same JVM to switch singleton
implementations (e.g. run some routers with one set of profile
calculators, and other routers with a different one).
There is still some work to be done regarding the actual boot up
of multiple routers in a JVM, as well as their configuration,
though the plan is to have the RouterContext override the
I2PAppContext's getProperty/getPropertyNames methods to read from
a config file (seperate ones per context) instead of using the
System.getProperty that the base I2PAppContext uses.
Once the multi-router is working, i'll shim in a VMCommSystem
that doesn't depend upon sockets or threads to read/write (and
that uses configurable message send delays / disconnects / etc,
perhaps using data from the routerContext.getProperty to drive it).
I could hold off until the sim is all working, but there's a
truckload of changes in here and I hate dealing with conflicts ;)
Everything works - I've been running 'er for a while and kicked
the tires a bit, but if you see something amiss, please let me
know.
2004-04-24 11:54:35 +00:00
|
|
|
buf.append("\n\tExpiration: ").append(getMessageExpiration());
|
|
|
|
buf.append("\n\tUnique ID: ").append(getUniqueId());
|
2004-04-08 04:41:54 +00:00
|
|
|
buf.append("\n\tKey: ").append(getKey());
|
|
|
|
buf.append("\n\tValue Type: ").append(getValueType());
|
|
|
|
buf.append("\n\tRouter Info: ").append(getRouterInfo());
|
|
|
|
buf.append("\n\tLease Set: ").append(getLeaseSet());
|
2004-05-20 11:06:25 +00:00
|
|
|
buf.append("\n\tReply token: ").append(getReplyToken());
|
|
|
|
buf.append("\n\tReply tunnel: ").append(getReplyTunnel());
|
|
|
|
buf.append("\n\tReply gateway: ").append(getReplyGateway());
|
2004-04-08 04:41:54 +00:00
|
|
|
buf.append("]");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
|
|
|
}
|