findbugs router, router/client
This commit is contained in:
@ -679,7 +679,7 @@ public class Blocklist {
|
|||||||
return;
|
return;
|
||||||
Job job = new ShitlistJob(peer);
|
Job job = new ShitlistJob(peer);
|
||||||
if (number > 0)
|
if (number > 0)
|
||||||
job.getTiming().setStartAfter(_context.clock().now() + (number * 30*1000));
|
job.getTiming().setStartAfter(_context.clock().now() + (30*1000l * number));
|
||||||
_context.jobQueue().addJob(job);
|
_context.jobQueue().addJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public class JobQueue {
|
|||||||
* <code>false</code> if the job is finished or doesn't exist in the queue.
|
* <code>false</code> if the job is finished or doesn't exist in the queue.
|
||||||
*/
|
*/
|
||||||
public boolean isJobActive(Job job) {
|
public boolean isJobActive(Job job) {
|
||||||
if (_readyJobs.contains(job) | _timedJobs.contains(job))
|
if (_readyJobs.contains(job) || _timedJobs.contains(job))
|
||||||
return true;
|
return true;
|
||||||
for (JobQueueRunner runner: _queueRunners.values())
|
for (JobQueueRunner runner: _queueRunners.values())
|
||||||
if (runner.getCurrentJob() == job)
|
if (runner.getCurrentJob() == job)
|
||||||
@ -689,7 +689,7 @@ public class JobQueue {
|
|||||||
TreeMap<Long, Job> ordered = new TreeMap();
|
TreeMap<Long, Job> ordered = new TreeMap();
|
||||||
for (int i = 0; i < timedJobs.size(); i++) {
|
for (int i = 0; i < timedJobs.size(); i++) {
|
||||||
Job j = timedJobs.get(i);
|
Job j = timedJobs.get(i);
|
||||||
ordered.put(new Long(j.getTiming().getStartAfter()), j);
|
ordered.put(Long.valueOf(j.getTiming().getStartAfter()), j);
|
||||||
}
|
}
|
||||||
for (Iterator<Job> iter = ordered.values().iterator(); iter.hasNext(); ) {
|
for (Iterator<Job> iter = ordered.values().iterator(); iter.hasNext(); ) {
|
||||||
Job j = iter.next();
|
Job j = iter.next();
|
||||||
|
@ -90,13 +90,17 @@ public class MultiRouter {
|
|||||||
|
|
||||||
private static Properties getEnv(String filename) {
|
private static Properties getEnv(String filename) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
FileInputStream in = null;
|
||||||
try {
|
try {
|
||||||
props.load(new FileInputStream(filename));
|
in = new FileInputStream(filename);
|
||||||
|
props.load(in);
|
||||||
props.setProperty("time.disabled", "true");
|
props.setProperty("time.disabled", "true");
|
||||||
return props;
|
return props;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
} finally {
|
||||||
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +89,18 @@ public class OutNetMessage {
|
|||||||
// only timestamp if we are debugging
|
// only timestamp if we are debugging
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
locked_initTimestamps();
|
locked_initTimestamps();
|
||||||
while (_timestamps.containsKey(eventName)) {
|
// ???
|
||||||
eventName = eventName + '.';
|
//while (_timestamps.containsKey(eventName)) {
|
||||||
}
|
// eventName = eventName + '.';
|
||||||
_timestamps.put(eventName, new Long(now));
|
//}
|
||||||
|
_timestamps.put(eventName, Long.valueOf(now));
|
||||||
_timestampOrder.add(eventName);
|
_timestampOrder.add(eventName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return now - _created;
|
return now - _created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated unused */
|
||||||
public Map<String, Long> getTimestamps() {
|
public Map<String, Long> getTimestamps() {
|
||||||
if (_log.shouldLog(Log.INFO)) {
|
if (_log.shouldLog(Log.INFO)) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@ -107,6 +110,8 @@ public class OutNetMessage {
|
|||||||
}
|
}
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.EMPTY_MAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated unused */
|
||||||
public Long getTimestamp(String eventName) {
|
public Long getTimestamp(String eventName) {
|
||||||
if (_log.shouldLog(Log.INFO)) {
|
if (_log.shouldLog(Log.INFO)) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@ -368,7 +373,7 @@ public class OutNetMessage {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj == null) return false;
|
if(obj == null) return false;
|
||||||
if(obj.getClass() != OutNetMessage.class) return false;
|
if(!(obj instanceof OutNetMessage)) return false;
|
||||||
return obj == this; // two OutNetMessages are different even if they contain the same message
|
return obj == this; // two OutNetMessages are different even if they contain the same message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class RouterThrottleImpl implements RouterThrottle {
|
|||||||
if (_context.router().getUptime() < 20*60*1000)
|
if (_context.router().getUptime() < 20*60*1000)
|
||||||
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
|
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
|
||||||
|
|
||||||
long lag = _context.jobQueue().getMaxLag();
|
//long lag = _context.jobQueue().getMaxLag();
|
||||||
// reject here if lag too high???
|
// reject here if lag too high???
|
||||||
|
|
||||||
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");
|
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");
|
||||||
|
@ -157,9 +157,12 @@ public class StatisticsManager implements Service {
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****
|
||||||
private void includeRate(String rateName, Properties stats, long selectedPeriods[]) {
|
private void includeRate(String rateName, Properties stats, long selectedPeriods[]) {
|
||||||
includeRate(rateName, stats, selectedPeriods, false);
|
includeRate(rateName, stats, selectedPeriods, false);
|
||||||
}
|
}
|
||||||
|
*****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fudgeQuantity the data being published in this stat is too sensitive to, uh
|
* @param fudgeQuantity the data being published in this stat is too sensitive to, uh
|
||||||
* publish, so we're kludge the quantity (allowing the fairly safe
|
* publish, so we're kludge the quantity (allowing the fairly safe
|
||||||
@ -258,7 +261,6 @@ public class StatisticsManager implements Service {
|
|||||||
// bah saturation
|
// bah saturation
|
||||||
buf.append("0;0;0;0;");
|
buf.append("0;0;0;0;");
|
||||||
}
|
}
|
||||||
long numPeriods = rate.getLifetimePeriods();
|
|
||||||
buf.append(num(fudgeQuantity)).append(';');
|
buf.append(num(fudgeQuantity)).append(';');
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,9 @@ class ClientManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated unused */
|
||||||
public void renderStatusHTML(Writer out) throws IOException {
|
public void renderStatusHTML(Writer out) throws IOException {
|
||||||
|
/******
|
||||||
StringBuilder buf = new StringBuilder(8*1024);
|
StringBuilder buf = new StringBuilder(8*1024);
|
||||||
buf.append("<u><b>Local destinations</b></u><br>");
|
buf.append("<u><b>Local destinations</b></u><br>");
|
||||||
|
|
||||||
@ -479,6 +481,7 @@ class ClientManager {
|
|||||||
buf.append("\n<hr>\n");
|
buf.append("\n<hr>\n");
|
||||||
out.write(buf.toString());
|
out.write(buf.toString());
|
||||||
out.flush();
|
out.flush();
|
||||||
|
******/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void messageReceived(ClientMessage msg) {
|
public void messageReceived(ClientMessage msg) {
|
||||||
|
@ -207,6 +207,7 @@ public class ClientManagerFacadeImpl extends ClientManagerFacade implements Inte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated unused */
|
||||||
@Override
|
@Override
|
||||||
public void renderStatusHTML(Writer out) throws IOException {
|
public void renderStatusHTML(Writer out) throws IOException {
|
||||||
if (_manager != null)
|
if (_manager != null)
|
||||||
|
@ -142,12 +142,12 @@ class SSLClientListenerRunner extends ClientListenerRunner {
|
|||||||
private void exportCert(File ks) {
|
private void exportCert(File ks) {
|
||||||
File sdir = new SecureDirectory(_context.getConfigDir(), "certificates");
|
File sdir = new SecureDirectory(_context.getConfigDir(), "certificates");
|
||||||
if (sdir.exists() || sdir.mkdir()) {
|
if (sdir.exists() || sdir.mkdir()) {
|
||||||
|
InputStream fis = null;
|
||||||
try {
|
try {
|
||||||
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
InputStream fis = new FileInputStream(ks);
|
fis = new FileInputStream(ks);
|
||||||
String ksPass = _context.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD);
|
String ksPass = _context.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD);
|
||||||
keyStore.load(fis, ksPass.toCharArray());
|
keyStore.load(fis, ksPass.toCharArray());
|
||||||
fis.close();
|
|
||||||
Certificate cert = keyStore.getCertificate(KEY_ALIAS);
|
Certificate cert = keyStore.getCertificate(KEY_ALIAS);
|
||||||
if (cert != null) {
|
if (cert != null) {
|
||||||
File certFile = new File(sdir, ASCII_KEYFILE);
|
File certFile = new File(sdir, ASCII_KEYFILE);
|
||||||
@ -159,6 +159,8 @@ class SSLClientListenerRunner extends ClientListenerRunner {
|
|||||||
_log.error("Error saving ASCII SSL keys", gse);
|
_log.error("Error saving ASCII SSL keys", gse);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("Error saving ASCII SSL keys", ioe);
|
_log.error("Error saving ASCII SSL keys", ioe);
|
||||||
|
} finally {
|
||||||
|
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_log.error("Error saving ASCII SSL keys");
|
_log.error("Error saving ASCII SSL keys");
|
||||||
@ -208,12 +210,12 @@ class SSLClientListenerRunner extends ClientListenerRunner {
|
|||||||
" in " + (new File(_context.getConfigDir(), "router.config")).getAbsolutePath());
|
" in " + (new File(_context.getConfigDir(), "router.config")).getAbsolutePath());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
InputStream fis = null;
|
||||||
try {
|
try {
|
||||||
SSLContext sslc = SSLContext.getInstance("TLS");
|
SSLContext sslc = SSLContext.getInstance("TLS");
|
||||||
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
InputStream fis = new FileInputStream(ks);
|
fis = new FileInputStream(ks);
|
||||||
keyStore.load(fis, ksPass.toCharArray());
|
keyStore.load(fis, ksPass.toCharArray());
|
||||||
fis.close();
|
|
||||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||||
kmf.init(keyStore, keyPass.toCharArray());
|
kmf.init(keyStore, keyPass.toCharArray());
|
||||||
sslc.init(kmf.getKeyManagers(), null, _context.random());
|
sslc.init(kmf.getKeyManagers(), null, _context.random());
|
||||||
@ -223,6 +225,8 @@ class SSLClientListenerRunner extends ClientListenerRunner {
|
|||||||
_log.error("Error loading SSL keys", gse);
|
_log.error("Error loading SSL keys", gse);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("Error loading SSL keys", ioe);
|
_log.error("Error loading SSL keys", ioe);
|
||||||
|
} finally {
|
||||||
|
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user