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.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
2004-05-17 03:38:53 +00:00
|
|
|
import net.i2p.I2PAppContext;
|
2004-04-08 04:41:54 +00:00
|
|
|
import net.i2p.data.Certificate;
|
|
|
|
import net.i2p.data.DataFormatException;
|
|
|
|
import net.i2p.data.DataHelper;
|
|
|
|
import net.i2p.data.Hash;
|
2004-07-27 22:04:02 +00:00
|
|
|
import net.i2p.data.SessionKey;
|
|
|
|
import net.i2p.data.SessionTag;
|
2004-07-30 22:19:57 +00:00
|
|
|
import net.i2p.data.TunnelId;
|
2004-04-08 04:41:54 +00:00
|
|
|
import net.i2p.util.Log;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines the message sent to a router to request that it participate in a
|
|
|
|
* tunnel using the included configuration settings.
|
|
|
|
*
|
|
|
|
* @author jrandom
|
|
|
|
*/
|
|
|
|
public class TunnelCreateMessage extends I2NPMessageImpl {
|
|
|
|
private final static Log _log = new Log(TunnelCreateMessage.class);
|
|
|
|
public final static int MESSAGE_TYPE = 6;
|
|
|
|
private int _participantType;
|
|
|
|
private TunnelId _tunnelId;
|
2004-07-27 22:04:02 +00:00
|
|
|
private Hash _nextRouter;
|
|
|
|
private TunnelId _nextTunnelId;
|
2004-04-08 04:41:54 +00:00
|
|
|
private long _tunnelDuration;
|
|
|
|
private TunnelConfigurationSessionKey _configKey;
|
|
|
|
private long _maxPeakMessagesPerMin;
|
|
|
|
private long _maxAvgMessagesPerMin;
|
|
|
|
private long _maxPeakBytesPerMin;
|
|
|
|
private long _maxAvgBytesPerMin;
|
|
|
|
private boolean _includeDummyTraffic;
|
|
|
|
private boolean _reorderMessages;
|
|
|
|
private TunnelSigningPublicKey _verificationPubKey;
|
|
|
|
private TunnelSigningPrivateKey _verificationPrivKey;
|
|
|
|
private TunnelSessionKey _tunnelKey;
|
|
|
|
private Certificate _certificate;
|
2004-07-27 22:04:02 +00:00
|
|
|
private SessionTag _replyTag;
|
|
|
|
private SessionKey _replyKey;
|
|
|
|
private TunnelId _replyTunnel;
|
|
|
|
private Hash _replyPeer;
|
2004-04-08 04:41:54 +00:00
|
|
|
|
|
|
|
public static final int PARTICIPANT_TYPE_GATEWAY = 1;
|
|
|
|
public static final int PARTICIPANT_TYPE_ENDPOINT = 2;
|
|
|
|
public static final int PARTICIPANT_TYPE_OTHER = 3;
|
|
|
|
|
|
|
|
private final static long FLAG_DUMMY = 1 << 7;
|
|
|
|
private final static long FLAG_REORDER = 1 << 6;
|
|
|
|
|
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 TunnelCreateMessage(I2PAppContext context) {
|
|
|
|
super(context);
|
|
|
|
setParticipantType(-1);
|
|
|
|
setNextRouter(null);
|
2004-07-27 22:04:02 +00:00
|
|
|
setNextTunnelId(null);
|
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
|
|
|
setTunnelId(null);
|
|
|
|
setTunnelDurationSeconds(-1);
|
|
|
|
setConfigurationKey(null);
|
|
|
|
setMaxPeakMessagesPerMin(-1);
|
|
|
|
setMaxAvgMessagesPerMin(-1);
|
|
|
|
setMaxPeakBytesPerMin(-1);
|
|
|
|
setMaxAvgBytesPerMin(-1);
|
|
|
|
setIncludeDummyTraffic(false);
|
|
|
|
setReorderMessages(false);
|
|
|
|
setVerificationPublicKey(null);
|
|
|
|
setVerificationPrivateKey(null);
|
|
|
|
setTunnelKey(null);
|
|
|
|
setCertificate(null);
|
2004-07-27 22:04:02 +00:00
|
|
|
setReplyTag(null);
|
|
|
|
setReplyKey(null);
|
|
|
|
setReplyTunnel(null);
|
|
|
|
setReplyPeer(null);
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setParticipantType(int type) { _participantType = type; }
|
|
|
|
public int getParticipantType() { return _participantType; }
|
|
|
|
public void setNextRouter(Hash routerIdentityHash) { _nextRouter = routerIdentityHash; }
|
|
|
|
public Hash getNextRouter() { return _nextRouter; }
|
2004-07-27 22:04:02 +00:00
|
|
|
public void setNextTunnelId(TunnelId id) { _nextTunnelId = id; }
|
|
|
|
public TunnelId getNextTunnelId() { return _nextTunnelId; }
|
2004-04-08 04:41:54 +00:00
|
|
|
public void setTunnelId(TunnelId id) { _tunnelId = id; }
|
|
|
|
public TunnelId getTunnelId() { return _tunnelId; }
|
|
|
|
public void setTunnelDurationSeconds(long durationSeconds) { _tunnelDuration = durationSeconds; }
|
|
|
|
public long getTunnelDurationSeconds() { return _tunnelDuration; }
|
|
|
|
public void setConfigurationKey(TunnelConfigurationSessionKey key) { _configKey = key; }
|
|
|
|
public TunnelConfigurationSessionKey getConfigurationKey() { return _configKey; }
|
|
|
|
public void setMaxPeakMessagesPerMin(long msgs) { _maxPeakMessagesPerMin = msgs; }
|
|
|
|
public long getMaxPeakMessagesPerMin() { return _maxPeakMessagesPerMin; }
|
|
|
|
public void setMaxAvgMessagesPerMin(long msgs) { _maxAvgMessagesPerMin = msgs; }
|
|
|
|
public long getMaxAvgMessagesPerMin() { return _maxAvgMessagesPerMin; }
|
|
|
|
public void setMaxPeakBytesPerMin(long bytes) { _maxPeakBytesPerMin = bytes; }
|
|
|
|
public long getMaxPeakBytesPerMin() { return _maxPeakBytesPerMin; }
|
|
|
|
public void setMaxAvgBytesPerMin(long bytes) { _maxAvgBytesPerMin = bytes; }
|
|
|
|
public long getMaxAvgBytesPerMin() { return _maxAvgBytesPerMin; }
|
|
|
|
public void setIncludeDummyTraffic(boolean include) { _includeDummyTraffic = include; }
|
|
|
|
public boolean getIncludeDummyTraffic() { return _includeDummyTraffic; }
|
|
|
|
public void setReorderMessages(boolean reorder) { _reorderMessages = reorder; }
|
|
|
|
public boolean getReorderMessages() { return _reorderMessages; }
|
|
|
|
public void setVerificationPublicKey(TunnelSigningPublicKey key) { _verificationPubKey = key; }
|
|
|
|
public TunnelSigningPublicKey getVerificationPublicKey() { return _verificationPubKey; }
|
|
|
|
public void setVerificationPrivateKey(TunnelSigningPrivateKey key) { _verificationPrivKey = key; }
|
|
|
|
public TunnelSigningPrivateKey getVerificationPrivateKey() { return _verificationPrivKey; }
|
|
|
|
public void setTunnelKey(TunnelSessionKey key) { _tunnelKey = key; }
|
|
|
|
public TunnelSessionKey getTunnelKey() { return _tunnelKey; }
|
|
|
|
public void setCertificate(Certificate cert) { _certificate = cert; }
|
|
|
|
public Certificate getCertificate() { return _certificate; }
|
2004-07-27 22:04:02 +00:00
|
|
|
public void setReplyTag(SessionTag tag) { _replyTag = tag; }
|
|
|
|
public SessionTag getReplyTag() { return _replyTag; }
|
|
|
|
public void setReplyKey(SessionKey key) { _replyKey = key; }
|
|
|
|
public SessionKey getReplyKey() { return _replyKey; }
|
|
|
|
public void setReplyTunnel(TunnelId id) { _replyTunnel = id; }
|
|
|
|
public TunnelId getReplyTunnel() { return _replyTunnel; }
|
|
|
|
public void setReplyPeer(Hash peer) { _replyPeer = peer; }
|
|
|
|
public Hash getReplyPeer() { return _replyPeer; }
|
2004-04-08 04:41:54 +00:00
|
|
|
|
|
|
|
public void readMessage(InputStream in, 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-04-08 04:41:54 +00:00
|
|
|
try {
|
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
|
|
|
_participantType = (int)DataHelper.readLong(in, 1);
|
|
|
|
if (_participantType != PARTICIPANT_TYPE_ENDPOINT) {
|
|
|
|
_nextRouter = new Hash();
|
|
|
|
_nextRouter.readBytes(in);
|
2004-07-27 22:04:02 +00:00
|
|
|
_nextTunnelId = new TunnelId();
|
|
|
|
_nextTunnelId.readBytes(in);
|
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
|
|
|
}
|
|
|
|
_tunnelId = new TunnelId();
|
|
|
|
_tunnelId.readBytes(in);
|
|
|
|
_tunnelDuration = DataHelper.readLong(in, 4);
|
|
|
|
_configKey = new TunnelConfigurationSessionKey();
|
|
|
|
_configKey.readBytes(in);
|
|
|
|
_maxPeakMessagesPerMin = DataHelper.readLong(in, 4);
|
|
|
|
_maxAvgMessagesPerMin = DataHelper.readLong(in, 4);
|
|
|
|
_maxPeakBytesPerMin = DataHelper.readLong(in, 4);
|
|
|
|
_maxAvgBytesPerMin = DataHelper.readLong(in, 4);
|
|
|
|
|
|
|
|
int flags = (int)DataHelper.readLong(in, 1);
|
|
|
|
_includeDummyTraffic = flagsIncludeDummy(flags);
|
|
|
|
_reorderMessages = flagsReorder(flags);
|
|
|
|
|
|
|
|
_verificationPubKey = new TunnelSigningPublicKey();
|
|
|
|
_verificationPubKey.readBytes(in);
|
|
|
|
if (_participantType == PARTICIPANT_TYPE_GATEWAY) {
|
|
|
|
_verificationPrivKey = new TunnelSigningPrivateKey();
|
|
|
|
_verificationPrivKey.readBytes(in);
|
|
|
|
}
|
|
|
|
if ( (_participantType == PARTICIPANT_TYPE_ENDPOINT) || (_participantType == PARTICIPANT_TYPE_GATEWAY) ) {
|
|
|
|
_tunnelKey = new TunnelSessionKey();
|
|
|
|
_tunnelKey.readBytes(in);
|
|
|
|
}
|
|
|
|
_certificate = new Certificate();
|
|
|
|
_certificate.readBytes(in);
|
2004-07-27 22:04:02 +00:00
|
|
|
_replyTag = new SessionTag();
|
|
|
|
_replyTag.readBytes(in);
|
|
|
|
_replyKey = new SessionKey();
|
|
|
|
_replyKey.readBytes(in);
|
|
|
|
_replyTunnel = new TunnelId();
|
|
|
|
_replyTunnel.readBytes(in);
|
|
|
|
_replyPeer = new Hash();
|
|
|
|
_replyPeer.readBytes(in);
|
2004-04-08 04:41:54 +00:00
|
|
|
} catch (DataFormatException dfe) {
|
|
|
|
throw new I2NPMessageException("Unable to load the message data", dfe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected byte[] writeMessage() throws I2NPMessageException, IOException {
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream(32);
|
|
|
|
try {
|
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.writeLong(os, 1, _participantType);
|
|
|
|
if (_participantType != PARTICIPANT_TYPE_ENDPOINT) {
|
|
|
|
_nextRouter.writeBytes(os);
|
2004-07-27 22:04:02 +00:00
|
|
|
_nextTunnelId.writeBytes(os);
|
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
|
|
|
}
|
|
|
|
_tunnelId.writeBytes(os);
|
|
|
|
DataHelper.writeLong(os, 4, _tunnelDuration);
|
|
|
|
_configKey.writeBytes(os);
|
|
|
|
|
|
|
|
DataHelper.writeLong(os, 4, _maxPeakMessagesPerMin);
|
|
|
|
DataHelper.writeLong(os, 4, _maxAvgMessagesPerMin);
|
|
|
|
DataHelper.writeLong(os, 4, _maxPeakBytesPerMin);
|
|
|
|
DataHelper.writeLong(os, 4, _maxAvgBytesPerMin);
|
|
|
|
|
|
|
|
long flags = getFlags();
|
|
|
|
DataHelper.writeLong(os, 1, flags);
|
|
|
|
|
|
|
|
_verificationPubKey.writeBytes(os);
|
|
|
|
if (_participantType == PARTICIPANT_TYPE_GATEWAY) {
|
|
|
|
_verificationPrivKey.writeBytes(os);
|
|
|
|
}
|
|
|
|
if ( (_participantType == PARTICIPANT_TYPE_ENDPOINT) || (_participantType == PARTICIPANT_TYPE_GATEWAY) ) {
|
|
|
|
_tunnelKey.writeBytes(os);
|
|
|
|
}
|
|
|
|
_certificate.writeBytes(os);
|
2004-07-27 22:04:02 +00:00
|
|
|
_replyTag.writeBytes(os);
|
|
|
|
_replyKey.writeBytes(os);
|
|
|
|
_replyTunnel.writeBytes(os);
|
|
|
|
_replyPeer.writeBytes(os);
|
2004-04-08 04:41:54 +00:00
|
|
|
} catch (Throwable t) {
|
|
|
|
throw new I2NPMessageException("Error writing out the message data", t);
|
|
|
|
}
|
|
|
|
return os.toByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean flagsIncludeDummy(long flags) {
|
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 (0 != (flags & FLAG_DUMMY));
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
private boolean flagsReorder(long flags) {
|
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 (0 != (flags & FLAG_REORDER));
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private long getFlags() {
|
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
|
|
|
long val = 0L;
|
|
|
|
if (getIncludeDummyTraffic())
|
|
|
|
val = val | FLAG_DUMMY;
|
|
|
|
if (getReorderMessages())
|
|
|
|
val = val | FLAG_REORDER;
|
|
|
|
return val;
|
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 (int)(DataHelper.hashCode(getCertificate()) +
|
2004-07-27 22:04:02 +00:00
|
|
|
DataHelper.hashCode(getConfigurationKey()) +
|
|
|
|
DataHelper.hashCode(getNextRouter()) +
|
|
|
|
DataHelper.hashCode(getNextTunnelId()) +
|
|
|
|
DataHelper.hashCode(getReplyPeer()) +
|
|
|
|
DataHelper.hashCode(getReplyTunnel()) +
|
|
|
|
DataHelper.hashCode(getTunnelId()) +
|
|
|
|
DataHelper.hashCode(getTunnelKey()) +
|
|
|
|
DataHelper.hashCode(getVerificationPrivateKey()) +
|
|
|
|
DataHelper.hashCode(getVerificationPublicKey()) +
|
|
|
|
(getIncludeDummyTraffic() ? 1 : 0) +
|
|
|
|
getMaxAvgBytesPerMin() +
|
|
|
|
getMaxAvgMessagesPerMin() +
|
|
|
|
getMaxPeakBytesPerMin() +
|
|
|
|
getMaxPeakMessagesPerMin() +
|
|
|
|
getParticipantType() +
|
|
|
|
(getReorderMessages() ? 1 : 0) +
|
|
|
|
getTunnelDurationSeconds());
|
2004-04-08 04:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object object) {
|
|
|
|
if ( (object != null) && (object instanceof TunnelCreateMessage) ) {
|
|
|
|
TunnelCreateMessage msg = (TunnelCreateMessage)object;
|
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.eq(getCertificate(), msg.getCertificate()) &&
|
|
|
|
DataHelper.eq(getConfigurationKey(), msg.getConfigurationKey()) &&
|
|
|
|
DataHelper.eq(getNextRouter(), msg.getNextRouter()) &&
|
2004-07-27 22:04:02 +00:00
|
|
|
DataHelper.eq(getNextTunnelId(), msg.getNextTunnelId()) &&
|
|
|
|
DataHelper.eq(getReplyTag(), msg.getReplyTag()) &&
|
|
|
|
DataHelper.eq(getReplyKey(), msg.getReplyKey()) &&
|
|
|
|
DataHelper.eq(getReplyTunnel(), msg.getReplyTunnel()) &&
|
|
|
|
DataHelper.eq(getReplyPeer(), msg.getReplyPeer()) &&
|
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(getTunnelId(), msg.getTunnelId()) &&
|
|
|
|
DataHelper.eq(getTunnelKey(), msg.getTunnelKey()) &&
|
|
|
|
DataHelper.eq(getVerificationPrivateKey(), msg.getVerificationPrivateKey()) &&
|
|
|
|
DataHelper.eq(getVerificationPublicKey(), msg.getVerificationPublicKey()) &&
|
|
|
|
(getIncludeDummyTraffic() == msg.getIncludeDummyTraffic()) &&
|
|
|
|
(getMaxAvgBytesPerMin() == msg.getMaxAvgBytesPerMin()) &&
|
|
|
|
(getMaxAvgMessagesPerMin() == msg.getMaxAvgMessagesPerMin()) &&
|
|
|
|
(getMaxPeakBytesPerMin() == msg.getMaxPeakBytesPerMin()) &&
|
|
|
|
(getMaxPeakMessagesPerMin() == msg.getMaxPeakMessagesPerMin()) &&
|
|
|
|
(getParticipantType() == msg.getParticipantType()) &&
|
|
|
|
(getReorderMessages() == msg.getReorderMessages()) &&
|
|
|
|
(getTunnelDurationSeconds() == msg.getTunnelDurationSeconds());
|
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("[TunnelCreateMessage: ");
|
|
|
|
buf.append("\n\tParticipant Type: ").append(getParticipantType());
|
|
|
|
buf.append("\n\tCertificate: ").append(getCertificate());
|
|
|
|
buf.append("\n\tConfiguration Key: ").append(getConfigurationKey());
|
|
|
|
buf.append("\n\tNext Router: ").append(getNextRouter());
|
2004-07-27 22:04:02 +00:00
|
|
|
buf.append("\n\tNext Tunnel: ").append(getNextTunnelId());
|
|
|
|
buf.append("\n\tReply Tag: ").append(getReplyTag());
|
|
|
|
buf.append("\n\tReply Key: ").append(getReplyKey());
|
|
|
|
buf.append("\n\tReply Tunnel: ").append(getReplyTunnel());
|
|
|
|
buf.append("\n\tReply Peer: ").append(getReplyPeer());
|
2004-04-08 04:41:54 +00:00
|
|
|
buf.append("\n\tTunnel ID: ").append(getTunnelId());
|
|
|
|
buf.append("\n\tTunnel Key: ").append(getTunnelKey());
|
|
|
|
buf.append("\n\tVerification Private Key: ").append(getVerificationPrivateKey());
|
|
|
|
buf.append("\n\tVerification Public Key: ").append(getVerificationPublicKey());
|
|
|
|
buf.append("\n\tInclude Dummy Traffic: ").append(getIncludeDummyTraffic());
|
|
|
|
buf.append("\n\tMax Avg Bytes / Minute: ").append(getMaxAvgBytesPerMin());
|
|
|
|
buf.append("\n\tMax Peak Bytes / Minute: ").append(getMaxPeakBytesPerMin());
|
|
|
|
buf.append("\n\tMax Avg Messages / Minute: ").append(getMaxAvgMessagesPerMin());
|
|
|
|
buf.append("\n\tMax Peak Messages / Minute: ").append(getMaxPeakMessagesPerMin());
|
|
|
|
buf.append("\n\tReorder Messages: ").append(getReorderMessages());
|
|
|
|
buf.append("\n\tTunnel Duration (seconds): ").append(getTunnelDurationSeconds());
|
|
|
|
buf.append("]");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
|
|
|
}
|