forked from I2P_Developers/i2p.i2p
Core: type arguments, unused imports
This commit is contained in:
@@ -201,7 +201,7 @@ public class I2PAppContext {
|
|||||||
_overrideProps = new I2PProperties();
|
_overrideProps = new I2PProperties();
|
||||||
if (envProps != null)
|
if (envProps != null)
|
||||||
_overrideProps.putAll(envProps);
|
_overrideProps.putAll(envProps);
|
||||||
_shutdownTasks = new ConcurrentHashSet(32);
|
_shutdownTasks = new ConcurrentHashSet<Runnable>(32);
|
||||||
_portMapper = new PortMapper(this);
|
_portMapper = new PortMapper(this);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -535,7 +535,7 @@ public class I2PAppContext {
|
|||||||
*
|
*
|
||||||
* @return set of Strings containing the names of defined system properties
|
* @return set of Strings containing the names of defined system properties
|
||||||
*/
|
*/
|
||||||
public Set getPropertyNames() {
|
public Set<String> getPropertyNames() {
|
||||||
// clone to avoid ConcurrentModificationException
|
// clone to avoid ConcurrentModificationException
|
||||||
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
|
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
|
||||||
if (_overrideProps != null)
|
if (_overrideProps != null)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package net.i2p.app;
|
package net.i2p.app;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a class started via clients.config implements this interface,
|
* If a class started via clients.config implements this interface,
|
||||||
* it will be used to manage the client, instead of starting with main()
|
* it will be used to manage the client, instead of starting with main()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ClientWriterRunner implements Runnable {
|
|||||||
public ClientWriterRunner(OutputStream out, I2PSessionImpl session) {
|
public ClientWriterRunner(OutputStream out, I2PSessionImpl session) {
|
||||||
_out = new BufferedOutputStream(out);
|
_out = new BufferedOutputStream(out);
|
||||||
_session = session;
|
_session = session;
|
||||||
_messagesToWrite = new LinkedBlockingQueue(MAX_QUEUE_SIZE);
|
_messagesToWrite = new LinkedBlockingQueue<I2CPMessage>(MAX_QUEUE_SIZE);
|
||||||
Thread t = new I2PAppThread(this, "I2CP Client Writer " + __Id.incrementAndGet(), true);
|
Thread t = new I2PAppThread(this, "I2CP Client Writer " + __Id.incrementAndGet(), true);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class I2PSessionDemultiplexer implements I2PSessionMuxedListener {
|
|||||||
|
|
||||||
public I2PSessionDemultiplexer(I2PAppContext ctx) {
|
public I2PSessionDemultiplexer(I2PAppContext ctx) {
|
||||||
_log = ctx.logManager().getLog(I2PSessionDemultiplexer.class);
|
_log = ctx.logManager().getLog(I2PSessionDemultiplexer.class);
|
||||||
_listeners = new ConcurrentHashMap();
|
_listeners = new ConcurrentHashMap<Integer, I2PSessionMuxedListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** unused */
|
/** unused */
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import net.i2p.util.I2PAppThread;
|
|||||||
import net.i2p.util.I2PSSLSocketFactory;
|
import net.i2p.util.I2PSSLSocketFactory;
|
||||||
import net.i2p.util.LHMCache;
|
import net.i2p.util.LHMCache;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
import net.i2p.util.VersionComparator;
|
import net.i2p.util.VersionComparator;
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
protected Map<Long, MessagePayloadMessage> _availableMessages;
|
protected Map<Long, MessagePayloadMessage> _availableMessages;
|
||||||
|
|
||||||
/** hashes of lookups we are waiting for */
|
/** hashes of lookups we are waiting for */
|
||||||
protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue();
|
protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue<LookupWaiter>();
|
||||||
protected final Object _bwReceivedLock = new Object();
|
protected final Object _bwReceivedLock = new Object();
|
||||||
protected volatile int[] _bwLimits;
|
protected volatile int[] _bwLimits;
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
/**
|
/**
|
||||||
* @since 0.8.9
|
* @since 0.8.9
|
||||||
*/
|
*/
|
||||||
private static final Map<Hash, Destination> _lookupCache = new LHMCache(16);
|
private static final Map<Hash, Destination> _lookupCache = new LHMCache<Hash, Destination>(16);
|
||||||
|
|
||||||
/** SSL interface (only) @since 0.8.3 */
|
/** SSL interface (only) @since 0.8.3 */
|
||||||
protected static final String PROP_ENABLE_SSL = "i2cp.SSL";
|
protected static final String PROP_ENABLE_SSL = "i2cp.SSL";
|
||||||
@@ -196,7 +195,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
_fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE));
|
_fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE));
|
||||||
if (hasDest) {
|
if (hasDest) {
|
||||||
_producer = new I2CPMessageProducer(context);
|
_producer = new I2CPMessageProducer(context);
|
||||||
_availableMessages = new ConcurrentHashMap();
|
_availableMessages = new ConcurrentHashMap<Long, MessagePayloadMessage>();
|
||||||
_myDestination = new Destination();
|
_myDestination = new Destination();
|
||||||
_privateKey = new PrivateKey();
|
_privateKey = new PrivateKey();
|
||||||
_signingPrivateKey = new SigningPrivateKey();
|
_signingPrivateKey = new SigningPrivateKey();
|
||||||
@@ -593,7 +592,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* message. Just copy all unclaimed ones and check 30 seconds later.
|
* message. Just copy all unclaimed ones and check 30 seconds later.
|
||||||
*/
|
*/
|
||||||
private class VerifyUsage implements SimpleTimer.TimedEvent {
|
private class VerifyUsage implements SimpleTimer.TimedEvent {
|
||||||
private final List<Long> toCheck = new ArrayList();
|
private final List<Long> toCheck = new ArrayList<Long>();
|
||||||
|
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
@@ -623,8 +622,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
private volatile boolean _alive;
|
private volatile boolean _alive;
|
||||||
|
|
||||||
public AvailabilityNotifier() {
|
public AvailabilityNotifier() {
|
||||||
_pendingIds = new ArrayList(2);
|
_pendingIds = new ArrayList<Long>(2);
|
||||||
_pendingSizes = new ArrayList(2);
|
_pendingSizes = new ArrayList<Integer>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopNotifying() {
|
public void stopNotifying() {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
*/
|
*/
|
||||||
public I2PSessionImpl2(I2PAppContext ctx, InputStream destKeyStream, Properties options) throws I2PSessionException {
|
public I2PSessionImpl2(I2PAppContext ctx, InputStream destKeyStream, Properties options) throws I2PSessionException {
|
||||||
super(ctx, destKeyStream, options);
|
super(ctx, destKeyStream, options);
|
||||||
_sendingStates = new HashSet(32);
|
_sendingStates = new HashSet<MessageState>(32);
|
||||||
// default is BestEffort
|
// default is BestEffort
|
||||||
_noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US));
|
_noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US));
|
||||||
|
|
||||||
@@ -449,8 +449,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
long inSync = 0;
|
long inSync = 0;
|
||||||
synchronized (_sendingStates) {
|
synchronized (_sendingStates) {
|
||||||
inSync = _context.clock().now();
|
inSync = _context.clock().now();
|
||||||
for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) {
|
for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||||
state = (MessageState) iter.next();
|
state = iter.next();
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State " + state.getMessageId() + " / " + state.getNonce());
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State " + state.getMessageId() + " / " + state.getNonce());
|
||||||
if (state.getNonce() == nonce) {
|
if (state.getNonce() == nonce) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state");
|
||||||
@@ -523,8 +523,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
if (_sendingStates == null) // only null if overridden by I2PSimpleSession
|
if (_sendingStates == null) // only null if overridden by I2PSimpleSession
|
||||||
return;
|
return;
|
||||||
synchronized (_sendingStates) {
|
synchronized (_sendingStates) {
|
||||||
for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) {
|
for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||||
MessageState state = (MessageState) iter.next();
|
MessageState state = iter.next();
|
||||||
state.cancel();
|
state.cancel();
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Disconnecting " + _sendingStates.size() + " states");
|
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Disconnecting " + _sendingStates.size() + " states");
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.i2p.data.Destination;
|
|||||||
import net.i2p.data.SessionKey;
|
import net.i2p.data.SessionKey;
|
||||||
import net.i2p.data.i2cp.MessagePayloadMessage;
|
import net.i2p.data.i2cp.MessagePayloadMessage;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I2PSession with protocol and ports
|
* I2PSession with protocol and ports
|
||||||
@@ -297,7 +296,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 {
|
|||||||
private final AtomicBoolean stopping = new AtomicBoolean(false);
|
private final AtomicBoolean stopping = new AtomicBoolean(false);
|
||||||
|
|
||||||
public MuxedAvailabilityNotifier() {
|
public MuxedAvailabilityNotifier() {
|
||||||
_msgs = new LinkedBlockingQueue();
|
_msgs = new LinkedBlockingQueue<MsgData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class MessageState {
|
|||||||
_log = ctx.logManager().getLog(MessageState.class);
|
_log = ctx.logManager().getLog(MessageState.class);
|
||||||
_nonce = nonce;
|
_nonce = nonce;
|
||||||
_prefix = prefix + "[" + _stateId + "]: ";
|
_prefix = prefix + "[" + _stateId + "]: ";
|
||||||
_receivedStatus = new HashSet();
|
_receivedStatus = new HashSet<Integer>();
|
||||||
_created = ctx.clock().now();
|
_created = ctx.clock().now();
|
||||||
//ctx.statManager().createRateStat("i2cp.checkStatusTime", "how long it takes to go through the states", "i2cp", new long[] { 60*1000 });
|
//ctx.statManager().createRateStat("i2cp.checkStatusTime", "how long it takes to go through the states", "i2cp", new long[] { 60*1000 });
|
||||||
}
|
}
|
||||||
@@ -150,8 +150,8 @@ class MessageState {
|
|||||||
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(_prefix + "isSuccess(" + wantedStatus + "): " + _receivedStatus);
|
_log.debug(_prefix + "isSuccess(" + wantedStatus + "): " + _receivedStatus);
|
||||||
for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) {
|
for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||||
Integer val = (Integer) iter.next();
|
Integer val = iter.next();
|
||||||
int recv = val.intValue();
|
int recv = val.intValue();
|
||||||
switch (recv) {
|
switch (recv) {
|
||||||
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
||||||
@@ -210,8 +210,8 @@ class MessageState {
|
|||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(_prefix + "isFailure(" + wantedStatus + "): " + _receivedStatus);
|
_log.debug(_prefix + "isFailure(" + wantedStatus + "): " + _receivedStatus);
|
||||||
|
|
||||||
for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) {
|
for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||||
Integer val = (Integer) iter.next();
|
Integer val = iter.next();
|
||||||
int recv = val.intValue();
|
int recv = val.intValue();
|
||||||
switch (recv) {
|
switch (recv) {
|
||||||
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
|||||||
protected RequestLeaseSetMessageHandler(I2PAppContext context, int messageType) {
|
protected RequestLeaseSetMessageHandler(I2PAppContext context, int messageType) {
|
||||||
super(context, messageType);
|
super(context, messageType);
|
||||||
// not clear why there would ever be more than one
|
// not clear why there would ever be more than one
|
||||||
_existingLeaseSets = new ConcurrentHashMap(4);
|
_existingLeaseSets = new ConcurrentHashMap<Destination, LeaseInfo>(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.util.Properties;
|
|||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
*/
|
*/
|
||||||
public BlockfileNamingService(I2PAppContext context) {
|
public BlockfileNamingService(I2PAppContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
_lists = new ArrayList();
|
_lists = new ArrayList<String>();
|
||||||
_invalid = new ArrayList();
|
_invalid = new ArrayList<InvalidEntry>();
|
||||||
_negativeCache = new LHMCache(NEGATIVE_CACHE_SIZE);
|
_negativeCache = new LHMCache<String, String>(NEGATIVE_CACHE_SIZE);
|
||||||
BlockFile bf = null;
|
BlockFile bf = null;
|
||||||
RAIFile raf = null;
|
RAIFile raf = null;
|
||||||
boolean readOnly = false;
|
boolean readOnly = false;
|
||||||
@@ -468,7 +468,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
|
|
||||||
private static List<String> getFilenames(String list) {
|
private static List<String> getFilenames(String list) {
|
||||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||||
List<String> rv = new ArrayList(tok.countTokens());
|
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||||
while (tok.hasMoreTokens())
|
while (tok.hasMoreTokens())
|
||||||
rv.add(tok.nextToken());
|
rv.add(tok.nextToken());
|
||||||
return rv;
|
return rv;
|
||||||
@@ -847,20 +847,20 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
" limit=" + limit + " skip=" + skip);
|
" limit=" + limit + " skip=" + skip);
|
||||||
synchronized(_bf) {
|
synchronized(_bf) {
|
||||||
if (_isClosed)
|
if (_isClosed)
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
try {
|
try {
|
||||||
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
|
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
|
||||||
if (sl == null) {
|
if (sl == null) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("No skiplist found for lookup in " + listname);
|
_log.warn("No skiplist found for lookup in " + listname);
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
SkipIterator iter;
|
SkipIterator iter;
|
||||||
if (beginWith != null)
|
if (beginWith != null)
|
||||||
iter = sl.find(beginWith);
|
iter = sl.find(beginWith);
|
||||||
else
|
else
|
||||||
iter = sl.iterator();
|
iter = sl.iterator();
|
||||||
Map<String, Destination> rv = new HashMap();
|
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||||
for (int i = 0; i < skip && iter.hasNext(); i++) {
|
for (int i = 0; i < skip && iter.hasNext(); i++) {
|
||||||
// don't bother validating here
|
// don't bother validating here
|
||||||
iter.next();
|
iter.next();
|
||||||
@@ -886,10 +886,10 @@ public class BlockfileNamingService extends DummyNamingService {
|
|||||||
return rv;
|
return rv;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("DB lookup error", ioe);
|
_log.error("DB lookup error", ioe);
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
} catch (RuntimeException re) {
|
} catch (RuntimeException re) {
|
||||||
_log.error("DB lookup error", re);
|
_log.error("DB lookup error", re);
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
} finally {
|
} finally {
|
||||||
deleteInvalid();
|
deleteInvalid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class DummyNamingService extends NamingService {
|
|||||||
* Classes should take care to call removeCache() for any entries that
|
* Classes should take care to call removeCache() for any entries that
|
||||||
* are invalidated.
|
* are invalidated.
|
||||||
*/
|
*/
|
||||||
private static final Map<String, Destination> _cache = new LHMCache(CACHE_MAX_SIZE);
|
private static final Map<String, Destination> _cache = new LHMCache<String, Destination>(CACHE_MAX_SIZE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The naming service should only be constructed and accessed through the
|
* The naming service should only be constructed and accessed through the
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public class EepGetNamingService extends DummyNamingService {
|
|||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getURLs() {
|
private List<String> getURLs() {
|
||||||
String list = _context.getProperty(PROP_EEPGET_LIST, DEFAULT_EEPGET_LIST);
|
String list = _context.getProperty(PROP_EEPGET_LIST, DEFAULT_EEPGET_LIST);
|
||||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||||
List rv = new ArrayList(tok.countTokens());
|
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||||
while (tok.hasMoreTokens())
|
while (tok.hasMoreTokens())
|
||||||
rv.add(tok.nextToken());
|
rv.add(tok.nextToken());
|
||||||
return rv;
|
return rv;
|
||||||
@@ -70,13 +70,13 @@ public class EepGetNamingService extends DummyNamingService {
|
|||||||
if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p"))
|
if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p"))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List URLs = getURLs();
|
List<String> URLs = getURLs();
|
||||||
if (URLs.isEmpty())
|
if (URLs.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// prevent lookup loops - this cannot be the only lookup service
|
// prevent lookup loops - this cannot be the only lookup service
|
||||||
for (int i = 0; i < URLs.size(); i++) {
|
for (int i = 0; i < URLs.size(); i++) {
|
||||||
String url = (String)URLs.get(i);
|
String url = URLs.get(i);
|
||||||
if (url.startsWith("http://" + hostname + "/")) {
|
if (url.startsWith("http://" + hostname + "/")) {
|
||||||
_log.error("Lookup loop: " + hostname);
|
_log.error("Lookup loop: " + hostname);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class HostsTxtNamingService extends MetaNamingService {
|
|||||||
private List<String> getFilenames() {
|
private List<String> getFilenames() {
|
||||||
String list = _context.getProperty(PROP_HOSTS_FILE, DEFAULT_HOSTS_FILE);
|
String list = _context.getProperty(PROP_HOSTS_FILE, DEFAULT_HOSTS_FILE);
|
||||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||||
List<String> rv = new ArrayList(tok.countTokens());
|
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||||
while (tok.hasMoreTokens())
|
while (tok.hasMoreTokens())
|
||||||
rv.add(tok.nextToken());
|
rv.add(tok.nextToken());
|
||||||
return rv;
|
return rv;
|
||||||
@@ -97,6 +97,6 @@ public class HostsTxtNamingService extends MetaNamingService {
|
|||||||
if (name.equals(file) || name.endsWith('/' + file) || name.endsWith('\\' + file))
|
if (name.equals(file) || name.endsWith('/' + file) || name.endsWith('\\' + file))
|
||||||
return ns.getNames(options);
|
return ns.getNames(options);
|
||||||
}
|
}
|
||||||
return new HashSet(0);
|
return new HashSet<String>(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class MetaNamingService extends DummyNamingService {
|
|||||||
super(context);
|
super(context);
|
||||||
String list = _context.getProperty(PROP_NAME_SERVICES, DEFAULT_NAME_SERVICES);
|
String list = _context.getProperty(PROP_NAME_SERVICES, DEFAULT_NAME_SERVICES);
|
||||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||||
_services = new CopyOnWriteArrayList();
|
_services = new CopyOnWriteArrayList<NamingService>();
|
||||||
while (tok.hasMoreTokens()) {
|
while (tok.hasMoreTokens()) {
|
||||||
try {
|
try {
|
||||||
Class cls = Class.forName(tok.nextToken());
|
Class cls = Class.forName(tok.nextToken());
|
||||||
@@ -53,7 +53,7 @@ public class MetaNamingService extends DummyNamingService {
|
|||||||
*/
|
*/
|
||||||
public MetaNamingService(I2PAppContext context, List<NamingService> services) {
|
public MetaNamingService(I2PAppContext context, List<NamingService> services) {
|
||||||
super(context);
|
super(context);
|
||||||
_services = new CopyOnWriteArrayList();
|
_services = new CopyOnWriteArrayList<NamingService>();
|
||||||
if (services != null) {
|
if (services != null) {
|
||||||
for (NamingService ns : services) {
|
for (NamingService ns : services) {
|
||||||
addNamingService(ns, false);
|
addNamingService(ns, false);
|
||||||
@@ -172,7 +172,7 @@ public class MetaNamingService extends DummyNamingService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Destination> getEntries(Properties options) {
|
public Map<String, Destination> getEntries(Properties options) {
|
||||||
Map<String, Destination> rv = new HashMap();
|
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||||
for (NamingService ns : _services) {
|
for (NamingService ns : _services) {
|
||||||
rv.putAll(ns.getEntries(options));
|
rv.putAll(ns.getEntries(options));
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ public class MetaNamingService extends DummyNamingService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getNames(Properties options) {
|
public Set<String> getNames(Properties options) {
|
||||||
Set<String> rv = new HashSet();
|
Set<String> rv = new HashSet<String>();
|
||||||
for (NamingService ns : _services) {
|
for (NamingService ns : _services) {
|
||||||
rv.addAll(ns.getNames(options));
|
rv.addAll(ns.getNames(options));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ public abstract class NamingService {
|
|||||||
protected NamingService(I2PAppContext context) {
|
protected NamingService(I2PAppContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_log = context.logManager().getLog(getClass());
|
_log = context.logManager().getLog(getClass());
|
||||||
_listeners = new CopyOnWriteArraySet();
|
_listeners = new CopyOnWriteArraySet<NamingServiceListener>();
|
||||||
_updaters = new CopyOnWriteArraySet();
|
_updaters = new CopyOnWriteArraySet<NamingServiceUpdater>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,7 +226,7 @@ public abstract class NamingService {
|
|||||||
* @since 0.8.7
|
* @since 0.8.7
|
||||||
*/
|
*/
|
||||||
public Map<String, Destination> getEntries(Properties options) {
|
public Map<String, Destination> getEntries(Properties options) {
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +242,7 @@ public abstract class NamingService {
|
|||||||
* @since 0.8.7
|
* @since 0.8.7
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getBase64Entries(Properties options) {
|
public Map<String, String> getBase64Entries(Properties options) {
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +263,7 @@ public abstract class NamingService {
|
|||||||
* @since 0.8.7
|
* @since 0.8.7
|
||||||
*/
|
*/
|
||||||
public Set<String> getNames(Properties options) {
|
public Set<String> getNames(Properties options) {
|
||||||
return Collections.EMPTY_SET;
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Destination> getEntries(Properties options) {
|
public Map<String, Destination> getEntries(Properties options) {
|
||||||
if (!_file.exists())
|
if (!_file.exists())
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
String searchOpt = null;
|
String searchOpt = null;
|
||||||
String startsWith = null;
|
String startsWith = null;
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
@@ -322,7 +322,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
try {
|
try {
|
||||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
||||||
String line = null;
|
String line = null;
|
||||||
Map<String, Destination> rv = new HashMap();
|
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||||
while ( (line = in.readLine()) != null) {
|
while ( (line = in.readLine()) != null) {
|
||||||
if (line.length() <= 0)
|
if (line.length() <= 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -357,7 +357,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
return rv;
|
return rv;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("getEntries error", ioe);
|
_log.error("getEntries error", ioe);
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.emptyMap();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
releaseReadLock();
|
releaseReadLock();
|
||||||
@@ -370,13 +370,13 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
*/
|
*/
|
||||||
public Set<String> getNames(Properties options) {
|
public Set<String> getNames(Properties options) {
|
||||||
if (!_file.exists())
|
if (!_file.exists())
|
||||||
return Collections.EMPTY_SET;
|
return Collections.emptySet();
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
getReadLock();
|
getReadLock();
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
||||||
String line = null;
|
String line = null;
|
||||||
Set<String> rv = new HashSet();
|
Set<String> rv = new HashSet<String>();
|
||||||
while ( (line = in.readLine()) != null) {
|
while ( (line = in.readLine()) != null) {
|
||||||
if (line.length() <= 0)
|
if (line.length() <= 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -391,7 +391,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
return rv;
|
return rv;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("getNames error", ioe);
|
_log.error("getNames error", ioe);
|
||||||
return Collections.EMPTY_SET;
|
return Collections.emptySet();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
releaseReadLock();
|
releaseReadLock();
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.security.GeneralSecurityException;
|
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.CertificateEncodingException;
|
import java.security.cert.CertificateEncodingException;
|
||||||
import java.security.cert.CertificateFactory;
|
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import java.security.InvalidKeyException;
|
|||||||
//import javax.crypto.spec.SecretKeySpec;
|
//import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.ByteArray;
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.SessionKey;
|
import net.i2p.data.SessionKey;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public final class CryptixAESKeyCache {
|
|||||||
* @deprecated unused, keys are now cached in the SessionKey objects
|
* @deprecated unused, keys are now cached in the SessionKey objects
|
||||||
*/
|
*/
|
||||||
public CryptixAESKeyCache() {
|
public CryptixAESKeyCache() {
|
||||||
_availableKeys = new LinkedBlockingQueue(MAX_KEYS);
|
_availableKeys = new LinkedBlockingQueue<KeyCacheEntry>(MAX_KEYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,13 +29,11 @@ package net.i2p.crypto;
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.KeyFactory;
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|||||||
@@ -3,11 +3,8 @@ package net.i2p.crypto;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.AlgorithmParameters;
|
import java.security.AlgorithmParameters;
|
||||||
import java.security.AlgorithmParameterGenerator;
|
|
||||||
import java.security.GeneralSecurityException;
|
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
|
||||||
import java.security.spec.ECField;
|
import java.security.spec.ECField;
|
||||||
import java.security.spec.ECFieldFp;
|
import java.security.spec.ECFieldFp;
|
||||||
import java.security.spec.ECGenParameterSpec;
|
import java.security.spec.ECGenParameterSpec;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.Base64;
|
|
||||||
import net.i2p.data.DataFormatException;
|
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;
|
||||||
@@ -100,7 +99,7 @@ public class ElGamalAESEngine {
|
|||||||
SessionKey key = keyManager.consumeTag(st);
|
SessionKey key = keyManager.consumeTag(st);
|
||||||
SessionKey foundKey = new SessionKey();
|
SessionKey foundKey = new SessionKey();
|
||||||
SessionKey usedKey = new SessionKey();
|
SessionKey usedKey = new SessionKey();
|
||||||
Set foundTags = new HashSet();
|
Set<SessionTag> foundTags = new HashSet<SessionTag>();
|
||||||
byte decrypted[] = null;
|
byte decrypted[] = null;
|
||||||
boolean wasExisting = false;
|
boolean wasExisting = false;
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
@@ -170,7 +169,7 @@ public class ElGamalAESEngine {
|
|||||||
*
|
*
|
||||||
* @return null if decryption fails
|
* @return null if decryption fails
|
||||||
*/
|
*/
|
||||||
private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set foundTags, SessionKey usedKey,
|
private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set<SessionTag> foundTags, SessionKey usedKey,
|
||||||
SessionKey foundKey) throws DataFormatException {
|
SessionKey foundKey) throws DataFormatException {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
//if (_log.shouldLog(Log.WARN)) _log.warn("Data is null, unable to decrypt new session");
|
//if (_log.shouldLog(Log.WARN)) _log.warn("Data is null, unable to decrypt new session");
|
||||||
@@ -246,7 +245,7 @@ public class ElGamalAESEngine {
|
|||||||
* @return decrypted data or null on failure
|
* @return decrypted data or null on failure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set foundTags,
|
private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set<SessionTag> foundTags,
|
||||||
SessionKey usedKey, SessionKey foundKey) throws DataFormatException {
|
SessionKey usedKey, SessionKey foundKey) throws DataFormatException {
|
||||||
byte preIV[] = SimpleByteCache.acquire(32);
|
byte preIV[] = SimpleByteCache.acquire(32);
|
||||||
System.arraycopy(data, 0, preIV, 0, 32);
|
System.arraycopy(data, 0, preIV, 0, 32);
|
||||||
@@ -315,7 +314,7 @@ public class ElGamalAESEngine {
|
|||||||
* Note: package private for ElGamalTest.testAES()
|
* Note: package private for ElGamalTest.testAES()
|
||||||
*/
|
*/
|
||||||
byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[],
|
byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[],
|
||||||
byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
|
byte sentTag[], Set<SessionTag> foundTags, SessionKey foundKey) throws DataFormatException {
|
||||||
//_log.debug("iv for decryption: " + DataHelper.toString(iv, 16));
|
//_log.debug("iv for decryption: " + DataHelper.toString(iv, 16));
|
||||||
//_log.debug("decrypting AES block. encr.length = " + (encrypted == null? -1 : encrypted.length) + " sentTag: " + DataHelper.toString(sentTag, 32));
|
//_log.debug("decrypting AES block. encr.length = " + (encrypted == null? -1 : encrypted.length) + " sentTag: " + DataHelper.toString(sentTag, 32));
|
||||||
byte decrypted[] = new byte[encryptedLen];
|
byte decrypted[] = new byte[encryptedLen];
|
||||||
@@ -324,13 +323,13 @@ public class ElGamalAESEngine {
|
|||||||
//_log.debug("Hash of entire aes block after decryption: \n" + DataHelper.toString(h.getData(), 32));
|
//_log.debug("Hash of entire aes block after decryption: \n" + DataHelper.toString(h.getData(), 32));
|
||||||
try {
|
try {
|
||||||
SessionKey newKey = null;
|
SessionKey newKey = null;
|
||||||
List tags = null;
|
List<SessionTag> tags = null;
|
||||||
|
|
||||||
//ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
|
//ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
|
||||||
int cur = 0;
|
int cur = 0;
|
||||||
long numTags = DataHelper.fromLong(decrypted, cur, 2);
|
long numTags = DataHelper.fromLong(decrypted, cur, 2);
|
||||||
if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new Exception("Invalid number of session tags");
|
if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new Exception("Invalid number of session tags");
|
||||||
if (numTags > 0) tags = new ArrayList((int)numTags);
|
if (numTags > 0) tags = new ArrayList<SessionTag>((int)numTags);
|
||||||
cur += 2;
|
cur += 2;
|
||||||
//_log.debug("# tags: " + numTags);
|
//_log.debug("# tags: " + numTags);
|
||||||
if (numTags * SessionTag.BYTE_LENGTH > decrypted.length - 2) {
|
if (numTags * SessionTag.BYTE_LENGTH > decrypted.length - 2) {
|
||||||
@@ -404,7 +403,7 @@ public class ElGamalAESEngine {
|
|||||||
*
|
*
|
||||||
* Unused externally, only called by below (i.e. newKey is always null)
|
* Unused externally, only called by below (i.e. newKey is always null)
|
||||||
*/
|
*/
|
||||||
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
|
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
|
||||||
SessionTag currentTag, SessionKey newKey, long paddedSize) {
|
SessionTag currentTag, SessionKey newKey, long paddedSize) {
|
||||||
if (currentTag == null) {
|
if (currentTag == null) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
@@ -450,7 +449,7 @@ public class ElGamalAESEngine {
|
|||||||
* body's real size, no bytes are appended but the body is not truncated)
|
* body's real size, no bytes are appended but the body is not truncated)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
|
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
|
||||||
SessionTag currentTag, long paddedSize) {
|
SessionTag currentTag, long paddedSize) {
|
||||||
return encrypt(data, target, key, tagsForDelivery, currentTag, null, paddedSize);
|
return encrypt(data, target, key, tagsForDelivery, currentTag, null, paddedSize);
|
||||||
}
|
}
|
||||||
@@ -464,7 +463,7 @@ public class ElGamalAESEngine {
|
|||||||
* 200 max enforced at receiver
|
* 200 max enforced at receiver
|
||||||
* @deprecated unused
|
* @deprecated unused
|
||||||
*/
|
*/
|
||||||
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, long paddedSize) {
|
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, long paddedSize) {
|
||||||
return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize);
|
return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +501,7 @@ public class ElGamalAESEngine {
|
|||||||
* @param tagsForDelivery session tags to be associated with the key or null;
|
* @param tagsForDelivery session tags to be associated with the key or null;
|
||||||
* 200 max enforced at receiver
|
* 200 max enforced at receiver
|
||||||
*/
|
*/
|
||||||
private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
|
private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
|
||||||
SessionKey newKey, long paddedSize) {
|
SessionKey newKey, long paddedSize) {
|
||||||
//_log.debug("Encrypting to a NEW session");
|
//_log.debug("Encrypting to a NEW session");
|
||||||
byte elgSrcData[] = new byte[SessionKey.KEYSIZE_BYTES+32+158];
|
byte elgSrcData[] = new byte[SessionKey.KEYSIZE_BYTES+32+158];
|
||||||
@@ -571,7 +570,7 @@ public class ElGamalAESEngine {
|
|||||||
* @param tagsForDelivery session tags to be associated with the key or null;
|
* @param tagsForDelivery session tags to be associated with the key or null;
|
||||||
* 200 max enforced at receiver
|
* 200 max enforced at receiver
|
||||||
*/
|
*/
|
||||||
private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
|
private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
|
||||||
SessionTag currentTag, SessionKey newKey, long paddedSize) {
|
SessionTag currentTag, SessionKey newKey, long paddedSize) {
|
||||||
//_log.debug("Encrypting to an EXISTING session");
|
//_log.debug("Encrypting to an EXISTING session");
|
||||||
byte rawTag[] = currentTag.getData();
|
byte rawTag[] = currentTag.getData();
|
||||||
@@ -629,7 +628,7 @@ public class ElGamalAESEngine {
|
|||||||
* @param tagsForDelivery session tags to be associated with the key or null;
|
* @param tagsForDelivery session tags to be associated with the key or null;
|
||||||
* 200 max enforced at receiver
|
* 200 max enforced at receiver
|
||||||
*/
|
*/
|
||||||
final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
|
final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey,
|
||||||
long paddedSize) {
|
long paddedSize) {
|
||||||
return encryptAESBlock(data, key, iv, tagsForDelivery, newKey, paddedSize, 0);
|
return encryptAESBlock(data, key, iv, tagsForDelivery, newKey, paddedSize, 0);
|
||||||
}
|
}
|
||||||
@@ -639,11 +638,11 @@ public class ElGamalAESEngine {
|
|||||||
* @param tagsForDelivery session tags to be associated with the key or null;
|
* @param tagsForDelivery session tags to be associated with the key or null;
|
||||||
* 200 max enforced at receiver
|
* 200 max enforced at receiver
|
||||||
*/
|
*/
|
||||||
private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
|
private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey,
|
||||||
long paddedSize, int prefixBytes) {
|
long paddedSize, int prefixBytes) {
|
||||||
//_log.debug("iv for encryption: " + DataHelper.toString(iv, 16));
|
//_log.debug("iv for encryption: " + DataHelper.toString(iv, 16));
|
||||||
//_log.debug("Encrypting AES");
|
//_log.debug("Encrypting AES");
|
||||||
if (tagsForDelivery == null) tagsForDelivery = Collections.EMPTY_SET;
|
if (tagsForDelivery == null) tagsForDelivery = Collections.emptySet();
|
||||||
int size = 2 // sizeof(tags)
|
int size = 2 // sizeof(tags)
|
||||||
+ SessionTag.BYTE_LENGTH*tagsForDelivery.size()
|
+ SessionTag.BYTE_LENGTH*tagsForDelivery.size()
|
||||||
+ 4 // payload length
|
+ 4 // payload length
|
||||||
@@ -657,8 +656,8 @@ public class ElGamalAESEngine {
|
|||||||
int cur = prefixBytes;
|
int cur = prefixBytes;
|
||||||
DataHelper.toLong(aesData, cur, 2, tagsForDelivery.size());
|
DataHelper.toLong(aesData, cur, 2, tagsForDelivery.size());
|
||||||
cur += 2;
|
cur += 2;
|
||||||
for (Iterator iter = tagsForDelivery.iterator(); iter.hasNext();) {
|
for (Iterator<SessionTag> iter = tagsForDelivery.iterator(); iter.hasNext();) {
|
||||||
SessionTag tag = (SessionTag) iter.next();
|
SessionTag tag = iter.next();
|
||||||
System.arraycopy(tag.getData(), 0, aesData, cur, SessionTag.BYTE_LENGTH);
|
System.arraycopy(tag.getData(), 0, aesData, cur, SessionTag.BYTE_LENGTH);
|
||||||
cur += SessionTag.BYTE_LENGTH;
|
cur += SessionTag.BYTE_LENGTH;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class HMACGenerator {
|
|||||||
* @param context unused
|
* @param context unused
|
||||||
*/
|
*/
|
||||||
public HMACGenerator(I2PAppContext context) {
|
public HMACGenerator(I2PAppContext context) {
|
||||||
_available = new LinkedBlockingQueue(32);
|
_available = new LinkedBlockingQueue<I2PHMac>(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import java.security.GeneralSecurityException;
|
|||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.CertificateEncodingException;
|
|
||||||
import java.security.cert.CertificateExpiredException;
|
import java.security.cert.CertificateExpiredException;
|
||||||
import java.security.cert.CertificateNotYetValidException;
|
import java.security.cert.CertificateNotYetValidException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
@@ -20,7 +18,6 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.Base32;
|
import net.i2p.data.Base32;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SecureDirectory;
|
import net.i2p.util.SecureDirectory;
|
||||||
import net.i2p.util.SecureFileOutputStream;
|
import net.i2p.util.SecureFileOutputStream;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public final class SHA256Generator {
|
|||||||
* @param context unused
|
* @param context unused
|
||||||
*/
|
*/
|
||||||
public SHA256Generator(I2PAppContext context) {
|
public SHA256Generator(I2PAppContext context) {
|
||||||
_digests = new LinkedBlockingQueue(32);
|
_digests = new LinkedBlockingQueue<MessageDigest>(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final SHA256Generator getInstance() {
|
public static final SHA256Generator getInstance() {
|
||||||
|
|||||||
@@ -30,11 +30,7 @@ import net.i2p.I2PAppContext;
|
|||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Signature;
|
import net.i2p.data.Signature;
|
||||||
import net.i2p.data.SigningPrivateKey;
|
|
||||||
import net.i2p.data.SigningPublicKey;
|
|
||||||
import net.i2p.data.SimpleDataStructure;
|
import net.i2p.data.SimpleDataStructure;
|
||||||
import net.i2p.util.HexDump;
|
|
||||||
import net.i2p.util.SecureFileOutputStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Succesor to the ".sud" format used in TrustedUpdate.
|
* Succesor to the ".sud" format used in TrustedUpdate.
|
||||||
@@ -441,7 +437,7 @@ public class SU3File {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
List<String> a = new ArrayList(Arrays.asList(args));
|
List<String> a = new ArrayList<String>(Arrays.asList(args));
|
||||||
try {
|
try {
|
||||||
// defaults
|
// defaults
|
||||||
String stype = null;
|
String stype = null;
|
||||||
|
|||||||
@@ -21,14 +21,10 @@ import java.security.interfaces.RSAPrivateKey;
|
|||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.DSAPrivateKeySpec;
|
import java.security.spec.DSAPrivateKeySpec;
|
||||||
import java.security.spec.DSAPublicKeySpec;
|
import java.security.spec.DSAPublicKeySpec;
|
||||||
import java.security.spec.ECField;
|
|
||||||
import java.security.spec.ECFieldFp;
|
|
||||||
import java.security.spec.ECGenParameterSpec;
|
|
||||||
import java.security.spec.ECParameterSpec;
|
import java.security.spec.ECParameterSpec;
|
||||||
import java.security.spec.ECPrivateKeySpec;
|
import java.security.spec.ECPrivateKeySpec;
|
||||||
import java.security.spec.ECPublicKeySpec;
|
import java.security.spec.ECPublicKeySpec;
|
||||||
import java.security.spec.ECPoint;
|
import java.security.spec.ECPoint;
|
||||||
import java.security.spec.EllipticCurve;
|
|
||||||
import java.security.spec.KeySpec;
|
import java.security.spec.KeySpec;
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
import java.security.spec.RSAKeyGenParameterSpec;
|
import java.security.spec.RSAKeyGenParameterSpec;
|
||||||
@@ -51,8 +47,8 @@ import net.i2p.util.NativeBigInteger;
|
|||||||
*/
|
*/
|
||||||
class SigUtil {
|
class SigUtil {
|
||||||
|
|
||||||
private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache(64);
|
private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache<SigningPublicKey, ECPublicKey>(64);
|
||||||
private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache(16);
|
private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache<SigningPrivateKey, ECPrivateKey>(16);
|
||||||
|
|
||||||
private SigUtil() {}
|
private SigUtil() {}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@@ -30,7 +29,6 @@ import net.i2p.data.PublicKey;
|
|||||||
import net.i2p.data.SessionKey;
|
import net.i2p.data.SessionKey;
|
||||||
import net.i2p.data.SessionTag;
|
import net.i2p.data.SessionTag;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,8 +175,8 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
_lowThreshold = lowThreshold;
|
_lowThreshold = lowThreshold;
|
||||||
_log = context.logManager().getLog(TransientSessionKeyManager.class);
|
_log = context.logManager().getLog(TransientSessionKeyManager.class);
|
||||||
_context = context;
|
_context = context;
|
||||||
_outboundSessions = new HashMap(64);
|
_outboundSessions = new HashMap<PublicKey, OutboundSession>(64);
|
||||||
_inboundTagSets = new HashMap(128);
|
_inboundTagSets = new HashMap<SessionTag, TagSet>(128);
|
||||||
context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
||||||
context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
||||||
_alive = true;
|
_alive = true;
|
||||||
@@ -212,14 +210,14 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
/** TagSet - used only by HTML */
|
/** TagSet - used only by HTML */
|
||||||
private Set<TagSet> getInboundTagSets() {
|
private Set<TagSet> getInboundTagSets() {
|
||||||
synchronized (_inboundTagSets) {
|
synchronized (_inboundTagSets) {
|
||||||
return new HashSet(_inboundTagSets.values());
|
return new HashSet<TagSet>(_inboundTagSets.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** OutboundSession - used only by HTML */
|
/** OutboundSession - used only by HTML */
|
||||||
private Set<OutboundSession> getOutboundSessions() {
|
private Set<OutboundSession> getOutboundSessions() {
|
||||||
synchronized (_outboundSessions) {
|
synchronized (_outboundSessions) {
|
||||||
return new HashSet(_outboundSessions.values());
|
return new HashSet<OutboundSession>(_outboundSessions.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +584,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
int tags = 0;
|
int tags = 0;
|
||||||
int toRemove = overage * 2;
|
int toRemove = overage * 2;
|
||||||
_log.log(Log.CRIT, "TOO MANY SESSION TAGS! Starting cleanup, overage = " + overage);
|
_log.log(Log.CRIT, "TOO MANY SESSION TAGS! Starting cleanup, overage = " + overage);
|
||||||
List<TagSet> removed = new ArrayList(toRemove);
|
List<TagSet> removed = new ArrayList<TagSet>(toRemove);
|
||||||
synchronized (_inboundTagSets) {
|
synchronized (_inboundTagSets) {
|
||||||
for (TagSet set : _inboundTagSets.values()) {
|
for (TagSet set : _inboundTagSets.values()) {
|
||||||
int size = set.getTags().size();
|
int size = set.getTags().size();
|
||||||
@@ -717,12 +715,12 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
buf.append("<h2>Inbound sessions</h2>" +
|
buf.append("<h2>Inbound sessions</h2>" +
|
||||||
"<table>");
|
"<table>");
|
||||||
Set<TagSet> inbound = getInboundTagSets();
|
Set<TagSet> inbound = getInboundTagSets();
|
||||||
Map<SessionKey, Set<TagSet>> inboundSets = new HashMap(inbound.size());
|
Map<SessionKey, Set<TagSet>> inboundSets = new HashMap<SessionKey, Set<TagSet>>(inbound.size());
|
||||||
// Build a map of the inbound tag sets, grouped by SessionKey
|
// Build a map of the inbound tag sets, grouped by SessionKey
|
||||||
for (TagSet ts : inbound) {
|
for (TagSet ts : inbound) {
|
||||||
Set<TagSet> sets = inboundSets.get(ts.getAssociatedKey());
|
Set<TagSet> sets = inboundSets.get(ts.getAssociatedKey());
|
||||||
if (sets == null) {
|
if (sets == null) {
|
||||||
sets = new HashSet();
|
sets = new HashSet<TagSet>();
|
||||||
inboundSets.put(ts.getAssociatedKey(), sets);
|
inboundSets.put(ts.getAssociatedKey(), sets);
|
||||||
}
|
}
|
||||||
sets.add(ts);
|
sets.add(ts);
|
||||||
@@ -731,7 +729,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) {
|
for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) {
|
||||||
SessionKey skey = e.getKey();
|
SessionKey skey = e.getKey();
|
||||||
Set<TagSet> sets = new TreeSet(new TagSetComparator());
|
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
|
||||||
sets.addAll(e.getValue());
|
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>" +
|
||||||
@@ -761,7 +759,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
Set<OutboundSession> outbound = getOutboundSessions();
|
Set<OutboundSession> outbound = getOutboundSessions();
|
||||||
for (Iterator<OutboundSession> iter = outbound.iterator(); iter.hasNext();) {
|
for (Iterator<OutboundSession> iter = outbound.iterator(); iter.hasNext();) {
|
||||||
OutboundSession sess = iter.next();
|
OutboundSession sess = iter.next();
|
||||||
Set<TagSet> sets = new TreeSet(new TagSetComparator());
|
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
|
||||||
sets.addAll(sess.getTagSets());
|
sets.addAll(sess.getTagSets());
|
||||||
buf.append("<tr><td><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" +
|
buf.append("<tr><td><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" +
|
||||||
"<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" +
|
"<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" +
|
||||||
@@ -850,7 +848,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
private static final int MAX_FAILS = 2;
|
private static final int MAX_FAILS = 2;
|
||||||
|
|
||||||
public OutboundSession(I2PAppContext ctx, Log log, PublicKey target) {
|
public OutboundSession(I2PAppContext ctx, Log log, PublicKey target) {
|
||||||
this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList());
|
this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList<TagSet>());
|
||||||
}
|
}
|
||||||
|
|
||||||
OutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey curKey,
|
OutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey curKey,
|
||||||
@@ -862,7 +860,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
_established = established;
|
_established = established;
|
||||||
_lastUsed = lastUsed;
|
_lastUsed = lastUsed;
|
||||||
_unackedTagSets = tagSets;
|
_unackedTagSets = tagSets;
|
||||||
_tagSets = new ArrayList();
|
_tagSets = new ArrayList<TagSet>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -873,7 +871,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
List<TagSet> getTagSets() {
|
List<TagSet> getTagSets() {
|
||||||
List<TagSet> rv;
|
List<TagSet> rv;
|
||||||
synchronized (_tagSets) {
|
synchronized (_tagSets) {
|
||||||
rv = new ArrayList(_unackedTagSets);
|
rv = new ArrayList<TagSet>(_unackedTagSets);
|
||||||
rv.addAll(_tagSets);
|
rv.addAll(_tagSets);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
|
|||||||
/** 172 */
|
/** 172 */
|
||||||
private static final int KEYSIZE_B64_BYTES = 2 + (SigningPublicKey.KEYSIZE_BYTES * 4 / 3);
|
private static final int KEYSIZE_B64_BYTES = 2 + (SigningPublicKey.KEYSIZE_BYTES * 4 / 3);
|
||||||
|
|
||||||
private static final Map<String, String> DEFAULT_KEYS = new HashMap(4);
|
private static final Map<String, String> DEFAULT_KEYS = new HashMap<String, String>(4);
|
||||||
static {
|
static {
|
||||||
//DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p");
|
//DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p");
|
||||||
DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY2, "zzz@mail.i2p");
|
DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY2, "zzz@mail.i2p");
|
||||||
@@ -187,7 +187,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
|
|||||||
public TrustedUpdate(I2PAppContext context) {
|
public TrustedUpdate(I2PAppContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_log = _context.logManager().getLog(TrustedUpdate.class);
|
_log = _context.logManager().getLog(TrustedUpdate.class);
|
||||||
_trustedKeys = new HashMap(4);
|
_trustedKeys = new HashMap<SigningPublicKey, String>(4);
|
||||||
|
|
||||||
String propertyTrustedKeys = context.getProperty(PROP_TRUSTED_KEYS);
|
String propertyTrustedKeys = context.getProperty(PROP_TRUSTED_KEYS);
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class YKGenerator {
|
|||||||
MAX_NUM_BUILDERS = ctx.getProperty(PROP_YK_PRECALC_MAX, defaultMax);
|
MAX_NUM_BUILDERS = ctx.getProperty(PROP_YK_PRECALC_MAX, defaultMax);
|
||||||
|
|
||||||
CALC_DELAY = ctx.getProperty(PROP_YK_PRECALC_DELAY, DEFAULT_YK_PRECALC_DELAY);
|
CALC_DELAY = ctx.getProperty(PROP_YK_PRECALC_DELAY, DEFAULT_YK_PRECALC_DELAY);
|
||||||
_values = new LinkedBlockingQueue(MAX_NUM_BUILDERS);
|
_values = new LinkedBlockingQueue<BigInteger[]>(MAX_NUM_BUILDERS);
|
||||||
|
|
||||||
//if (_log.shouldLog(Log.DEBUG))
|
//if (_log.shouldLog(Log.DEBUG))
|
||||||
// _log.debug("ElGamal YK Precalc (minimum: " + MIN_NUM_BUILDERS + " max: " + MAX_NUM_BUILDERS + ", delay: "
|
// _log.debug("ElGamal YK Precalc (minimum: " + MIN_NUM_BUILDERS + " max: " + MAX_NUM_BUILDERS + ", delay: "
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class DataHelper {
|
|||||||
"version", "created", "upgraded", "lists",
|
"version", "created", "upgraded", "lists",
|
||||||
"a", "s",
|
"a", "s",
|
||||||
};
|
};
|
||||||
_propertiesKeyCache = new HashMap(keys.length);
|
_propertiesKeyCache = new HashMap<String, String>(keys.length);
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
_propertiesKeyCache.put(keys[i], keys[i]);
|
_propertiesKeyCache.put(keys[i], keys[i]);
|
||||||
}
|
}
|
||||||
@@ -1394,7 +1394,7 @@ public class DataHelper {
|
|||||||
* @return a new list
|
* @return a new list
|
||||||
*/
|
*/
|
||||||
public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) {
|
public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) {
|
||||||
if (dataStructures == null) return Collections.EMPTY_LIST;
|
if (dataStructures == null) return Collections.emptyList();
|
||||||
|
|
||||||
// This used to use Hash.toString(), which is insane, since a change to toString()
|
// This used to use Hash.toString(), which is insane, since a change to toString()
|
||||||
// would break the whole network. Now use Hash.toBase64().
|
// would break the whole network. Now use Hash.toBase64().
|
||||||
@@ -1409,7 +1409,7 @@ public class DataHelper {
|
|||||||
//for (DataStructure struct : tm.values()) {
|
//for (DataStructure struct : tm.values()) {
|
||||||
// rv.add(struct);
|
// rv.add(struct);
|
||||||
//}
|
//}
|
||||||
ArrayList<DataStructure> rv = new ArrayList(dataStructures);
|
ArrayList<DataStructure> rv = new ArrayList<DataStructure>(dataStructures);
|
||||||
sortStructureList(rv);
|
sortStructureList(rv);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.io.InputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
import net.i2p.util.LHMCache;
|
import net.i2p.util.LHMCache;
|
||||||
import net.i2p.util.SystemVersion;
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ public class Destination extends KeysAndCert {
|
|||||||
// I2PAppContext.getGlobalContext().statManager().createRateStat("DestCache", "Hit rate", "Router", new long[] { 10*60*1000 });
|
// I2PAppContext.getGlobalContext().statManager().createRateStat("DestCache", "Hit rate", "Router", new long[] { 10*60*1000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<SigningPublicKey, Destination> _cache = new LHMCache(CACHE_SIZE);
|
private static final Map<SigningPublicKey, Destination> _cache = new LHMCache<SigningPublicKey, Destination>(CACHE_SIZE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull from cache or return new
|
* Pull from cache or return new
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Hash extends SimpleDataStructure {
|
|||||||
public final static Hash FAKE_HASH = new Hash(new byte[HASH_LENGTH]);
|
public final static Hash FAKE_HASH = new Hash(new byte[HASH_LENGTH]);
|
||||||
private static final int CACHE_SIZE = 2048;
|
private static final int CACHE_SIZE = 2048;
|
||||||
|
|
||||||
private static final SDSCache<Hash> _cache = new SDSCache(Hash.class, HASH_LENGTH, CACHE_SIZE);
|
private static final SDSCache<Hash> _cache = new SDSCache<Hash>(Hash.class, HASH_LENGTH, CACHE_SIZE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull from cache or return new
|
* Pull from cache or return new
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class LeaseSet extends DatabaseEntry {
|
|||||||
private static final int OLD_MAX_LEASES = 6;
|
private static final int OLD_MAX_LEASES = 6;
|
||||||
|
|
||||||
public LeaseSet() {
|
public LeaseSet() {
|
||||||
_leases = new ArrayList(OLD_MAX_LEASES);
|
_leases = new ArrayList<Lease>(OLD_MAX_LEASES);
|
||||||
_firstExpiration = Long.MAX_VALUE;
|
_firstExpiration = Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ public class LeaseSet extends DatabaseEntry {
|
|||||||
_signingKey.writeBytes(out);
|
_signingKey.writeBytes(out);
|
||||||
DataHelper.writeLong(out, 1, _leases.size());
|
DataHelper.writeLong(out, 1, _leases.size());
|
||||||
//DataHelper.writeLong(out, 4, _version);
|
//DataHelper.writeLong(out, 4, _version);
|
||||||
for (Iterator iter = _leases.iterator(); iter.hasNext();) {
|
for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) {
|
||||||
Lease lease = (Lease) iter.next();
|
Lease lease = iter.next();
|
||||||
lease.writeBytes(out);
|
lease.writeBytes(out);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
@@ -339,8 +339,8 @@ public class LeaseSet extends DatabaseEntry {
|
|||||||
_signingKey.writeBytes(out);
|
_signingKey.writeBytes(out);
|
||||||
DataHelper.writeLong(out, 1, _leases.size());
|
DataHelper.writeLong(out, 1, _leases.size());
|
||||||
//DataHelper.writeLong(out, 4, _version);
|
//DataHelper.writeLong(out, 4, _version);
|
||||||
for (Iterator iter = _leases.iterator(); iter.hasNext();) {
|
for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) {
|
||||||
Lease lease = (Lease) iter.next();
|
Lease lease = iter.next();
|
||||||
lease.writeBytes(out);
|
lease.writeBytes(out);
|
||||||
}
|
}
|
||||||
_signature.writeBytes(out);
|
_signature.writeBytes(out);
|
||||||
@@ -494,7 +494,7 @@ public class LeaseSet extends DatabaseEntry {
|
|||||||
byte[] dec = new byte[enclen];
|
byte[] dec = new byte[enclen];
|
||||||
I2PAppContext.getGlobalContext().aes().decrypt(enc, 0, dec, 0, key, iv, enclen);
|
I2PAppContext.getGlobalContext().aes().decrypt(enc, 0, dec, 0, key, iv, enclen);
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(dec);
|
ByteArrayInputStream bais = new ByteArrayInputStream(dec);
|
||||||
_decryptedLeases = new ArrayList(size - 1);
|
_decryptedLeases = new ArrayList<Lease>(size - 1);
|
||||||
for (int i = 0; i < size-1; i++) {
|
for (int i = 0; i < size-1; i++) {
|
||||||
Lease l = new Lease();
|
Lease l = new Lease();
|
||||||
Hash h = new Hash();
|
Hash h = new Hash();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class PublicKey extends SimpleDataStructure {
|
|||||||
public final static int KEYSIZE_BYTES = 256;
|
public final static int KEYSIZE_BYTES = 256;
|
||||||
private static final int CACHE_SIZE = 1024;
|
private static final int CACHE_SIZE = 1024;
|
||||||
|
|
||||||
private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
private static final SDSCache<PublicKey> _cache = new SDSCache<PublicKey>(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull from cache or return new.
|
* Pull from cache or return new.
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class RouterInfo extends DatabaseEntry {
|
|||||||
*/
|
*/
|
||||||
public Set<Hash> getPeers() {
|
public Set<Hash> getPeers() {
|
||||||
if (_peers == null)
|
if (_peers == null)
|
||||||
return Collections.EMPTY_SET;
|
return Collections.emptySet();
|
||||||
return _peers;
|
return _peers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public class RouterInfo extends DatabaseEntry {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_peers == null)
|
if (_peers == null)
|
||||||
_peers = new HashSet(2);
|
_peers = new HashSet<Hash>(2);
|
||||||
synchronized (_peers) {
|
synchronized (_peers) {
|
||||||
_peers.clear();
|
_peers.clear();
|
||||||
_peers.addAll(peers);
|
_peers.addAll(peers);
|
||||||
@@ -546,7 +546,7 @@ public class RouterInfo extends DatabaseEntry {
|
|||||||
if (numPeers == 0) {
|
if (numPeers == 0) {
|
||||||
_peers = null;
|
_peers = null;
|
||||||
} else {
|
} else {
|
||||||
_peers = new HashSet(numPeers);
|
_peers = new HashSet<Hash>(numPeers);
|
||||||
for (int i = 0; i < numPeers; i++) {
|
for (int i = 0; i < numPeers; i++) {
|
||||||
Hash peerIdentityHash = new Hash();
|
Hash peerIdentityHash = new Hash();
|
||||||
peerIdentityHash.readBytes(din);
|
peerIdentityHash.readBytes(din);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SDSCache<V extends SimpleDataStructure> {
|
|||||||
*/
|
*/
|
||||||
public SDSCache(Class<V> rvClass, int len, int max) {
|
public SDSCache(Class<V> rvClass, int len, int max) {
|
||||||
int size = (int) (max * FACTOR);
|
int size = (int) (max * FACTOR);
|
||||||
_cache = new LHMCache(size);
|
_cache = new LHMCache<Integer, WeakReference<V>>(size);
|
||||||
_datalen = len;
|
_datalen = len;
|
||||||
try {
|
try {
|
||||||
_rvCon = rvClass.getConstructor(conArg);
|
_rvCon = rvClass.getConstructor(conArg);
|
||||||
@@ -135,7 +135,7 @@ public class SDSCache<V extends SimpleDataStructure> {
|
|||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new RuntimeException("SDSCache error", e);
|
throw new RuntimeException("SDSCache error", e);
|
||||||
}
|
}
|
||||||
_cache.put(key, new WeakReference(rv));
|
_cache.put(key, new WeakReference<V>(rv));
|
||||||
found = 0;
|
found = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class SigningPublicKey extends SimpleDataStructure {
|
|||||||
public final static int KEYSIZE_BYTES = DEF_TYPE.getPubkeyLen();
|
public final static int KEYSIZE_BYTES = DEF_TYPE.getPubkeyLen();
|
||||||
private static final int CACHE_SIZE = 1024;
|
private static final int CACHE_SIZE = 1024;
|
||||||
|
|
||||||
private static final SDSCache<SigningPublicKey> _cache = new SDSCache(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
private static final SDSCache<SigningPublicKey> _cache = new SDSCache<SigningPublicKey>(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
||||||
|
|
||||||
private final SigType _type;
|
private final SigType _type;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
import net.i2p.data.LeaseSet;
|
import net.i2p.data.LeaseSet;
|
||||||
import net.i2p.data.PrivateKey;
|
import net.i2p.data.PrivateKey;
|
||||||
import net.i2p.data.SigningPrivateKey;
|
import net.i2p.data.SigningPrivateKey;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the message a client sends to a router when establishing a new
|
* Defines the message a client sends to a router when establishing a new
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the message a client sends to a router when destroying
|
* Defines the message a client sends to a router when destroying
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the message a client sends to a router when
|
* Defines the message a client sends to a router when
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the message a client sends to a router when asking the
|
* Defines the message a client sends to a router when asking the
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
private Date _end;
|
private Date _end;
|
||||||
|
|
||||||
public RequestLeaseSetMessage() {
|
public RequestLeaseSetMessage() {
|
||||||
_endpoints = new ArrayList();
|
_endpoints = new ArrayList<TunnelEndpoint>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionId getSessionId() {
|
public SessionId getSessionId() {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class RequestVariableLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
private static final String MIN_VERSION = "0.9.7";
|
private static final String MIN_VERSION = "0.9.7";
|
||||||
|
|
||||||
public RequestVariableLeaseSetMessage() {
|
public RequestVariableLeaseSetMessage() {
|
||||||
_endpoints = new ArrayList();
|
_endpoints = new ArrayList<Lease>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class BufferedStatLog implements StatLog {
|
|||||||
private int _lastWrite;
|
private int _lastWrite;
|
||||||
/** flush stat events to disk after this many events (or 30s)*/
|
/** flush stat events to disk after this many events (or 30s)*/
|
||||||
private int _flushFrequency;
|
private int _flushFrequency;
|
||||||
private final List _statFilters;
|
private final List<String> _statFilters;
|
||||||
private String _lastFilters;
|
private String _lastFilters;
|
||||||
private BufferedWriter _out;
|
private BufferedWriter _out;
|
||||||
private String _outFile;
|
private String _outFile;
|
||||||
@@ -45,7 +45,7 @@ public class BufferedStatLog implements StatLog {
|
|||||||
_events[i] = new StatEvent();
|
_events[i] = new StatEvent();
|
||||||
_eventNext = 0;
|
_eventNext = 0;
|
||||||
_lastWrite = _events.length-1;
|
_lastWrite = _events.length-1;
|
||||||
_statFilters = new ArrayList(10);
|
_statFilters = new ArrayList<String>(10);
|
||||||
_flushFrequency = 500;
|
_flushFrequency = 500;
|
||||||
updateFilters();
|
updateFilters();
|
||||||
I2PThread writer = new I2PThread(new StatLogWriter(), "StatLogWriter");
|
I2PThread writer = new I2PThread(new StatLogWriter(), "StatLogWriter");
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package net.i2p.update;
|
package net.i2p.update;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls one or more types of updates.
|
* Controls one or more types of updates.
|
||||||
* This must be registered with the UpdateManager.
|
* This must be registered with the UpdateManager.
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public abstract class Addresses {
|
|||||||
boolean includeIPv6) {
|
boolean includeIPv6) {
|
||||||
boolean haveIPv4 = false;
|
boolean haveIPv4 = false;
|
||||||
boolean haveIPv6 = false;
|
boolean haveIPv6 = false;
|
||||||
SortedSet<String> rv = new TreeSet();
|
SortedSet<String> rv = new TreeSet<String>();
|
||||||
try {
|
try {
|
||||||
InetAddress localhost = InetAddress.getLocalHost();
|
InetAddress localhost = InetAddress.getLocalHost();
|
||||||
InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());
|
InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());
|
||||||
@@ -236,7 +236,7 @@ public abstract class Addresses {
|
|||||||
} else {
|
} else {
|
||||||
size = 32;
|
size = 32;
|
||||||
}
|
}
|
||||||
_IPAddress = new LHMCache(size);
|
_IPAddress = new LHMCache<String, byte[]>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import net.i2p.data.ByteArray;
|
|||||||
public final class ByteCache {
|
public final class ByteCache {
|
||||||
|
|
||||||
//private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(ByteCache.class);
|
//private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(ByteCache.class);
|
||||||
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap(16);
|
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap<Integer, ByteCache>(16);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* max size in bytes of each cache
|
* max size in bytes of each cache
|
||||||
@@ -119,7 +119,7 @@ public final class ByteCache {
|
|||||||
|
|
||||||
private ByteCache(int maxCachedEntries, int entrySize) {
|
private ByteCache(int maxCachedEntries, int entrySize) {
|
||||||
if (_cache)
|
if (_cache)
|
||||||
_available = new LinkedBlockingQueue(maxCachedEntries);
|
_available = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
|
||||||
_maxCached = maxCachedEntries;
|
_maxCached = maxCachedEntries;
|
||||||
_entrySize = entrySize;
|
_entrySize = entrySize;
|
||||||
_lastOverflow = -1;
|
_lastOverflow = -1;
|
||||||
@@ -131,7 +131,7 @@ public final class ByteCache {
|
|||||||
if (_maxCached >= maxCachedEntries) return;
|
if (_maxCached >= maxCachedEntries) return;
|
||||||
_maxCached = maxCachedEntries;
|
_maxCached = maxCachedEntries;
|
||||||
// make a bigger one, move the cached items over
|
// make a bigger one, move the cached items over
|
||||||
Queue<ByteArray> newLBQ = new LinkedBlockingQueue(maxCachedEntries);
|
Queue<ByteArray> newLBQ = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
|
||||||
ByteArray ba;
|
ByteArray ba;
|
||||||
while ((ba = _available.poll()) != null)
|
while ((ba = _available.poll()) != null)
|
||||||
newLBQ.offer(ba);
|
newLBQ.offer(ba);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Clock implements Timestamper.UpdateListener {
|
|||||||
|
|
||||||
public Clock(I2PAppContext context) {
|
public Clock(I2PAppContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_listeners = new CopyOnWriteArraySet();
|
_listeners = new CopyOnWriteArraySet<ClockUpdateListener>();
|
||||||
_startedOn = System.currentTimeMillis();
|
_startedOn = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements Set<E> {
|
|||||||
private final Map<E, Object> _map;
|
private final Map<E, Object> _map;
|
||||||
|
|
||||||
public ConcurrentHashSet() {
|
public ConcurrentHashSet() {
|
||||||
_map = new ConcurrentHashMap();
|
_map = new ConcurrentHashMap<E, Object>();
|
||||||
}
|
}
|
||||||
public ConcurrentHashSet(int capacity) {
|
public ConcurrentHashSet(int capacity) {
|
||||||
_map = new ConcurrentHashMap(capacity);
|
_map = new ConcurrentHashMap<E, Object>(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class EepGet {
|
|||||||
_postData = postData;
|
_postData = postData;
|
||||||
_bytesRemaining = -1;
|
_bytesRemaining = -1;
|
||||||
_fetchHeaderTimeout = CONNECT_TIMEOUT;
|
_fetchHeaderTimeout = CONNECT_TIMEOUT;
|
||||||
_listeners = new ArrayList(1);
|
_listeners = new ArrayList<StatusListener>(1);
|
||||||
_etag = etag;
|
_etag = etag;
|
||||||
_lastModified = lastModified;
|
_lastModified = lastModified;
|
||||||
_etagOrig = etag;
|
_etagOrig = etag;
|
||||||
@@ -190,7 +190,7 @@ public class EepGet {
|
|||||||
lineLen = Integer.parseInt(args[++i]);
|
lineLen = Integer.parseInt(args[++i]);
|
||||||
} else if (args[i].equals("-h")) {
|
} else if (args[i].equals("-h")) {
|
||||||
if (extra == null)
|
if (extra == null)
|
||||||
extra = new ArrayList(2);
|
extra = new ArrayList<String>(2);
|
||||||
extra.add(args[++i]);
|
extra.add(args[++i]);
|
||||||
extra.add(args[++i]);
|
extra.add(args[++i]);
|
||||||
} else if (args[i].equals("-u")) {
|
} else if (args[i].equals("-u")) {
|
||||||
@@ -1241,7 +1241,7 @@ public class EepGet {
|
|||||||
*/
|
*/
|
||||||
public void addHeader(String name, String value) {
|
public void addHeader(String name, String value) {
|
||||||
if (_extraHeaders == null)
|
if (_extraHeaders == null)
|
||||||
_extraHeaders = new ArrayList();
|
_extraHeaders = new ArrayList<String>();
|
||||||
_extraHeaders.add(name + ": " + value);
|
_extraHeaders.add(name + ": " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public interface EventDispatcher {
|
|||||||
*
|
*
|
||||||
* @return A set of event names
|
* @return A set of event names
|
||||||
*/
|
*/
|
||||||
public Set getEvents();
|
public Set<String> getEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignore further event notifications
|
* Ignore further event notifications
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
public class EventDispatcherImpl implements EventDispatcher {
|
public class EventDispatcherImpl implements EventDispatcher {
|
||||||
|
|
||||||
private boolean _ignore = false;
|
private boolean _ignore = false;
|
||||||
private final Map<String, Object> _events = new ConcurrentHashMap(4);
|
private final Map<String, Object> _events = new ConcurrentHashMap<String, Object>(4);
|
||||||
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList();
|
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList<EventDispatcher>();
|
||||||
|
|
||||||
public EventDispatcher getEventDispatcher() {
|
public EventDispatcher getEventDispatcher() {
|
||||||
return this;
|
return this;
|
||||||
@@ -72,8 +72,8 @@ public class EventDispatcherImpl implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getEvents() {
|
public Set<String> getEvents() {
|
||||||
if (_ignore) return Collections.EMPTY_SET;
|
if (_ignore) return Collections.emptySet();
|
||||||
return new HashSet(_events.keySet());
|
return new HashSet<String>(_events.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignoreEvents() {
|
public void ignoreEvents() {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class FileUtil {
|
|||||||
try {
|
try {
|
||||||
byte buf[] = new byte[16*1024];
|
byte buf[] = new byte[16*1024];
|
||||||
zip = new ZipFile(zipfile);
|
zip = new ZipFile(zipfile);
|
||||||
Enumeration entries = zip.entries();
|
Enumeration<? extends ZipEntry> entries = zip.entries();
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
ZipEntry entry = (ZipEntry)entries.nextElement();
|
ZipEntry entry = (ZipEntry)entries.nextElement();
|
||||||
if (entry.getName().indexOf("..") != -1) {
|
if (entry.getName().indexOf("..") != -1) {
|
||||||
@@ -215,7 +215,7 @@ public class FileUtil {
|
|||||||
try {
|
try {
|
||||||
byte buf[] = new byte[16*1024];
|
byte buf[] = new byte[16*1024];
|
||||||
zip = new ZipFile(zipfile);
|
zip = new ZipFile(zipfile);
|
||||||
Enumeration entries = zip.entries();
|
Enumeration<? extends ZipEntry> entries = zip.entries();
|
||||||
boolean p200TestRequired = true;
|
boolean p200TestRequired = true;
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
ZipEntry entry = (ZipEntry)entries.nextElement();
|
ZipEntry entry = (ZipEntry)entries.nextElement();
|
||||||
@@ -358,7 +358,7 @@ public class FileUtil {
|
|||||||
try {
|
try {
|
||||||
fis = new FileInputStream(f);
|
fis = new FileInputStream(f);
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
|
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
|
||||||
List lines = new ArrayList(maxNumLines > 0 ? maxNumLines : 64);
|
List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64);
|
||||||
String line = null;
|
String line = null;
|
||||||
while ( (line = in.readLine()) != null) {
|
while ( (line = in.readLine()) != null) {
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
*/
|
*/
|
||||||
public class I2PAppThread extends I2PThread {
|
public class I2PAppThread extends I2PThread {
|
||||||
|
|
||||||
private final Set _threadListeners = new CopyOnWriteArraySet();
|
private final Set<OOMEventListener> _threadListeners = new CopyOnWriteArraySet<OOMEventListener>();
|
||||||
|
|
||||||
public I2PAppThread() {
|
public I2PAppThread() {
|
||||||
super();
|
super();
|
||||||
@@ -45,8 +45,8 @@ public class I2PAppThread extends I2PThread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fireOOM(OutOfMemoryError oom) {
|
protected void fireOOM(OutOfMemoryError oom) {
|
||||||
for (Iterator iter = _threadListeners.iterator(); iter.hasNext(); ) {
|
for (Iterator<OOMEventListener> iter = _threadListeners.iterator(); iter.hasNext(); ) {
|
||||||
OOMEventListener listener = (OOMEventListener)iter.next();
|
OOMEventListener listener = iter.next();
|
||||||
listener.outOfMemory(oom);
|
listener.outOfMemory(oom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package net.i2p.util;
|
package net.i2p.util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class I2PThread extends Thread {
|
|||||||
* Logging removed, too much trouble with extra contexts
|
* Logging removed, too much trouble with extra contexts
|
||||||
*/
|
*/
|
||||||
//private volatile Log _log;
|
//private volatile Log _log;
|
||||||
private static final Set _listeners = new CopyOnWriteArraySet();
|
private static final Set<OOMEventListener> _listeners = new CopyOnWriteArraySet<OOMEventListener>();
|
||||||
//private String _name;
|
//private String _name;
|
||||||
//private Exception _createdBy;
|
//private Exception _createdBy;
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ public class I2PThread extends Thread {
|
|||||||
****/
|
****/
|
||||||
|
|
||||||
protected void fireOOM(OutOfMemoryError oom) {
|
protected void fireOOM(OutOfMemoryError oom) {
|
||||||
for (Iterator iter = _listeners.iterator(); iter.hasNext(); ) {
|
for (Iterator<OOMEventListener> iter = _listeners.iterator(); iter.hasNext(); ) {
|
||||||
OOMEventListener listener = (OOMEventListener)iter.next();
|
OOMEventListener listener = iter.next();
|
||||||
listener.outOfMemory(oom);
|
listener.outOfMemory(oom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||||||
* @since 0.7.9
|
* @since 0.7.9
|
||||||
*/
|
*/
|
||||||
public class InternalServerSocket extends ServerSocket {
|
public class InternalServerSocket extends ServerSocket {
|
||||||
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
|
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap<Integer, InternalServerSocket>(4);
|
||||||
private final BlockingQueue<InternalSocket> _acceptQueue;
|
private final BlockingQueue<InternalSocket> _acceptQueue;
|
||||||
private final Integer _port;
|
private final Integer _port;
|
||||||
private volatile boolean _running;
|
private volatile boolean _running;
|
||||||
@@ -41,7 +41,7 @@ public class InternalServerSocket extends ServerSocket {
|
|||||||
if (previous != null)
|
if (previous != null)
|
||||||
throw new IOException("Internal port in use: " + port);
|
throw new IOException("Internal port in use: " + port);
|
||||||
_running = true;
|
_running = true;
|
||||||
_acceptQueue = new LinkedBlockingQueue();
|
_acceptQueue = new LinkedBlockingQueue<InternalSocket>();
|
||||||
//if (_log.shouldLog(Log.DEBUG))
|
//if (_log.shouldLog(Log.DEBUG))
|
||||||
// _log.debug("Registered " + _port);
|
// _log.debug("Registered " + _port);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ public class LogConsoleBuffer {
|
|||||||
lim = Math.max(limit, 4);
|
lim = Math.max(limit, 4);
|
||||||
// Add some extra room to minimize the chance of losing a message,
|
// Add some extra room to minimize the chance of losing a message,
|
||||||
// since we are doing offer() below.
|
// since we are doing offer() below.
|
||||||
_buffer = new LinkedBlockingQueue(lim + 4);
|
_buffer = new LinkedBlockingQueue<String>(lim + 4);
|
||||||
_critBuffer = new LinkedBlockingQueue(lim + 4);
|
_critBuffer = new LinkedBlockingQueue<String>(lim + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(String msg) {
|
void add(String msg) {
|
||||||
@@ -64,7 +64,7 @@ public class LogConsoleBuffer {
|
|||||||
* @return oldest first
|
* @return oldest first
|
||||||
*/
|
*/
|
||||||
public List<String> getMostRecentMessages() {
|
public List<String> getMostRecentMessages() {
|
||||||
return new ArrayList(_buffer);
|
return new ArrayList<String>(_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +75,7 @@ public class LogConsoleBuffer {
|
|||||||
* @return oldest first
|
* @return oldest first
|
||||||
*/
|
*/
|
||||||
public List<String> getMostRecentCriticalMessages() {
|
public List<String> getMostRecentCriticalMessages() {
|
||||||
return new ArrayList(_critBuffer);
|
return new ArrayList<String>(_critBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ public class LogManager {
|
|||||||
public LogManager(I2PAppContext context) {
|
public LogManager(I2PAppContext context) {
|
||||||
_displayOnScreen = true;
|
_displayOnScreen = true;
|
||||||
_alreadyNoticedMissingConfig = false;
|
_alreadyNoticedMissingConfig = false;
|
||||||
_limits = new ConcurrentHashSet();
|
_limits = new ConcurrentHashSet<LogLimit>();
|
||||||
_logs = new ConcurrentHashMap(128);
|
_logs = new ConcurrentHashMap<Object, Log>(128);
|
||||||
_defaultLimit = Log.ERROR;
|
_defaultLimit = Log.ERROR;
|
||||||
_context = context;
|
_context = context;
|
||||||
_log = getLog(LogManager.class);
|
_log = getLog(LogManager.class);
|
||||||
String location = context.getProperty(CONFIG_LOCATION_PROP, CONFIG_LOCATION_DEFAULT);
|
String location = context.getProperty(CONFIG_LOCATION_PROP, CONFIG_LOCATION_DEFAULT);
|
||||||
setConfig(location);
|
setConfig(location);
|
||||||
_records = new LinkedBlockingQueue(_logBufferSize);
|
_records = new LinkedBlockingQueue<LogRecord>(_logBufferSize);
|
||||||
_consoleBuffer = new LogConsoleBuffer(_consoleBufferSize);
|
_consoleBuffer = new LogConsoleBuffer(_consoleBufferSize);
|
||||||
// If we aren't in the router context, delay creating the LogWriter until required,
|
// If we aren't in the router context, delay creating the LogWriter until required,
|
||||||
// so it doesn't create a log directory and log files unless there is output.
|
// so it doesn't create a log directory and log files unless there is output.
|
||||||
@@ -582,7 +582,7 @@ public class LogManager {
|
|||||||
for (LogLimit limit : _limits) {
|
for (LogLimit limit : _limits) {
|
||||||
if (limit.matches(log)) {
|
if (limit.matches(log)) {
|
||||||
if (limits == null)
|
if (limits == null)
|
||||||
limits = new ArrayList(4);
|
limits = new ArrayList<LogLimit>(4);
|
||||||
limits.add(limit);
|
limits.add(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import freenet.support.CPUInformation.UnknownCPUException;
|
|||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.crypto.CryptoConstants;
|
import net.i2p.crypto.CryptoConstants;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>BigInteger that takes advantage of the jbigi library for the modPow operation,
|
* <p>BigInteger that takes advantage of the jbigi library for the modPow operation,
|
||||||
@@ -627,8 +626,8 @@ public class NativeBigInteger extends BigInteger {
|
|||||||
*/
|
*/
|
||||||
private static List<String> getResourceList() {
|
private static List<String> getResourceList() {
|
||||||
if (_isAndroid)
|
if (_isAndroid)
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
List<String> rv = new ArrayList(8);
|
List<String> rv = new ArrayList<String>(8);
|
||||||
String primary = getMiddleName2(true);
|
String primary = getMiddleName2(true);
|
||||||
if (primary != null) {
|
if (primary != null) {
|
||||||
if (_is64) {
|
if (_is64) {
|
||||||
@@ -708,7 +707,7 @@ public class NativeBigInteger extends BigInteger {
|
|||||||
* @since 0.9.1
|
* @since 0.9.1
|
||||||
*/
|
*/
|
||||||
private static Map<String, String> getCPUInfo() {
|
private static Map<String, String> getCPUInfo() {
|
||||||
Map<String, String> rv = new HashMap(32);
|
Map<String, String> rv = new HashMap<String, String>(32);
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/cpuinfo"), "ISO-8859-1"), 4096);
|
in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/cpuinfo"), "ISO-8859-1"), 4096);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class PortMapper {
|
|||||||
* @param context unused for now
|
* @param context unused for now
|
||||||
*/
|
*/
|
||||||
public PortMapper(I2PAppContext context) {
|
public PortMapper(I2PAppContext context) {
|
||||||
_dir = new ConcurrentHashMap(8);
|
_dir = new ConcurrentHashMap<String, Integer>(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class ReusableGZIPInputStream extends ResettableGZIPInputStream {
|
|||||||
private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
|
private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
|
||||||
static {
|
static {
|
||||||
if (ENABLE_CACHING)
|
if (ENABLE_CACHING)
|
||||||
_available = new LinkedBlockingQueue(8);
|
_available = new LinkedBlockingQueue<ReusableGZIPInputStream>(8);
|
||||||
else
|
else
|
||||||
_available = null;
|
_available = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
|
|||||||
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
|
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
|
||||||
static {
|
static {
|
||||||
if (ENABLE_CACHING)
|
if (ENABLE_CACHING)
|
||||||
_available = new LinkedBlockingQueue(16);
|
_available = new LinkedBlockingQueue<ReusableGZIPOutputStream>(16);
|
||||||
else
|
else
|
||||||
_available = null;
|
_available = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ package net.i2p.util;
|
|||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
@@ -50,8 +48,6 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.cert.Certificate;
|
|
||||||
import java.security.cert.CertificateEncodingException;
|
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.i2p.util;
|
package net.i2p.util;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -16,7 +15,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||||||
*/
|
*/
|
||||||
public final class SimpleByteCache {
|
public final class SimpleByteCache {
|
||||||
|
|
||||||
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap(8);
|
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap<Integer, SimpleByteCache>(8);
|
||||||
|
|
||||||
private static final int DEFAULT_SIZE = 64;
|
private static final int DEFAULT_SIZE = 64;
|
||||||
|
|
||||||
@@ -89,8 +88,8 @@ public final class SimpleByteCache {
|
|||||||
*/
|
*/
|
||||||
private Queue<byte[]> createQueue() {
|
private Queue<byte[]> createQueue() {
|
||||||
if (_entrySize <= MAX_FOR_ABQ)
|
if (_entrySize <= MAX_FOR_ABQ)
|
||||||
return new ArrayBlockingQueue(_maxCached);
|
return new ArrayBlockingQueue<byte[]>(_maxCached);
|
||||||
return new LinkedBlockingQueue(_maxCached);
|
return new LinkedBlockingQueue<byte[]>(_maxCached);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ public class SimpleTimer {
|
|||||||
private SimpleTimer(I2PAppContext context, String name) {
|
private SimpleTimer(I2PAppContext context, String name) {
|
||||||
runn = new SimpleStore(true);
|
runn = new SimpleStore(true);
|
||||||
_log = context.logManager().getLog(SimpleTimer.class);
|
_log = context.logManager().getLog(SimpleTimer.class);
|
||||||
_events = new TreeMap();
|
_events = new TreeMap<Long, TimedEvent>();
|
||||||
_eventTimes = new HashMap(256);
|
_eventTimes = new HashMap<TimedEvent, Long>(256);
|
||||||
_readyEvents = new ArrayList(4);
|
_readyEvents = new ArrayList<TimedEvent>(4);
|
||||||
I2PThread runner = new I2PThread(new SimpleTimerRunner());
|
I2PThread runner = new I2PThread(new SimpleTimerRunner());
|
||||||
runner.setName(name);
|
runner.setName(name);
|
||||||
runner.setDaemon(true);
|
runner.setDaemon(true);
|
||||||
@@ -155,8 +155,8 @@ public class SimpleTimer {
|
|||||||
|
|
||||||
if ( (_events.size() != _eventTimes.size()) ) {
|
if ( (_events.size() != _eventTimes.size()) ) {
|
||||||
_log.error("Skewed events: " + _events.size() + " for " + _eventTimes.size());
|
_log.error("Skewed events: " + _events.size() + " for " + _eventTimes.size());
|
||||||
for (Iterator iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<TimedEvent> iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
|
||||||
TimedEvent evt = (TimedEvent)iter.next();
|
TimedEvent evt = iter.next();
|
||||||
Long when = _eventTimes.get(evt);
|
Long when = _eventTimes.get(evt);
|
||||||
TimedEvent cur = _events.get(when);
|
TimedEvent cur = _events.get(when);
|
||||||
if (cur != evt) {
|
if (cur != evt) {
|
||||||
@@ -209,7 +209,7 @@ public class SimpleTimer {
|
|||||||
// private TimedEvent _recentEvents[] = new TimedEvent[5];
|
// private TimedEvent _recentEvents[] = new TimedEvent[5];
|
||||||
private class SimpleTimerRunner implements Runnable {
|
private class SimpleTimerRunner implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
List<TimedEvent> eventsToFire = new ArrayList(1);
|
List<TimedEvent> eventsToFire = new ArrayList<TimedEvent>(1);
|
||||||
while(runn.getAnswer()) {
|
while(runn.getAnswer()) {
|
||||||
try {
|
try {
|
||||||
synchronized (_events) {
|
synchronized (_events) {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import net.i2p.util.ConcurrentHashSet;
|
|||||||
public abstract class Translate {
|
public abstract class Translate {
|
||||||
public static final String PROP_LANG = "routerconsole.lang";
|
public static final String PROP_LANG = "routerconsole.lang";
|
||||||
private static final String _localeLang = Locale.getDefault().getLanguage();
|
private static final String _localeLang = Locale.getDefault().getLanguage();
|
||||||
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(16);
|
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap<String, ResourceBundle>(16);
|
||||||
private static final Set<String> _missing = new ConcurrentHashSet(16);
|
private static final Set<String> _missing = new ConcurrentHashSet<String>(16);
|
||||||
/** use to look for untagged strings */
|
/** use to look for untagged strings */
|
||||||
private static final String TEST_LANG = "xx";
|
private static final String TEST_LANG = "xx";
|
||||||
private static final String TEST_STRING = "XXXX";
|
private static final String TEST_STRING = "XXXX";
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class TranslateReader extends FilterReader {
|
|||||||
super(new BufferedReader(new InputStreamReader(in, "UTF-8")));
|
super(new BufferedReader(new InputStreamReader(in, "UTF-8")));
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
_bundle = bundle;
|
_bundle = bundle;
|
||||||
_args = new ArrayList(4);
|
_args = new ArrayList<String>(4);
|
||||||
_inBuf = new StringBuilder(64);
|
_inBuf = new StringBuilder(64);
|
||||||
_outBuf = new StringBuilder(64);
|
_outBuf = new StringBuilder(64);
|
||||||
_argBuf = new StringBuilder(64);
|
_argBuf = new StringBuilder(64);
|
||||||
@@ -415,7 +415,7 @@ public class TranslateReader extends FilterReader {
|
|||||||
File[] listing = dir.listFiles();
|
File[] listing = dir.listFiles();
|
||||||
if (listing == null)
|
if (listing == null)
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
filelist = new ArrayList(listing.length);
|
filelist = new ArrayList<String>(listing.length);
|
||||||
for (int i = 0; i < listing.length; i++) {
|
for (int i = 0; i < listing.length; i++) {
|
||||||
File f = listing[i];
|
File f = listing[i];
|
||||||
if (!f.isDirectory())
|
if (!f.isDirectory())
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class BlockFile {
|
|||||||
private boolean _isClosed;
|
private boolean _isClosed;
|
||||||
/** cached list of free pages, only valid if freListStart > 0 */
|
/** cached list of free pages, only valid if freListStart > 0 */
|
||||||
private FreeListBlock flb;
|
private FreeListBlock flb;
|
||||||
private final HashMap openIndices = new HashMap();
|
private final HashMap<String, BSkipList> openIndices = new HashMap<String, BSkipList>();
|
||||||
|
|
||||||
private void mount() throws IOException {
|
private void mount() throws IOException {
|
||||||
file.seek(BlockFile.OFFSET_MOUNTED);
|
file.seek(BlockFile.OFFSET_MOUNTED);
|
||||||
@@ -481,12 +481,12 @@ public class BlockFile {
|
|||||||
_isClosed = true;
|
_isClosed = true;
|
||||||
metaIndex.close();
|
metaIndex.close();
|
||||||
|
|
||||||
Set oi = openIndices.keySet();
|
Set<String> oi = openIndices.keySet();
|
||||||
Iterator i = oi.iterator();
|
Iterator<String> i = oi.iterator();
|
||||||
Object k;
|
Object k;
|
||||||
while(i.hasNext()) {
|
while(i.hasNext()) {
|
||||||
k = i.next();
|
k = i.next();
|
||||||
BSkipList bsl = (BSkipList) openIndices.get(k);
|
BSkipList bsl = openIndices.get(k);
|
||||||
bsl.close();
|
bsl.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
* @since 0.8.8
|
* @since 0.8.8
|
||||||
*/
|
*/
|
||||||
private boolean blvlfix() {
|
private boolean blvlfix() {
|
||||||
TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator());
|
TreeSet<SkipLevels> lvls = new TreeSet<SkipLevels>(new LevelComparator());
|
||||||
if (bf.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
bf.log.debug("Starting level search");
|
bf.log.debug("Starting level search");
|
||||||
getAllLevels(this, lvls);
|
getAllLevels(this, lvls);
|
||||||
@@ -284,7 +284,7 @@ public class BSkipLevels extends SkipLevels {
|
|||||||
* @param lvlSet out parameter, the result
|
* @param lvlSet out parameter, the result
|
||||||
* @since 0.8.8
|
* @since 0.8.8
|
||||||
*/
|
*/
|
||||||
private void getAllLevels(SkipLevels l, Set lvlSet) {
|
private void getAllLevels(SkipLevels l, Set<SkipLevels> lvlSet) {
|
||||||
if (bf.log.shouldLog(Log.DEBUG))
|
if (bf.log.shouldLog(Log.DEBUG))
|
||||||
bf.log.debug("GAL " + l.print());
|
bf.log.debug("GAL " + l.print());
|
||||||
// Do level 0 without recursion, on the assumption everything is findable
|
// Do level 0 without recursion, on the assumption everything is findable
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ public class BSkipList extends SkipList {
|
|||||||
public final BlockFile bf;
|
public final BlockFile bf;
|
||||||
private boolean isClosed;
|
private boolean isClosed;
|
||||||
|
|
||||||
final HashMap<Integer, BSkipSpan> spanHash = new HashMap();
|
final HashMap<Integer, BSkipSpan> spanHash = new HashMap<Integer, BSkipSpan>();
|
||||||
final HashMap<Integer, SkipLevels> levelHash = new HashMap();
|
final HashMap<Integer, SkipLevels> levelHash = new HashMap<Integer, SkipLevels>();
|
||||||
|
|
||||||
private final boolean fileOnly;
|
private final boolean fileOnly;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user