This commit is contained in:
zzz
2011-09-28 17:05:38 +00:00
parent 7bac7aaaf3
commit 273e940fa1
17 changed files with 49 additions and 38 deletions

View File

@@ -292,11 +292,9 @@ class HTTPResponseOutputStream extends FilterOutputStream {
} finally {
if (_log.shouldLog(Log.INFO) && (_in != null))
_log.info("After decompression, written=" + written +
(_in != null ?
" read=" + _in.getTotalRead()
+ ", expanded=" + _in.getTotalExpanded() + ", remaining=" + _in.getRemaining()
+ ", finished=" + _in.getFinished()
: ""));
+ ", finished=" + _in.getFinished());
if (ba != null)
_cache.release(ba);
if (_out != null) try {

View File

@@ -212,10 +212,11 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
}
}
if (sockMgr == null) {
l.log("Invalid I2CP configuration");
throw new IllegalArgumentException("Socket manager could not be created");
}
// can't be null unless we limit the loop above
//if (sockMgr == null) {
// l.log("Invalid I2CP configuration");
// throw new IllegalArgumentException("Socket manager could not be created");
//}
l.log("Tunnels ready for client: " + handlerName);
} // else delay creating session until createI2PSocket() is called
@@ -556,7 +557,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
if (localPort == 0) {
localPort = ss.getLocalPort();
}
notifyEvent("clientLocalPort", new Integer(ss.getLocalPort()));
notifyEvent("clientLocalPort", Integer.valueOf(ss.getLocalPort()));
// duplicates message in constructor
//l.log("Listening for clients on port " + localPort + " of " + getTunnel().listenHost);

View File

@@ -412,9 +412,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
protected static String formatHeaders(Map<String, List<String>> headers, StringBuilder command) {
StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
buf.append(command.toString().trim()).append("\r\n");
for (Iterator<String> iter = headers.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
for(String val: headers.get(name)) {
for (Map.Entry<String, List<String>> e : headers.entrySet()) {
String name = e.getKey();
for(String val: e.getValue()) {
buf.append(name.trim()).append(": ").append(val.trim()).append("\r\n");
}
}

View File

@@ -311,7 +311,7 @@ class Connection {
int windowSize;
int remaining;
synchronized (_outboundPackets) {
_outboundPackets.put(new Long(packet.getSequenceNum()), packet);
_outboundPackets.put(Long.valueOf(packet.getSequenceNum()), packet);
windowSize = _options.getWindowSize();
remaining = windowSize - _outboundPackets.size() ;
_outboundPackets.notifyAll();
@@ -441,7 +441,7 @@ class Connection {
if (acked != null) {
for (int i = 0; i < acked.size(); i++) {
PacketLocal p = acked.get(i);
_outboundPackets.remove(new Long(p.getSequenceNum()));
_outboundPackets.remove(Long.valueOf(p.getSequenceNum()));
_ackedPackets++;
if (p.getNumSends() > 1) {
_activeResends--;
@@ -1129,7 +1129,7 @@ class Connection {
synchronized (_outboundPackets) {
if (_packet.getSequenceNum() == _highestAckedThrough + 1)
isLowest = true;
if (_outboundPackets.containsKey(new Long(_packet.getSequenceNum())))
if (_outboundPackets.containsKey(Long.valueOf(_packet.getSequenceNum())))
resend = true;
}
if ( (resend) && (_packet.getAckTime() <= 0) ) {

View File

@@ -229,8 +229,8 @@ class MessageInputStream extends InputStream {
_highestReadyBlockId = messageId;
long cur = _highestReadyBlockId + 1;
// now pull in any previously pending blocks
while (_notYetReadyBlocks.containsKey(new Long(cur))) {
ByteArray ba = _notYetReadyBlocks.remove(new Long(cur));
while (_notYetReadyBlocks.containsKey(Long.valueOf(cur))) {
ByteArray ba = _notYetReadyBlocks.remove(Long.valueOf(cur));
if ( (ba != null) && (ba.getData() != null) && (ba.getValid() > 0) ) {
_readyDataBlocks.add(ba);
}
@@ -245,9 +245,9 @@ class MessageInputStream extends InputStream {
if (_log.shouldLog(Log.DEBUG))
_log.debug("message is out of order: " + messageId);
if (_locallyClosed) // dont need the payload, just the msgId in order
_notYetReadyBlocks.put(new Long(messageId), new ByteArray(null));
_notYetReadyBlocks.put(Long.valueOf(messageId), new ByteArray(null));
else
_notYetReadyBlocks.put(new Long(messageId), payload);
_notYetReadyBlocks.put(Long.valueOf(messageId), payload);
_dataLock.notifyAll();
}
}

View File

@@ -355,10 +355,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
_socket = new Socket(_hostname, _portNum);
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
_out = _socket.getOutputStream();
synchronized (_out) {
_out.write(I2PClient.PROTOCOL_BYTE);
_out.flush();
}
_out.write(I2PClient.PROTOCOL_BYTE);
_out.flush();
_writer = new ClientWriterRunner(_out, this);
InputStream in = _socket.getInputStream();
_reader = new I2CPMessageReader(in, this);

View File

@@ -78,10 +78,8 @@ class I2PSimpleSession extends I2PSessionImpl2 {
else
_socket = new Socket(_hostname, _portNum);
_out = _socket.getOutputStream();
synchronized (_out) {
_out.write(I2PClient.PROTOCOL_BYTE);
_out.flush();
}
_out.write(I2PClient.PROTOCOL_BYTE);
_out.flush();
_writer = new ClientWriterRunner(_out, this);
InputStream in = _socket.getInputStream();
_reader = new I2CPMessageReader(in, this);

View File

@@ -432,6 +432,7 @@ public class BlockfileNamingService extends DummyNamingService {
* @param source may be null
* @throws RuntimeException
*/
/****
private void addEntry(SkipList sl, String key, Destination dest, String source) {
Properties props = new Properties();
props.setProperty(PROP_ADDED, Long.toString(_context.clock().now()));
@@ -439,6 +440,7 @@ public class BlockfileNamingService extends DummyNamingService {
props.setProperty(PROP_SOURCE, source);
addEntry(sl, key, dest, props);
}
****/
/**
* Caller must synchronize
@@ -476,9 +478,11 @@ public class BlockfileNamingService extends DummyNamingService {
* @return null without exception on error (logs only)
* @since 0.8.9
*/
/****
private String getReverseEntry(Destination dest) {
return getReverseEntry(dest.calculateHash());
}
****/
/**
* Caller must synchronize.

View File

@@ -126,6 +126,7 @@ public class SingleFileNamingService extends NamingService {
_log.warn("Error loading hosts file " + _file, ioe);
return null;
} finally {
if (in != null) try { in.close(); } catch (IOException ioe) {}
releaseReadLock();
}
}

View File

@@ -519,9 +519,11 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
}
/** A basic symmetric encryption/decryption test. */
/****
public static boolean self_test() {
return self_test(_BLOCK_SIZE);
}
****/
// Rijndael own methods
//...........................................................................
@@ -745,6 +747,7 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
}
/** A basic symmetric encryption/decryption test for a given key size. */
/****
private static boolean self_test(int keysize) {
if (_RDEBUG) trace(_IN, "self_test(" + keysize + ")");
boolean ok = false;
@@ -795,6 +798,7 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
if (_RDEBUG) trace(_OUT, "self_test()");
return ok;
}
****/
/**
* Return The number of rounds for a given Rijndael's key and block sizes.
@@ -894,9 +898,11 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
// main(): use to generate the Intermediate Values KAT
//...........................................................................
/****
public static void main(String[] args) {
self_test(16);
self_test(24);
self_test(32);
}
}
****/
}

View File

@@ -298,10 +298,12 @@ public class ElGamalAESEngine {
* @param foundKey out parameter. Data must be unset when called; may be filled with a new sessionKey found during decryption
* @return decrypted data or null on failure
*/
/****
private byte[] decryptAESBlock(byte encrypted[], SessionKey key, byte iv[],
byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
return decryptAESBlock(encrypted, 0, encrypted.length, key, iv, sentTag, foundTags, foundKey);
}
****/
/*
* Note: package private for ElGamalTest.testAES()

View File

@@ -34,7 +34,7 @@ public class HMAC256Generator extends HMACGenerator {
return new I2PHMac(new Sha256ForMAC());
}
private class Sha256ForMAC extends Sha256Standalone implements Digest {
private static class Sha256ForMAC extends Sha256Standalone implements Digest {
public String getAlgorithmName() { return "sha256 for hmac"; }
public int getDigestSize() { return 32; }
public int doFinal(byte[] out, int outOff) {

View File

@@ -596,10 +596,10 @@ public class TransientSessionKeyManager extends SessionKeyManager {
}
int total = 0;
long now = _context.clock().now();
for (Iterator<SessionKey> iter = inboundSets.keySet().iterator(); iter.hasNext();) {
SessionKey skey = iter.next();
for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) {
SessionKey skey = e.getKey();
Set<TagSet> sets = new TreeSet(new TagSetComparator());
sets.addAll(inboundSets.get(skey));
sets.addAll(e.getValue());
buf.append("<tr><td><b>Session key</b>: ").append(skey.toBase64()).append("</td>" +
"<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" +
"<tr><td colspan=\"2\"><ul>");
@@ -653,9 +653,9 @@ public class TransientSessionKeyManager extends SessionKeyManager {
* Just for the HTML method above so we can see what's going on easier
* Earliest first
*/
private static class TagSetComparator implements Comparator {
public int compare(Object l, Object r) {
return (int) (((TagSet)l).getDate() - ((TagSet)r).getDate());
private static class TagSetComparator implements Comparator<TagSet> {
public int compare(TagSet l, TagSet r) {
return (int) (l.getDate() - r.getDate());
}
}

View File

@@ -33,6 +33,7 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import net.i2p.util.RandomSource;
/**
* This class represents a NTP message, as specified in RFC 2030. The message
@@ -399,7 +400,7 @@ public class NtpMessage {
// low order bits of the timestamp with a random, unbiased
// bitstring, both to avoid systematic roundoff errors and as
// a means of loop detection and replay detection.
array[7+pointer] = (byte) (Math.random()*255.0);
array[7+pointer] = (byte) (RandomSource.getInstance().nextInt());
}

View File

@@ -321,14 +321,16 @@ public class Timestamper implements Runnable {
_context.getProperty(PROP_CONCURRING_SERVERS, DEFAULT_CONCURRING_SERVERS)));
}
/****
public static void main(String args[]) {
System.setProperty(PROP_DISABLED, "false");
System.setProperty(PROP_QUERY_FREQUENCY, "30000");
I2PAppContext ctx = I2PAppContext.getGlobalContext();
I2PAppContext.getGlobalContext();
for (int i = 0; i < 5*60*1000; i += 61*1000) {
try { Thread.sleep(61*1000); } catch (InterruptedException ie) {}
}
}
****/
/**
* Interface to receive update notifications for when we query the time

View File

@@ -443,7 +443,7 @@ public class BlockFile {
public BSkipList makeIndex(String name, Serializer key, Serializer val) throws IOException {
if(metaIndex.get(name) != null) { throw new IOException("Index already exists"); }
int page = allocPage();
metaIndex.put(name, new Integer(page));
metaIndex.put(name, Integer.valueOf(page));
BSkipList.init(this, page, spanSize);
BSkipList bsl = new BSkipList(spanSize, this, page, key, val, true);
openIndices.put(name, bsl);

View File

@@ -103,7 +103,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
protected final static long DONT_FAIL_PERIOD = 10*60*1000;
/** don't probe or broadcast data, just respond and search when explicitly needed */
private final boolean QUIET = false;
private static final boolean QUIET = false;
public static final String PROP_ENFORCE_NETID = "router.networkDatabase.enforceNetId";
private static final boolean DEFAULT_ENFORCE_NETID = false;