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

Skip to content
Snippets Groups Projects
Commit 54aeab15 authored by jrandom's avatar jrandom Committed by zzz
Browse files

send the full RouterInfo in the STS validation, not just the RouterIdentity...

send the full RouterInfo in the STS validation, not just the RouterIdentity (and in turn, store that RouterInfo in the local netDb)
logging
parent 91f83277
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ import net.i2p.data.DataFormatException; ...@@ -27,6 +27,7 @@ import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.data.RouterIdentity; import net.i2p.data.RouterIdentity;
import net.i2p.data.RouterInfo;
import net.i2p.data.SessionKey; import net.i2p.data.SessionKey;
import net.i2p.data.Signature; import net.i2p.data.Signature;
import net.i2p.data.i2np.I2NPMessage; import net.i2p.data.i2np.I2NPMessage;
...@@ -35,6 +36,7 @@ import net.i2p.router.OutNetMessage; ...@@ -35,6 +36,7 @@ import net.i2p.router.OutNetMessage;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.transport.BandwidthLimitedInputStream; import net.i2p.router.transport.BandwidthLimitedInputStream;
import net.i2p.router.transport.BandwidthLimitedOutputStream; import net.i2p.router.transport.BandwidthLimitedOutputStream;
import net.i2p.router.transport.FIFOBandwidthLimiter;
import net.i2p.util.I2PThread; import net.i2p.util.I2PThread;
import net.i2p.util.Log; import net.i2p.util.Log;
import net.i2p.util.NativeBigInteger; import net.i2p.util.NativeBigInteger;
...@@ -150,14 +152,14 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { ...@@ -150,14 +152,14 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener {
} }
protected boolean identifyStationToStation() throws IOException, DataFormatException { protected boolean identifyStationToStation() throws IOException, DataFormatException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(512); ByteArrayOutputStream baos = new ByteArrayOutputStream(10*1024);
_context.router().getRouterInfo().getIdentity().writeBytes(baos); _context.router().getRouterInfo().writeBytes(baos);
Hash keyHash = _context.sha().calculateHash(_key.getData()); Hash keyHash = _context.sha().calculateHash(_key.getData());
keyHash.writeBytes(baos); keyHash.writeBytes(baos);
Signature sig = _context.dsa().sign(baos.toByteArray(), _context.keyManager().getSigningPrivateKey()); Signature sig = _context.dsa().sign(baos.toByteArray(), _context.keyManager().getSigningPrivateKey());
sig.writeBytes(baos); sig.writeBytes(baos);
byte encr[] = _context.AESEngine().safeEncrypt(baos.toByteArray(), _key, _iv, 1024); byte encr[] = _context.AESEngine().safeEncrypt(baos.toByteArray(), _key, _iv, 10*1024);
DataHelper.writeLong(_out, 2, encr.length); DataHelper.writeLong(_out, 2, encr.length);
_out.write(encr); _out.write(encr);
...@@ -172,8 +174,9 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { ...@@ -172,8 +174,9 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener {
throw new DataFormatException("Unable to decrypt - failed exchange?"); throw new DataFormatException("Unable to decrypt - failed exchange?");
ByteArrayInputStream bais = new ByteArrayInputStream(decr); ByteArrayInputStream bais = new ByteArrayInputStream(decr);
_remoteIdentity = new RouterIdentity(); RouterInfo peer = new RouterInfo();
_remoteIdentity.readBytes(bais); peer.readBytes(bais);
_remoteIdentity = peer.getIdentity();
Hash peerKeyHash = new Hash(); Hash peerKeyHash = new Hash();
peerKeyHash.readBytes(bais); peerKeyHash.readBytes(bais);
...@@ -187,7 +190,10 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { ...@@ -187,7 +190,10 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener {
rsig.readBytes(bais); rsig.readBytes(bais);
byte signedData[] = new byte[decr.length - rsig.getData().length]; byte signedData[] = new byte[decr.length - rsig.getData().length];
System.arraycopy(decr, 0, signedData, 0, signedData.length); System.arraycopy(decr, 0, signedData, 0, signedData.length);
return _context.dsa().verifySignature(rsig, signedData, _remoteIdentity.getSigningPublicKey()); boolean valid = _context.dsa().verifySignature(rsig, signedData, _remoteIdentity.getSigningPublicKey());
if (valid)
_context.netDb().store(_remoteIdentity.getHash(), peer);
return valid;
} }
protected final static int ESTABLISHMENT_TIMEOUT = 10*1000; // 10 second lag (not necessarily for the entire establish) protected final static int ESTABLISHMENT_TIMEOUT = 10*1000; // 10 second lag (not necessarily for the entire establish)
...@@ -311,6 +317,16 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { ...@@ -311,6 +317,16 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener {
if (_log.shouldLog(Log.ERROR)) if (_log.shouldLog(Log.ERROR))
_log.error("messages expired on the queue to " + _remoteIdentity.getHash().toBase64() + ": " + pending.toString()); _log.error("messages expired on the queue to " + _remoteIdentity.getHash().toBase64() + ": " + pending.toString());
if (_out instanceof BandwidthLimitedOutputStream) {
BandwidthLimitedOutputStream o = (BandwidthLimitedOutputStream)_out;
FIFOBandwidthLimiter.Request req = o.getCurrentRequest();
if (req != null) {
if (_log.shouldLog(Log.ERROR))
_log.error("When the messages timed out, our outbound con requested "
+ req.getTotalOutboundRequested() + " bytes (" + req.getPendingOutboundRequested()
+ " pending) after waiting " + (_context.clock().now() - req.getRequestTime()) + "ms");
}
}
// do we really want to give them a comm error because they're so.damn.slow reading their stream? // do we really want to give them a comm error because they're so.damn.slow reading their stream?
_context.profileManager().commErrorOccurred(_remoteIdentity.getHash()); _context.profileManager().commErrorOccurred(_remoteIdentity.getHash());
...@@ -538,7 +554,7 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { ...@@ -538,7 +554,7 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener {
long end = _context.clock().now(); long end = _context.clock().now();
long timeLeft = exp - end; long timeLeft = exp - end;
msg.timestamp("TCPConnection.runner.doSend sent and flushed"); msg.timestamp("TCPConnection.runner.doSend sent and flushed " + data.length + " bytes");
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Message " + msg.getMessageType() _log.info("Message " + msg.getMessageType()
......
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