2006-02-17 jrandom
* Disable the message history log file by default (duh - feel free to delete messageHistory.txt after upgrading. thanks deathfatty!) * Limit the size of the inbound tunnel build request queue so we don't get an insane backlog of requests that we're bound to reject, and adjust the queue processing so we keep on churning through them when we've got a backlog. * Small fixes for the multiuser syndie operation (thanks Complication!) * Renamed modified PRNG classes that were imported from gnu-crypto so we don't conflict with JVMs using that as a JCE provider (thanks blx!)
This commit is contained in:
@ -47,9 +47,9 @@ import java.util.Map;
|
||||
* <p>An abstract class to facilitate implementing PRNG algorithms.</p>
|
||||
*
|
||||
* Modified slightly by jrandom for I2P (removing unneeded exceptions)
|
||||
* @version $Revision: 1.12 $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public abstract class BasePRNG implements IRandom {
|
||||
public abstract class BasePRNGStandalone implements IRandom {
|
||||
|
||||
// Constants and variables
|
||||
// -------------------------------------------------------------------------
|
||||
@ -74,7 +74,7 @@ public abstract class BasePRNG implements IRandom {
|
||||
*
|
||||
* @param name the canonical name of this instance.
|
||||
*/
|
||||
protected BasePRNG(String name) {
|
||||
protected BasePRNGStandalone(String name) {
|
||||
super();
|
||||
|
||||
this.name = name;
|
@ -93,10 +93,11 @@ import net.i2p.crypto.CryptixAESKeyCache;
|
||||
*
|
||||
* Modified by jrandom for I2P to use Bouncycastle's SHA256, Cryptix's AES,
|
||||
* to strip out some unnecessary dependencies and increase the buffer size.
|
||||
* Renamed from Fortuna to FortunaStandalone so it doesn't conflict with the
|
||||
* gnu-crypto implementation, which has been imported into GNU/classpath
|
||||
*
|
||||
*/
|
||||
public class Fortuna extends BasePRNG
|
||||
implements Serializable, RandomEventListener
|
||||
public class FortunaStandalone extends BasePRNGStandalone implements Serializable, RandomEventListener
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 0xFACADE;
|
||||
@ -113,7 +114,7 @@ public class Fortuna extends BasePRNG
|
||||
|
||||
public static final String SEED = "gnu.crypto.prng.fortuna.seed";
|
||||
|
||||
public Fortuna()
|
||||
public FortunaStandalone()
|
||||
{
|
||||
super("Fortuna i2p");
|
||||
generator = new Generator();
|
||||
@ -215,7 +216,7 @@ public class Fortuna extends BasePRNG
|
||||
* right; Fortuna itself is basically a wrapper around this generator
|
||||
* that manages reseeding in a secure way.
|
||||
*/
|
||||
public static class Generator extends BasePRNG implements Cloneable
|
||||
public static class Generator extends BasePRNGStandalone implements Cloneable
|
||||
{
|
||||
|
||||
private static final int LIMIT = 1 << 20;
|
||||
@ -341,7 +342,7 @@ public class Fortuna extends BasePRNG
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
Fortuna f = new Fortuna();
|
||||
FortunaStandalone f = new FortunaStandalone();
|
||||
java.util.HashMap props = new java.util.HashMap();
|
||||
byte initSeed[] = new byte[1234];
|
||||
new java.util.Random().nextBytes(initSeed);
|
@ -14,7 +14,7 @@ import java.security.SecureRandom;
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.crypto.EntropyHarvester;
|
||||
|
||||
import gnu.crypto.prng.Fortuna;
|
||||
import gnu.crypto.prng.FortunaStandalone;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -26,13 +26,13 @@ import java.io.IOException;
|
||||
*
|
||||
*/
|
||||
public class FortunaRandomSource extends RandomSource implements EntropyHarvester {
|
||||
private Fortuna _fortuna;
|
||||
private FortunaStandalone _fortuna;
|
||||
private double _nextGaussian;
|
||||
private boolean _haveNextGaussian;
|
||||
|
||||
public FortunaRandomSource(I2PAppContext context) {
|
||||
super(context);
|
||||
_fortuna = new Fortuna();
|
||||
_fortuna = new FortunaStandalone();
|
||||
byte seed[] = new byte[1024];
|
||||
if (initSeed(seed)) {
|
||||
_fortuna.seed(seed);
|
||||
|
13
history.txt
13
history.txt
@ -1,4 +1,15 @@
|
||||
$Id: history.txt,v 1.401 2006/02/16 05:33:31 jrandom Exp $
|
||||
$Id: history.txt,v 1.402 2006/02/16 15:44:07 jrandom Exp $
|
||||
|
||||
2006-02-17 jrandom
|
||||
* Disable the message history log file by default (duh - feel free to
|
||||
delete messageHistory.txt after upgrading. thanks deathfatty!)
|
||||
* Limit the size of the inbound tunnel build request queue so we don't
|
||||
get an insane backlog of requests that we're bound to reject, and adjust
|
||||
the queue processing so we keep on churning through them when we've got
|
||||
a backlog.
|
||||
* Small fixes for the multiuser syndie operation (thanks Complication!)
|
||||
* Renamed modified PRNG classes that were imported from gnu-crypto so we
|
||||
don't conflict with JVMs using that as a JCE provider (thanks blx!)
|
||||
|
||||
* 2006-02-16 0.6.1.10 released
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class MessageHistory {
|
||||
|
||||
/** config property determining whether we want to debug with the message history */
|
||||
public final static String PROP_KEEP_MESSAGE_HISTORY = "router.keepHistory";
|
||||
public final static boolean DEFAULT_KEEP_MESSAGE_HISTORY = true;
|
||||
public final static boolean DEFAULT_KEEP_MESSAGE_HISTORY = false;
|
||||
/** config property determining where we want to log the message history, if we're keeping one */
|
||||
public final static String PROP_MESSAGE_HISTORY_FILENAME = "router.historyFilename";
|
||||
public final static String DEFAULT_MESSAGE_HISTORY_FILENAME = "messageHistory.txt";
|
||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
||||
*
|
||||
*/
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.344 $ $Date: 2006/02/16 05:33:29 $";
|
||||
public final static String ID = "$Revision: 1.345 $ $Date: 2006/02/16 15:44:12 $";
|
||||
public final static String VERSION = "0.6.1.10";
|
||||
public final static long BUILD = 0;
|
||||
public final static long BUILD = 1;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -199,7 +199,9 @@ class BuildExecutor implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
_handler.handleInboundRequests();
|
||||
boolean pendingRemaining = _handler.handleInboundRequests();
|
||||
if (pendingRemaining)
|
||||
_repoll = true;
|
||||
|
||||
wanted.clear();
|
||||
pools.clear();
|
||||
|
@ -57,9 +57,17 @@ class BuildHandler {
|
||||
}
|
||||
|
||||
private static final int MAX_HANDLE_AT_ONCE = 5;
|
||||
/**
|
||||
* Don't keep too many messages on the queue - when it reaches this size, delete the oldest request
|
||||
*/
|
||||
private static final int MAX_QUEUED_REQUESTS = MAX_HANDLE_AT_ONCE * (BuildRequestor.REQUEST_TIMEOUT/1000);
|
||||
private static final int NEXT_HOP_LOOKUP_TIMEOUT = 5*1000;
|
||||
|
||||
void handleInboundRequests() {
|
||||
/**
|
||||
* Blocking call to handle a few of the pending inbound requests, returning true if
|
||||
* there are remaining requeusts we skipped over
|
||||
*/
|
||||
boolean handleInboundRequests() {
|
||||
List handled = null;
|
||||
synchronized (_inboundBuildMessages) {
|
||||
int toHandle = _inboundBuildMessages.size();
|
||||
@ -101,6 +109,11 @@ class BuildHandler {
|
||||
handleRequestAsInboundEndpoint(state);
|
||||
}
|
||||
}
|
||||
|
||||
// anything else?
|
||||
synchronized (_inboundBuildMessages) {
|
||||
return _inboundBuildMessages.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
void handleInboundReplies() {
|
||||
@ -503,6 +516,8 @@ class BuildHandler {
|
||||
_log.warn("Dropping the reply " + reqId + ", as we used to be building that");
|
||||
} else {
|
||||
synchronized (_inboundBuildMessages) {
|
||||
while (_inboundBuildMessages.size() > MAX_QUEUED_REQUESTS)
|
||||
_inboundBuildMessages.remove(0); // keep the newest requests first, to offer better service
|
||||
_inboundBuildMessages.add(new BuildMessageState(receivedMessage, from, fromHash));
|
||||
}
|
||||
_exec.repoll();
|
||||
|
Reference in New Issue
Block a user