forked from I2P_Developers/i2p.i2p
findbugs
This commit is contained in:
@@ -292,11 +292,9 @@ class HTTPResponseOutputStream extends FilterOutputStream {
|
|||||||
} finally {
|
} finally {
|
||||||
if (_log.shouldLog(Log.INFO) && (_in != null))
|
if (_log.shouldLog(Log.INFO) && (_in != null))
|
||||||
_log.info("After decompression, written=" + written +
|
_log.info("After decompression, written=" + written +
|
||||||
(_in != null ?
|
|
||||||
" read=" + _in.getTotalRead()
|
" read=" + _in.getTotalRead()
|
||||||
+ ", expanded=" + _in.getTotalExpanded() + ", remaining=" + _in.getRemaining()
|
+ ", expanded=" + _in.getTotalExpanded() + ", remaining=" + _in.getRemaining()
|
||||||
+ ", finished=" + _in.getFinished()
|
+ ", finished=" + _in.getFinished());
|
||||||
: ""));
|
|
||||||
if (ba != null)
|
if (ba != null)
|
||||||
_cache.release(ba);
|
_cache.release(ba);
|
||||||
if (_out != null) try {
|
if (_out != null) try {
|
||||||
|
@@ -212,10 +212,11 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sockMgr == null) {
|
// can't be null unless we limit the loop above
|
||||||
l.log("Invalid I2CP configuration");
|
//if (sockMgr == null) {
|
||||||
throw new IllegalArgumentException("Socket manager could not be created");
|
// l.log("Invalid I2CP configuration");
|
||||||
}
|
// throw new IllegalArgumentException("Socket manager could not be created");
|
||||||
|
//}
|
||||||
l.log("Tunnels ready for client: " + handlerName);
|
l.log("Tunnels ready for client: " + handlerName);
|
||||||
|
|
||||||
} // else delay creating session until createI2PSocket() is called
|
} // else delay creating session until createI2PSocket() is called
|
||||||
@@ -556,7 +557,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
if (localPort == 0) {
|
if (localPort == 0) {
|
||||||
localPort = ss.getLocalPort();
|
localPort = ss.getLocalPort();
|
||||||
}
|
}
|
||||||
notifyEvent("clientLocalPort", new Integer(ss.getLocalPort()));
|
notifyEvent("clientLocalPort", Integer.valueOf(ss.getLocalPort()));
|
||||||
// duplicates message in constructor
|
// duplicates message in constructor
|
||||||
//l.log("Listening for clients on port " + localPort + " of " + getTunnel().listenHost);
|
//l.log("Listening for clients on port " + localPort + " of " + getTunnel().listenHost);
|
||||||
|
|
||||||
|
@@ -412,9 +412,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
protected static String formatHeaders(Map<String, List<String>> headers, StringBuilder command) {
|
protected static String formatHeaders(Map<String, List<String>> headers, StringBuilder command) {
|
||||||
StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
|
StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
|
||||||
buf.append(command.toString().trim()).append("\r\n");
|
buf.append(command.toString().trim()).append("\r\n");
|
||||||
for (Iterator<String> iter = headers.keySet().iterator(); iter.hasNext(); ) {
|
for (Map.Entry<String, List<String>> e : headers.entrySet()) {
|
||||||
String name = (String)iter.next();
|
String name = e.getKey();
|
||||||
for(String val: headers.get(name)) {
|
for(String val: e.getValue()) {
|
||||||
buf.append(name.trim()).append(": ").append(val.trim()).append("\r\n");
|
buf.append(name.trim()).append(": ").append(val.trim()).append("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -311,7 +311,7 @@ class Connection {
|
|||||||
int windowSize;
|
int windowSize;
|
||||||
int remaining;
|
int remaining;
|
||||||
synchronized (_outboundPackets) {
|
synchronized (_outboundPackets) {
|
||||||
_outboundPackets.put(new Long(packet.getSequenceNum()), packet);
|
_outboundPackets.put(Long.valueOf(packet.getSequenceNum()), packet);
|
||||||
windowSize = _options.getWindowSize();
|
windowSize = _options.getWindowSize();
|
||||||
remaining = windowSize - _outboundPackets.size() ;
|
remaining = windowSize - _outboundPackets.size() ;
|
||||||
_outboundPackets.notifyAll();
|
_outboundPackets.notifyAll();
|
||||||
@@ -441,7 +441,7 @@ class Connection {
|
|||||||
if (acked != null) {
|
if (acked != null) {
|
||||||
for (int i = 0; i < acked.size(); i++) {
|
for (int i = 0; i < acked.size(); i++) {
|
||||||
PacketLocal p = acked.get(i);
|
PacketLocal p = acked.get(i);
|
||||||
_outboundPackets.remove(new Long(p.getSequenceNum()));
|
_outboundPackets.remove(Long.valueOf(p.getSequenceNum()));
|
||||||
_ackedPackets++;
|
_ackedPackets++;
|
||||||
if (p.getNumSends() > 1) {
|
if (p.getNumSends() > 1) {
|
||||||
_activeResends--;
|
_activeResends--;
|
||||||
@@ -1129,7 +1129,7 @@ class Connection {
|
|||||||
synchronized (_outboundPackets) {
|
synchronized (_outboundPackets) {
|
||||||
if (_packet.getSequenceNum() == _highestAckedThrough + 1)
|
if (_packet.getSequenceNum() == _highestAckedThrough + 1)
|
||||||
isLowest = true;
|
isLowest = true;
|
||||||
if (_outboundPackets.containsKey(new Long(_packet.getSequenceNum())))
|
if (_outboundPackets.containsKey(Long.valueOf(_packet.getSequenceNum())))
|
||||||
resend = true;
|
resend = true;
|
||||||
}
|
}
|
||||||
if ( (resend) && (_packet.getAckTime() <= 0) ) {
|
if ( (resend) && (_packet.getAckTime() <= 0) ) {
|
||||||
|
@@ -229,8 +229,8 @@ class MessageInputStream extends InputStream {
|
|||||||
_highestReadyBlockId = messageId;
|
_highestReadyBlockId = messageId;
|
||||||
long cur = _highestReadyBlockId + 1;
|
long cur = _highestReadyBlockId + 1;
|
||||||
// now pull in any previously pending blocks
|
// now pull in any previously pending blocks
|
||||||
while (_notYetReadyBlocks.containsKey(new Long(cur))) {
|
while (_notYetReadyBlocks.containsKey(Long.valueOf(cur))) {
|
||||||
ByteArray ba = _notYetReadyBlocks.remove(new Long(cur));
|
ByteArray ba = _notYetReadyBlocks.remove(Long.valueOf(cur));
|
||||||
if ( (ba != null) && (ba.getData() != null) && (ba.getValid() > 0) ) {
|
if ( (ba != null) && (ba.getData() != null) && (ba.getValid() > 0) ) {
|
||||||
_readyDataBlocks.add(ba);
|
_readyDataBlocks.add(ba);
|
||||||
}
|
}
|
||||||
@@ -245,9 +245,9 @@ class MessageInputStream extends InputStream {
|
|||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("message is out of order: " + messageId);
|
_log.debug("message is out of order: " + messageId);
|
||||||
if (_locallyClosed) // dont need the payload, just the msgId in order
|
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
|
else
|
||||||
_notYetReadyBlocks.put(new Long(messageId), payload);
|
_notYetReadyBlocks.put(Long.valueOf(messageId), payload);
|
||||||
_dataLock.notifyAll();
|
_dataLock.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -355,10 +355,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
_socket = new Socket(_hostname, _portNum);
|
_socket = new Socket(_hostname, _portNum);
|
||||||
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
|
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
|
||||||
_out = _socket.getOutputStream();
|
_out = _socket.getOutputStream();
|
||||||
synchronized (_out) {
|
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
_out.flush();
|
||||||
_out.flush();
|
|
||||||
}
|
|
||||||
_writer = new ClientWriterRunner(_out, this);
|
_writer = new ClientWriterRunner(_out, this);
|
||||||
InputStream in = _socket.getInputStream();
|
InputStream in = _socket.getInputStream();
|
||||||
_reader = new I2CPMessageReader(in, this);
|
_reader = new I2CPMessageReader(in, this);
|
||||||
|
@@ -78,10 +78,8 @@ class I2PSimpleSession extends I2PSessionImpl2 {
|
|||||||
else
|
else
|
||||||
_socket = new Socket(_hostname, _portNum);
|
_socket = new Socket(_hostname, _portNum);
|
||||||
_out = _socket.getOutputStream();
|
_out = _socket.getOutputStream();
|
||||||
synchronized (_out) {
|
_out.write(I2PClient.PROTOCOL_BYTE);
|
||||||
_out.write(I2PClient.PROTOCOL_BYTE);
|
_out.flush();
|
||||||
_out.flush();
|
|
||||||
}
|
|
||||||
_writer = new ClientWriterRunner(_out, this);
|
_writer = new ClientWriterRunner(_out, this);
|
||||||
InputStream in = _socket.getInputStream();
|
InputStream in = _socket.getInputStream();
|
||||||
_reader = new I2CPMessageReader(in, this);
|
_reader = new I2CPMessageReader(in, this);
|
||||||
|
@@ -432,6 +432,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
* @param source may be null
|
* @param source may be null
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
|
/****
|
||||||
private void addEntry(SkipList sl, String key, Destination dest, String source) {
|
private void addEntry(SkipList sl, String key, Destination dest, String source) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty(PROP_ADDED, Long.toString(_context.clock().now()));
|
props.setProperty(PROP_ADDED, Long.toString(_context.clock().now()));
|
||||||
@@ -439,6 +440,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
props.setProperty(PROP_SOURCE, source);
|
props.setProperty(PROP_SOURCE, source);
|
||||||
addEntry(sl, key, dest, props);
|
addEntry(sl, key, dest, props);
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caller must synchronize
|
* Caller must synchronize
|
||||||
@@ -476,9 +478,11 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
* @return null without exception on error (logs only)
|
* @return null without exception on error (logs only)
|
||||||
* @since 0.8.9
|
* @since 0.8.9
|
||||||
*/
|
*/
|
||||||
|
/****
|
||||||
private String getReverseEntry(Destination dest) {
|
private String getReverseEntry(Destination dest) {
|
||||||
return getReverseEntry(dest.calculateHash());
|
return getReverseEntry(dest.calculateHash());
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caller must synchronize.
|
* Caller must synchronize.
|
||||||
|
@@ -126,6 +126,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
_log.warn("Error loading hosts file " + _file, ioe);
|
_log.warn("Error loading hosts file " + _file, ioe);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
releaseReadLock();
|
releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -519,9 +519,11 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A basic symmetric encryption/decryption test. */
|
/** A basic symmetric encryption/decryption test. */
|
||||||
|
/****
|
||||||
public static boolean self_test() {
|
public static boolean self_test() {
|
||||||
return self_test(_BLOCK_SIZE);
|
return self_test(_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
// Rijndael own methods
|
// 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. */
|
/** A basic symmetric encryption/decryption test for a given key size. */
|
||||||
|
/****
|
||||||
private static boolean self_test(int keysize) {
|
private static boolean self_test(int keysize) {
|
||||||
if (_RDEBUG) trace(_IN, "self_test(" + keysize + ")");
|
if (_RDEBUG) trace(_IN, "self_test(" + keysize + ")");
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
@@ -795,6 +798,7 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor
|
|||||||
if (_RDEBUG) trace(_OUT, "self_test()");
|
if (_RDEBUG) trace(_OUT, "self_test()");
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return The number of rounds for a given Rijndael's key and block sizes.
|
* 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
|
// main(): use to generate the Intermediate Values KAT
|
||||||
//...........................................................................
|
//...........................................................................
|
||||||
|
|
||||||
|
/****
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
self_test(16);
|
self_test(16);
|
||||||
self_test(24);
|
self_test(24);
|
||||||
self_test(32);
|
self_test(32);
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
}
|
}
|
@@ -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
|
* @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
|
* @return decrypted data or null on failure
|
||||||
*/
|
*/
|
||||||
|
/****
|
||||||
private byte[] decryptAESBlock(byte encrypted[], SessionKey key, byte iv[],
|
private byte[] decryptAESBlock(byte encrypted[], SessionKey key, byte iv[],
|
||||||
byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
|
byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
|
||||||
return decryptAESBlock(encrypted, 0, encrypted.length, key, iv, sentTag, foundTags, foundKey);
|
return decryptAESBlock(encrypted, 0, encrypted.length, key, iv, sentTag, foundTags, foundKey);
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: package private for ElGamalTest.testAES()
|
* Note: package private for ElGamalTest.testAES()
|
||||||
|
@@ -34,7 +34,7 @@ public class HMAC256Generator extends HMACGenerator {
|
|||||||
return new I2PHMac(new Sha256ForMAC());
|
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 String getAlgorithmName() { return "sha256 for hmac"; }
|
||||||
public int getDigestSize() { return 32; }
|
public int getDigestSize() { return 32; }
|
||||||
public int doFinal(byte[] out, int outOff) {
|
public int doFinal(byte[] out, int outOff) {
|
||||||
|
@@ -596,10 +596,10 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
for (Iterator<SessionKey> iter = inboundSets.keySet().iterator(); iter.hasNext();) {
|
for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) {
|
||||||
SessionKey skey = iter.next();
|
SessionKey skey = e.getKey();
|
||||||
Set<TagSet> sets = new TreeSet(new TagSetComparator());
|
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>" +
|
buf.append("<tr><td><b>Session key</b>: ").append(skey.toBase64()).append("</td>" +
|
||||||
"<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" +
|
"<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" +
|
||||||
"<tr><td colspan=\"2\"><ul>");
|
"<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
|
* Just for the HTML method above so we can see what's going on easier
|
||||||
* Earliest first
|
* Earliest first
|
||||||
*/
|
*/
|
||||||
private static class TagSetComparator implements Comparator {
|
private static class TagSetComparator implements Comparator<TagSet> {
|
||||||
public int compare(Object l, Object r) {
|
public int compare(TagSet l, TagSet r) {
|
||||||
return (int) (((TagSet)l).getDate() - ((TagSet)r).getDate());
|
return (int) (l.getDate() - r.getDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import net.i2p.util.RandomSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a NTP message, as specified in RFC 2030. The message
|
* 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
|
// low order bits of the timestamp with a random, unbiased
|
||||||
// bitstring, both to avoid systematic roundoff errors and as
|
// bitstring, both to avoid systematic roundoff errors and as
|
||||||
// a means of loop detection and replay detection.
|
// a means of loop detection and replay detection.
|
||||||
array[7+pointer] = (byte) (Math.random()*255.0);
|
array[7+pointer] = (byte) (RandomSource.getInstance().nextInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -321,14 +321,16 @@ public class Timestamper implements Runnable {
|
|||||||
_context.getProperty(PROP_CONCURRING_SERVERS, DEFAULT_CONCURRING_SERVERS)));
|
_context.getProperty(PROP_CONCURRING_SERVERS, DEFAULT_CONCURRING_SERVERS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.setProperty(PROP_DISABLED, "false");
|
System.setProperty(PROP_DISABLED, "false");
|
||||||
System.setProperty(PROP_QUERY_FREQUENCY, "30000");
|
System.setProperty(PROP_QUERY_FREQUENCY, "30000");
|
||||||
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
I2PAppContext.getGlobalContext();
|
||||||
for (int i = 0; i < 5*60*1000; i += 61*1000) {
|
for (int i = 0; i < 5*60*1000; i += 61*1000) {
|
||||||
try { Thread.sleep(61*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(61*1000); } catch (InterruptedException ie) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to receive update notifications for when we query the time
|
* Interface to receive update notifications for when we query the time
|
||||||
|
@@ -443,7 +443,7 @@ public class BlockFile {
|
|||||||
public BSkipList makeIndex(String name, Serializer key, Serializer val) throws IOException {
|
public BSkipList makeIndex(String name, Serializer key, Serializer val) throws IOException {
|
||||||
if(metaIndex.get(name) != null) { throw new IOException("Index already exists"); }
|
if(metaIndex.get(name) != null) { throw new IOException("Index already exists"); }
|
||||||
int page = allocPage();
|
int page = allocPage();
|
||||||
metaIndex.put(name, new Integer(page));
|
metaIndex.put(name, Integer.valueOf(page));
|
||||||
BSkipList.init(this, page, spanSize);
|
BSkipList.init(this, page, spanSize);
|
||||||
BSkipList bsl = new BSkipList(spanSize, this, page, key, val, true);
|
BSkipList bsl = new BSkipList(spanSize, this, page, key, val, true);
|
||||||
openIndices.put(name, bsl);
|
openIndices.put(name, bsl);
|
||||||
|
@@ -103,7 +103,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
|||||||
protected final static long DONT_FAIL_PERIOD = 10*60*1000;
|
protected final static long DONT_FAIL_PERIOD = 10*60*1000;
|
||||||
|
|
||||||
/** don't probe or broadcast data, just respond and search when explicitly needed */
|
/** 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";
|
public static final String PROP_ENFORCE_NETID = "router.networkDatabase.enforceNetId";
|
||||||
private static final boolean DEFAULT_ENFORCE_NETID = false;
|
private static final boolean DEFAULT_ENFORCE_NETID = false;
|
||||||
|
Reference in New Issue
Block a user