forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 7903431c2a396fceb1e0428b2be3dde03ba24635)
to branch 'i2p.i2p.str4d.cleanup' (head cfbae7380c3fa106f578d5de399701cfb72d5747)
This commit is contained in:
@@ -215,10 +215,10 @@ public class Blocklist {
|
||||
int badcount = 0;
|
||||
int peercount = 0;
|
||||
long ipcount = 0;
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(BLFile);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(BLFile), "UTF-8"));
|
||||
String buf = null;
|
||||
while ((buf = br.readLine()) != null && count < maxSize) {
|
||||
Entry e = parse(buf, true);
|
||||
@@ -247,7 +247,7 @@ public class Blocklist {
|
||||
_log.log(Log.CRIT, "OOM reading the blocklist");
|
||||
return;
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
if (_wrapSave != null) {
|
||||
@@ -405,10 +405,10 @@ public class Blocklist {
|
||||
private int getSize(File BLFile) {
|
||||
if ( (!BLFile.exists()) || (BLFile.length() <= 0) ) return 0;
|
||||
int lines = 0;
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(BLFile);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(BLFile), "ISO-8859-1"));
|
||||
while (br.readLine() != null) {
|
||||
lines++;
|
||||
}
|
||||
@@ -417,7 +417,7 @@ public class Blocklist {
|
||||
_log.warn("Error reading the BLFile", ioe);
|
||||
return 0;
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@@ -770,10 +770,10 @@ public class Blocklist {
|
||||
for (Iterator<byte[]> iter = ips.iterator(); iter.hasNext(); ) {
|
||||
byte ip[] = iter.next();
|
||||
int ipint = toInt(ip);
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(BLFile);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(BLFile), "UTF-8"));
|
||||
String buf = null;
|
||||
// assume the file is unsorted, so go through the whole thing
|
||||
while ((buf = br.readLine()) != null) {
|
||||
@@ -782,7 +782,7 @@ public class Blocklist {
|
||||
continue;
|
||||
}
|
||||
if (match(ipint, toEntry(e.ip1, e.ip2))) {
|
||||
try { in.close(); } catch (IOException ioe) {}
|
||||
try { br.close(); } catch (IOException ioe) {}
|
||||
String reason = _x("IP banned by blocklist.txt entry {0}");
|
||||
// only one translate parameter for now
|
||||
//for (int i = 0; i < 4; i++) {
|
||||
@@ -801,7 +801,7 @@ public class Blocklist {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Error reading the BLFile", ioe);
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
// We already banlisted in banlist(peer), that's good enough
|
||||
|
@@ -8,7 +8,7 @@ package net.i2p.router;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
@@ -49,9 +49,9 @@ public class ClientTunnelSettings {
|
||||
writeToProperties(p);
|
||||
buf.append("Client tunnel settings:\n");
|
||||
buf.append("====================================\n");
|
||||
for (Iterator iter = p.keySet().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
String val = p.getProperty(name);
|
||||
for (Map.Entry<Object, Object> entry : p.entrySet()) {
|
||||
String name = (String) entry.getKey();
|
||||
String val = (String) entry.getValue();
|
||||
buf.append(name).append(" = [").append(val).append("]\n");
|
||||
}
|
||||
buf.append("====================================\n");
|
||||
|
@@ -277,7 +277,7 @@ public class JobQueue {
|
||||
if (_maxWaitingJobs <= 0) return false; // dont ever drop jobs
|
||||
if (!_allowParallelOperation) return false; // dont drop during startup [duh]
|
||||
if (numReady > _maxWaitingJobs) {
|
||||
Class cls = job.getClass();
|
||||
Class<? extends Job> cls = job.getClass();
|
||||
// lets not try to drop too many tunnel messages...
|
||||
//if (cls == HandleTunnelMessageJob.class)
|
||||
// return true;
|
||||
|
@@ -67,13 +67,16 @@ public class MultiRouter {
|
||||
Scanner scan = new Scanner(args[0]);
|
||||
if (!scan.hasNextInt()) {
|
||||
usage();
|
||||
scan.close();
|
||||
return;
|
||||
}
|
||||
nbrRouters = scan.nextInt();
|
||||
if (nbrRouters < 0) {
|
||||
usage();
|
||||
scan.close();
|
||||
return;
|
||||
}
|
||||
scan.close();
|
||||
|
||||
_out = System.out;
|
||||
|
||||
|
@@ -3,8 +3,6 @@ package net.i2p.router;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.Hash;
|
||||
@@ -43,8 +41,7 @@ public class PersistentKeyRing extends KeyRing {
|
||||
}
|
||||
|
||||
private void addFromProperties() {
|
||||
for (Iterator iter = _ctx.getPropertyNames().iterator(); iter.hasNext(); ) {
|
||||
String prop = (String) iter.next();
|
||||
for (String prop : _ctx.getPropertyNames()) {
|
||||
if (!prop.startsWith(PROP_PFX))
|
||||
continue;
|
||||
String key = _ctx.getProperty(prop);
|
||||
|
@@ -201,7 +201,7 @@ public class TunnelPoolSettings {
|
||||
* @param prefix non-null
|
||||
*/
|
||||
public void readFromProperties(String prefix, Map<Object, Object> props) {
|
||||
for (Map.Entry e : props.entrySet()) {
|
||||
for (Map.Entry<Object, Object> e : props.entrySet()) {
|
||||
String name = (String) e.getKey();
|
||||
String value = (String) e.getValue();
|
||||
if (name.startsWith(prefix)) {
|
||||
@@ -250,7 +250,7 @@ public class TunnelPoolSettings {
|
||||
props.setProperty(prefix + PROP_IP_RESTRICTION, ""+_IPRestriction);
|
||||
if (!_isInbound)
|
||||
props.setProperty(prefix + PROP_PRIORITY, Integer.toString(_priority));
|
||||
for (Map.Entry e : _unknownOptions.entrySet()) {
|
||||
for (Map.Entry<Object, Object> e : _unknownOptions.entrySet()) {
|
||||
String name = (String) e.getKey();
|
||||
String val = (String) e.getValue();
|
||||
props.setProperty(prefix + name, val);
|
||||
@@ -264,7 +264,7 @@ public class TunnelPoolSettings {
|
||||
writeToProperties("", p);
|
||||
buf.append("Tunnel pool settings:\n");
|
||||
buf.append("====================================\n");
|
||||
for (Map.Entry e : p.entrySet()) {
|
||||
for (Map.Entry<Object, Object> e : p.entrySet()) {
|
||||
String name = (String) e.getKey();
|
||||
String val = (String) e.getValue();
|
||||
buf.append(name).append(" = [").append(val).append("]\n");
|
||||
|
@@ -197,7 +197,7 @@ public class LoadClientAppsJob extends JobImpl {
|
||||
log.info("Loading up the client application " + clientName + ": " + className + " " + Arrays.toString(args));
|
||||
if (args == null)
|
||||
args = new String[0];
|
||||
Class cls = Class.forName(className, true, cl);
|
||||
Class<?> cls = Class.forName(className, true, cl);
|
||||
Method method = cls.getMethod("main", new Class[] { String[].class });
|
||||
method.invoke(cls, new Object[] { args });
|
||||
}
|
||||
@@ -264,15 +264,15 @@ public class LoadClientAppsJob extends JobImpl {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Class cls = Class.forName(_className, true, _cl);
|
||||
Class<?> cls = Class.forName(_className, true, _cl);
|
||||
if (isRouterApp(cls)) {
|
||||
Constructor con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
|
||||
Constructor<?> con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
|
||||
RouterAppManager mgr = _ctx.clientAppManager();
|
||||
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
|
||||
RouterApp app = (RouterApp) con.newInstance(conArgs);
|
||||
mgr.addAndStart(app, _args);
|
||||
} else if (isClientApp(cls)) {
|
||||
Constructor con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
|
||||
Constructor<?> con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
|
||||
RouterAppManager mgr = _ctx.clientAppManager();
|
||||
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
|
||||
ClientApp app = (ClientApp) con.newInstance(conArgs);
|
||||
@@ -288,17 +288,17 @@ public class LoadClientAppsJob extends JobImpl {
|
||||
_log.info("Done running client application " + _appName);
|
||||
}
|
||||
|
||||
private static boolean isRouterApp(Class cls) {
|
||||
private static boolean isRouterApp(Class<?> cls) {
|
||||
return isInterface(cls, RouterApp.class);
|
||||
}
|
||||
|
||||
private static boolean isClientApp(Class cls) {
|
||||
private static boolean isClientApp(Class<?> cls) {
|
||||
return isInterface(cls, ClientApp.class);
|
||||
}
|
||||
|
||||
private static boolean isInterface(Class cls, Class intfc) {
|
||||
private static boolean isInterface(Class<?> cls, Class<?> intfc) {
|
||||
try {
|
||||
Class[] intfcs = cls.getInterfaces();
|
||||
Class<?>[] intfcs = cls.getInterfaces();
|
||||
for (int i = 0; i < intfcs.length; i++) {
|
||||
if (intfcs[i] == intfc)
|
||||
return true;
|
||||
|
@@ -194,10 +194,10 @@ class GeoIP {
|
||||
_log.warn("Country file not found: " + geoFile.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(geoFile);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(geoFile), "UTF-8"));
|
||||
String line = null;
|
||||
while ( (line = br.readLine()) != null) {
|
||||
try {
|
||||
@@ -215,7 +215,7 @@ class GeoIP {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error reading the Country File", ioe);
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,11 +256,11 @@ class GeoIP {
|
||||
String[] rv = new String[search.length];
|
||||
int idx = 0;
|
||||
long start = _context.clock().now();
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(geoFile);
|
||||
String buf = null;
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(geoFile), "ISO-8859-1"));
|
||||
while ((buf = br.readLine()) != null && idx < search.length) {
|
||||
try {
|
||||
if (buf.charAt(0) == '#') {
|
||||
@@ -288,7 +288,7 @@ class GeoIP {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error reading the geoFile", ioe);
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
if (_log.shouldLog(Log.INFO)) {
|
||||
|
@@ -158,12 +158,13 @@ class GeoIPv6 {
|
||||
for (File geoFile : inFiles) {
|
||||
int count = 0;
|
||||
InputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new BufferedInputStream(new FileInputStream(geoFile));
|
||||
if (geoFile.getName().endsWith(".gz"))
|
||||
in = new GZIPInputStream(in);
|
||||
String buf = null;
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
while ((buf = br.readLine()) != null) {
|
||||
try {
|
||||
if (buf.charAt(0) == '#') {
|
||||
@@ -191,6 +192,7 @@ class GeoIPv6 {
|
||||
return false;
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
Collections.sort(entries);
|
||||
|
@@ -280,8 +280,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
*/
|
||||
private void discoverService() {
|
||||
synchronized (lock) {
|
||||
for (Iterator iter = _router.getDeviceList().iterator();iter.hasNext();) {
|
||||
Device current = (Device)iter.next();
|
||||
for (Device current : _router.getDeviceList()) {
|
||||
if (!current.getDeviceType().equals(WAN_DEVICE))
|
||||
continue;
|
||||
|
||||
|
@@ -69,7 +69,7 @@ class NTCPSendFinisher {
|
||||
public CustomThreadPoolExecutor(int num) {
|
||||
// use unbounded queue, so maximumPoolSize and keepAliveTime have no effect
|
||||
super(num, num, 1000, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue(), new CustomThreadFactory());
|
||||
new LinkedBlockingQueue<Runnable>(), new CustomThreadFactory());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public List<Hash> selectPeers(TunnelPoolSettings settings) {
|
||||
public List<Hash> selectPeers(TunnelPoolSettings settings) {
|
||||
Log l = ctx.logManager().getLog(getClass());
|
||||
int length = getLength(settings);
|
||||
if (length < 0) {
|
||||
@@ -34,7 +34,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
|
||||
}
|
||||
|
||||
if (false && shouldSelectExplicit(settings)) {
|
||||
List rv = selectExplicit(settings, length);
|
||||
List<Hash> rv = selectExplicit(settings, length);
|
||||
if (l.shouldLog(Log.DEBUG))
|
||||
l.debug("Explicit peers selected: " + rv);
|
||||
return rv;
|
||||
|
@@ -6,7 +6,7 @@ import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
@@ -123,7 +123,8 @@ public class TunnelPool {
|
||||
return; // don't override client specified settings
|
||||
} else {
|
||||
if (_settings.isExploratory()) {
|
||||
Map props = _context.router().getConfigMap();
|
||||
Properties props = new Properties();
|
||||
props.putAll(_context.router().getConfigMap());
|
||||
if (_settings.isInbound())
|
||||
_settings.readFromProperties(TunnelPoolSettings.PREFIX_INBOUND_EXPLORATORY, props);
|
||||
else
|
||||
|
@@ -3,7 +3,6 @@ package net.i2p.router.util;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -116,10 +115,10 @@ public class EventLog {
|
||||
}
|
||||
}
|
||||
rv = new TreeMap<Long, String>();
|
||||
InputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(_file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(_file), "UTF-8"));
|
||||
String line = null;
|
||||
while ( (line = br.readLine()) != null) {
|
||||
try {
|
||||
@@ -141,7 +140,7 @@ public class EventLog {
|
||||
_cacheTime.put(event, Long.valueOf(since));
|
||||
} catch (IOException ioe) {
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
Reference in New Issue
Block a user