2004-10-08 jrandom

* Don't kill the establisher threads during a soft restart.
    * Attempt to validate the peer's routerInfo earlier during handshaking.
    * Revamp the AESOutputStream so it doesn't allocate any temporary objects
      during its operation.
This commit is contained in:
jrandom
2004-10-08 18:38:48 +00:00
committed by zzz
parent ff8674bca9
commit 730da3aa27
7 changed files with 161 additions and 58 deletions

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.46 $ $Date: 2004/10/07 14:19:52 $";
public final static String ID = "$Revision: 1.47 $ $Date: 2004/10/07 21:08:11 $";
public final static String VERSION = "0.4.1.1";
public final static long BUILD = 12;
public final static long BUILD = 13;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -437,7 +437,15 @@ public class ConnectionBuilder {
}
_actualPeer = peer;
return true;
try {
_context.netDb().store(peer.getIdentity().getHash(), peer);
return true;
} catch (IllegalArgumentException iae) {
fail("Peer sent us bad info - " + _target.getIdentity().getHash().toBase64().substring(0,6)
+ ": " + iae.getMessage());
return false;
}
} catch (IOException ioe) {
fail("Error reading the verified info from "
+ _target.getIdentity().calculateHash().toBase64().substring(0,6)
@ -584,7 +592,15 @@ public class ConnectionBuilder {
}
_actualPeer = peer;
return true;
try {
_context.netDb().store(peer.getIdentity().getHash(), peer);
return true;
} catch (IllegalArgumentException iae) {
fail("Peer sent us bad info - " + _target.getIdentity().getHash().toBase64().substring(0,6)
+ ": " + iae.getMessage());
return false;
}
} catch (IOException ioe) {
fail("Error reading the verified info from "
+ _target.getIdentity().calculateHash().toBase64().substring(0,6)
@ -645,7 +661,6 @@ public class ConnectionBuilder {
//_connectionOut = _rawOut;
Hash peer = _actualPeer.getIdentity().getHash();
_context.netDb().store(peer, _actualPeer);
_transport.getTagManager().replaceTag(peer, _nextConnectionTag, _key);
}

View File

@ -443,7 +443,14 @@ public class ConnectionHandler {
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddhhmmssSSS");
props.setProperty("SKEW", fmt.format(new Date(_context.clock().now())));
} else {
status = STATUS_OK;
try {
_context.netDb().store(_actualPeer.getIdentity().getHash(), _actualPeer);
status = STATUS_OK;
} catch (IllegalArgumentException iae) {
// bad peer info
status = STATUS_UNKNOWN;
props.setProperty("REASON", "RouterInfoFailed");
}
}
baos.write(status);
@ -460,7 +467,7 @@ public class ConnectionHandler {
verification.writeBytes(_rawOut);
_rawOut.flush();
return handleStatus(status, clockSkew);
return handleStatus(status, clockSkew);
} catch (IOException ioe) {
fail("Error writing the peer info to " + _from
+ ": " + ioe.getMessage(), ioe);
@ -601,7 +608,14 @@ public class ConnectionHandler {
} else if (!sigOk) {
status = STATUS_SIGNATURE_FAILED;
} else {
status = STATUS_OK;
try {
_context.netDb().store(_actualPeer.getIdentity().getHash(), _actualPeer);
status = STATUS_OK;
} catch (IllegalArgumentException iae) {
// bad peer info
status = STATUS_UNKNOWN;
props.setProperty("REASON", "RouterInfoFailed");
}
}
if (_actualPeer.getIdentity().getHash().equals(_context.routerHash())) {
@ -827,7 +841,6 @@ public class ConnectionHandler {
//_connectionOut = _rawOut;
Hash peer = _actualPeer.getIdentity().getHash();
_context.netDb().store(peer, _actualPeer);
_transport.getTagManager().replaceTag(peer, _nextConnectionTag, _key);
}

View File

@ -24,6 +24,10 @@ public class TCPConnectionEstablisher implements Runnable {
public void run() {
while (true) {
RouterInfo info = _transport.getNextPeer();
if (info == null) {
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
continue;
}
ConnectionBuilder cb = new ConnectionBuilder(_context, _transport, info);
TCPConnection con = null;