Big findbugs cleanup
This commit is contained in:
@ -107,7 +107,11 @@ public class ConfigParser {
|
||||
FileInputStream fileStream = new FileInputStream(file);
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(
|
||||
fileStream));
|
||||
return ConfigParser.parse(input);
|
||||
Map rv = ConfigParser.parse(input);
|
||||
try {
|
||||
fileStream.close();
|
||||
} catch (IOException ioe) {}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +142,7 @@ public class ConfigParser {
|
||||
* cannot be read, map.
|
||||
*/
|
||||
public static Map parse(File file, Map map) {
|
||||
Map result = new HashMap();
|
||||
Map result;
|
||||
try {
|
||||
result = ConfigParser.parse(file);
|
||||
} catch (IOException exp) {
|
||||
@ -188,7 +192,11 @@ public class ConfigParser {
|
||||
FileInputStream fileStream = new FileInputStream(file);
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(
|
||||
fileStream));
|
||||
return ConfigParser.parseSubscriptions(input);
|
||||
List rv = ConfigParser.parseSubscriptions(input);
|
||||
try {
|
||||
fileStream.close();
|
||||
} catch (IOException ioe) {}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +226,7 @@ public class ConfigParser {
|
||||
* file cannot be read, list.
|
||||
*/
|
||||
public static List parseSubscriptions(File file, List list) {
|
||||
List result = new LinkedList();
|
||||
List result;
|
||||
try {
|
||||
result = ConfigParser.parseSubscriptions(file);
|
||||
} catch (IOException exp) {
|
||||
|
@ -125,7 +125,6 @@ public class Daemon {
|
||||
|
||||
public void run(String[] args) {
|
||||
String settingsLocation = "config.txt";
|
||||
Map settings = new HashMap();
|
||||
String home;
|
||||
if (args.length > 0) {
|
||||
home = args[0];
|
||||
@ -157,7 +156,7 @@ public class Daemon {
|
||||
|
||||
File settingsFile = new File(homeFile, settingsLocation);
|
||||
|
||||
settings = ConfigParser.parse(settingsFile, defaultSettings);
|
||||
Map settings = ConfigParser.parse(settingsFile, defaultSettings);
|
||||
// wait
|
||||
try {
|
||||
Thread.sleep(5*60*1000);
|
||||
|
@ -54,14 +54,17 @@ public class Log {
|
||||
* A String containing a message to append to the log.
|
||||
*/
|
||||
public void append(String entry) {
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(this.file,
|
||||
bw = new BufferedWriter(new FileWriter(this.file,
|
||||
true));
|
||||
String timestamp = new Date().toString();
|
||||
bw.write(timestamp + " -- " + entry);
|
||||
bw.newLine();
|
||||
bw.close();
|
||||
} catch (IOException exp) {
|
||||
} finally {
|
||||
if (bw != null)
|
||||
try { bw.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (UnknownHostException uhe) {
|
||||
l.log("unknown host");
|
||||
_log.error(getPrefix() + "Error resolving " + args[0], uhe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -363,19 +363,19 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
I2PTunnelServer serv = new I2PTunnelServer(serverHost, portNum, privKeyFile, args[2], l, (EventDispatcher) this, this);
|
||||
serv.setReadTimeout(readTimeout);
|
||||
serv.startRunning();
|
||||
addtask(serv);
|
||||
notifyEvent("serverTaskId", new Integer(serv.getId()));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(serv.getId()));
|
||||
return;
|
||||
} else {
|
||||
l.log("server <host> <port> <privkeyfile>");
|
||||
l.log(" creates a server that sends all incoming data\n" + " of its destination to host:port.");
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (UnknownHostException uhe) {
|
||||
l.log("unknown host");
|
||||
_log.error(getPrefix() + "Error resolving " + args[0], uhe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -420,21 +420,21 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[3]);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
I2PTunnelHTTPServer serv = new I2PTunnelHTTPServer(serverHost, portNum, privKeyFile, args[3], spoofedHost, l, (EventDispatcher) this, this);
|
||||
serv.setReadTimeout(readTimeout);
|
||||
serv.startRunning();
|
||||
addtask(serv);
|
||||
notifyEvent("serverTaskId", new Integer(serv.getId()));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(serv.getId()));
|
||||
return;
|
||||
} else {
|
||||
l.log("httpserver <host> <port> <spoofedhost> <privkeyfile>");
|
||||
l.log(" creates an HTTP server that sends all incoming data\n"
|
||||
+ " of its destination to host:port., filtering the HTTP\n"
|
||||
+ " headers so it looks like the request is to the spoofed host.");
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (UnknownHostException uhe) {
|
||||
l.log("unknown host");
|
||||
_log.error(getPrefix() + "Error resolving " + args[0], uhe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe);
|
||||
notifyEvent("serverTaskId", new Integer(-1));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -475,11 +475,11 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
serv.setReadTimeout(readTimeout);
|
||||
serv.startRunning();
|
||||
addtask(serv);
|
||||
notifyEvent("serverTaskId", new Integer(serv.getId()));
|
||||
notifyEvent("serverTaskId", Integer.valueOf(serv.getId()));
|
||||
} else {
|
||||
l.log("textserver <host> <port> <privkey>");
|
||||
l.log(" creates a server that sends all incoming data\n" + " of its destination to host:port.");
|
||||
notifyEvent("textserverTaskId", new Integer(-1));
|
||||
notifyEvent("textserverTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||
notifyEvent("clientTaskId", new Integer(-1));
|
||||
notifyEvent("clientTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
I2PTunnelTask task;
|
||||
@ -515,11 +515,11 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
try {
|
||||
task = new I2PTunnelClient(portNum, args[1], l, ownDest, (EventDispatcher) this, this);
|
||||
addtask(task);
|
||||
notifyEvent("clientTaskId", new Integer(task.getId()));
|
||||
notifyEvent("clientTaskId", Integer.valueOf(task.getId()));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
_log.error(getPrefix() + "Invalid I2PTunnel config to create a client [" + host + ":"+ port + "]", iae);
|
||||
l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]");
|
||||
notifyEvent("clientTaskId", new Integer(-1));
|
||||
notifyEvent("clientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
} else {
|
||||
l.log("client <port> <pubkey>[,<pubkey>]|file:<pubkeyfile>[ <sharedClient>]");
|
||||
@ -528,7 +528,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
+ " a comma delimited list of pubkeys, it will rotate among them\n"
|
||||
+ " randomlyl. sharedClient indicates if this client shares \n"
|
||||
+ " with other clients (true of false)");
|
||||
notifyEvent("clientTaskId", new Integer(-1));
|
||||
notifyEvent("clientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||
notifyEvent("httpclientTaskId", new Integer(-1));
|
||||
notifyEvent("httpclientTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -582,11 +582,11 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
try {
|
||||
task = new I2PTunnelHTTPClient(port, l, ownDest, proxy, (EventDispatcher) this, this);
|
||||
addtask(task);
|
||||
notifyEvent("httpclientTaskId", new Integer(task.getId()));
|
||||
notifyEvent("httpclientTaskId", Integer.valueOf(task.getId()));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
_log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ port + "]", iae);
|
||||
l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]");
|
||||
notifyEvent("httpclientTaskId", new Integer(-1));
|
||||
notifyEvent("httpclientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
} else {
|
||||
l.log("httpclient <port> [<sharedClient>] [<proxy>]");
|
||||
@ -595,7 +595,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
l.log(" <proxy> (optional) indicates a proxy server to be used");
|
||||
l.log(" when trying to access an address out of the .i2p domain");
|
||||
l.log(" (the default proxy is squid.i2p).");
|
||||
notifyEvent("httpclientTaskId", new Integer(-1));
|
||||
notifyEvent("httpclientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||
notifyEvent("ircclientTaskId", new Integer(-1));
|
||||
notifyEvent("ircclientTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -639,17 +639,17 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
try {
|
||||
task = new I2PTunnelIRCClient(port, args[1],l, ownDest, (EventDispatcher) this, this);
|
||||
addtask(task);
|
||||
notifyEvent("ircclientTaskId", new Integer(task.getId()));
|
||||
notifyEvent("ircclientTaskId", Integer.valueOf(task.getId()));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
_log.error(getPrefix() + "Invalid I2PTunnel config to create an ircclient [" + host + ":"+ port + "]", iae);
|
||||
l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]");
|
||||
notifyEvent("ircclientTaskId", new Integer(-1));
|
||||
notifyEvent("ircclientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
} else {
|
||||
l.log("ircclient <port> [<sharedClient>]");
|
||||
l.log(" creates a client that filter IRC protocol.");
|
||||
l.log(" <sharedClient> (optional) indicates if this client shares tunnels with other clients (true of false)");
|
||||
notifyEvent("ircclientTaskId", new Integer(-1));
|
||||
notifyEvent("ircclientTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -672,18 +672,18 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
} catch (NumberFormatException nfe) {
|
||||
l.log("invalid port");
|
||||
_log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe);
|
||||
notifyEvent("sockstunnelTaskId", new Integer(-1));
|
||||
notifyEvent("sockstunnelTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
I2PTunnelTask task;
|
||||
task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this);
|
||||
addtask(task);
|
||||
notifyEvent("sockstunnelTaskId", new Integer(task.getId()));
|
||||
notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
|
||||
} else {
|
||||
l.log("sockstunnel <port>");
|
||||
l.log(" creates a tunnel that distributes SOCKS requests.");
|
||||
notifyEvent("sockstunnelTaskId", new Integer(-1));
|
||||
notifyEvent("sockstunnelTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -967,7 +967,6 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
l.log(" try to resolve the name into a destination key");
|
||||
notifyEvent("lookupResult", "invalidUsage");
|
||||
} else {
|
||||
String target = args[0];
|
||||
try {
|
||||
Destination dest = destFromName(args[0]);
|
||||
if (dest == null) {
|
||||
@ -998,13 +997,13 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
// pings always use the main destination
|
||||
task = new I2Ping(allargs, l, false, (EventDispatcher) this, this);
|
||||
addtask(task);
|
||||
notifyEvent("pingTaskId", new Integer(task.getId()));
|
||||
notifyEvent("pingTaskId", Integer.valueOf(task.getId()));
|
||||
} else {
|
||||
l.log("ping <opts> <dest>");
|
||||
l.log("ping <opts> -h");
|
||||
l.log("ping <opts> -l <destlistfile>");
|
||||
l.log(" Tests communication with peers.\n" + " opts can be -ns (nosync) or not.");
|
||||
notifyEvent("pingTaskId", new Integer(-1));
|
||||
notifyEvent("pingTaskId", Integer.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1083,7 +1082,6 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
public static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l) {
|
||||
try {
|
||||
l.log("Generating new keys...");
|
||||
ByteArrayOutputStream priv = new ByteArrayOutputStream(), pub = new ByteArrayOutputStream();
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
Destination d = client.createDestination(writeTo);
|
||||
l.log("Secret key saved.");
|
||||
@ -1107,7 +1105,6 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
*/
|
||||
public static void showKey(InputStream readFrom, OutputStream pubDest, Logging l) {
|
||||
try {
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
Destination d = new Destination();
|
||||
d.readBytes(readFrom);
|
||||
l.log("Public key: " + d.toBase64());
|
||||
|
@ -217,9 +217,6 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
}
|
||||
protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel) {
|
||||
Properties props = new Properties();
|
||||
if (tunnel == null)
|
||||
props.putAll(System.getProperties());
|
||||
else
|
||||
props.putAll(tunnel.getClientOptions());
|
||||
int portNum = 7654;
|
||||
if (tunnel.port != null) {
|
||||
|
@ -216,9 +216,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL
|
||||
private void removeRef() {
|
||||
if (sockList != null) {
|
||||
synchronized (slock) {
|
||||
boolean removed = sockList.remove(i2ps);
|
||||
//System.out.println("Removal of i2psocket " + i2ps + " successful? "
|
||||
// + removed + " remaining: " + sockList.size());
|
||||
sockList.remove(i2ps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,11 +70,16 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
_usePool = "true".equalsIgnoreCase(usePool);
|
||||
else
|
||||
_usePool = DEFAULT_USE_POOL;
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
init(host, port, new FileInputStream(privkey), privkeyname, l);
|
||||
fis = new FileInputStream(privkey);
|
||||
init(host, port, fis, privkeyname, l);
|
||||
} catch (IOException ioe) {
|
||||
_log.error("Error starting server", ioe);
|
||||
notifyEvent("openServerResult", "error");
|
||||
} finally {
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +97,6 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
this.l = l;
|
||||
this.remoteHost = host;
|
||||
this.remotePort = port;
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
Properties props = new Properties();
|
||||
props.putAll(getTunnel().getClientOptions());
|
||||
int portNum = 7654;
|
||||
|
@ -384,7 +384,7 @@ class I2PSocketImpl implements I2PSocket {
|
||||
}
|
||||
}
|
||||
if (read.length > len) throw new RuntimeException("BUG");
|
||||
if ( (inStreamClosed) && ( (read == null) || (read.length <= 0) ) )
|
||||
if ( (inStreamClosed) && (read.length <= 0) )
|
||||
return -1;
|
||||
|
||||
System.arraycopy(read, 0, b, off, read.length);
|
||||
|
@ -75,7 +75,7 @@ public class I2PSocketManagerFactory {
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512);
|
||||
try {
|
||||
Destination dest = client.createDestination(keyStream);
|
||||
client.createDestination(keyStream);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(keyStream.toByteArray());
|
||||
return createManager(in, i2cpHost, i2cpPort, opts);
|
||||
} catch (IOException ioe) {
|
||||
|
@ -71,7 +71,7 @@ public class StreamSinkClient {
|
||||
_log.error("Peer destination is not valid in " + _peerDestFile, dfe);
|
||||
return;
|
||||
} finally {
|
||||
if (fis == null) try { fis.close(); } catch (IOException ioe) {}
|
||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -226,7 +226,6 @@ public class ReseedHandler {
|
||||
|
||||
/* Since we don't return a value, we should always throw an exception if something fails. */
|
||||
private void fetchSeed(String seedURL, String peer) throws Exception {
|
||||
Log log = I2PAppContext.getGlobalContext().logManager().getLog(ReseedHandler.class);
|
||||
URL url = new URL(seedURL + (seedURL.endsWith("/") ? "" : "/") + "routerInfo-" + peer + ".dat");
|
||||
|
||||
byte data[] = readURL(url);
|
||||
|
@ -156,7 +156,6 @@ class SummaryRenderer {
|
||||
public static synchronized void render(I2PAppContext ctx, OutputStream out, String filename) throws IOException {
|
||||
long end = ctx.clock().now() - 60*1000;
|
||||
long start = end - 60*1000*SummaryListener.PERIODS;
|
||||
long begin = System.currentTimeMillis();
|
||||
try {
|
||||
RrdGraphDefTemplate template = new RrdGraphDefTemplate(filename);
|
||||
RrdGraphDef def = template.getRrdGraphDef();
|
||||
|
@ -261,10 +261,7 @@ public class ConnectionPacketHandler {
|
||||
_context.statManager().addRateData("stream.con.packetsAckedPerMessageReceived", acked.size(), highestRTT);
|
||||
}
|
||||
|
||||
if (packet != null)
|
||||
return adjustWindow(con, isNew, packet.getSequenceNum(), numResends, (acked != null ? acked.size() : 0), choke);
|
||||
else
|
||||
return adjustWindow(con, false, -1, numResends, (acked != null ? acked.size() : 0), choke);
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,7 +177,6 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
|
||||
if (_connection == null)
|
||||
throw new IllegalStateException("Cannot wait for accept with no connection");
|
||||
long before = _context.clock().now();
|
||||
long expiration = before+maxWaitMs;
|
||||
int queued = _connection.getUnackedPacketsSent();
|
||||
int window = _connection.getOptions().getWindowSize();
|
||||
boolean accepted = _connection.packetSendChoke(maxWaitMs);
|
||||
|
@ -34,9 +34,10 @@ class SchedulerClosing extends SchedulerImpl {
|
||||
}
|
||||
|
||||
public boolean accept(Connection con) {
|
||||
if (con == null)
|
||||
return false;
|
||||
long timeSinceClose = _context.clock().now() - con.getCloseSentOn();
|
||||
boolean ok = (con != null) &&
|
||||
(!con.getResetSent()) &&
|
||||
boolean ok = (!con.getResetSent()) &&
|
||||
(!con.getResetReceived()) &&
|
||||
( (con.getCloseSentOn() > 0) || (con.getCloseReceivedOn() > 0) ) &&
|
||||
(timeSinceClose < Connection.DISCONNECT_TIMEOUT) &&
|
||||
|
@ -85,9 +85,11 @@ public class AddressbookBean
|
||||
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
|
||||
return;
|
||||
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
properties.clear();
|
||||
properties.load( new FileInputStream( ConfigBean.configFileName ) );
|
||||
fis = new FileInputStream( ConfigBean.configFileName );
|
||||
properties.load( fis );
|
||||
// added in 0.5, for compatibility with 0.4 config.txt
|
||||
if( properties.getProperty(PRIVATE_BOOK) == null)
|
||||
properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK);
|
||||
@ -95,6 +97,9 @@ public class AddressbookBean
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
|
||||
} finally {
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
public String getFileName()
|
||||
@ -143,9 +148,10 @@ public class AddressbookBean
|
||||
addressbook = new Properties();
|
||||
|
||||
String message = "";
|
||||
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
addressbook.load( new FileInputStream( getFileName() ) );
|
||||
fis = new FileInputStream( getFileName() );
|
||||
addressbook.load( fis );
|
||||
LinkedList list = new LinkedList();
|
||||
Enumeration e = addressbook.keys();
|
||||
while( e.hasMoreElements() ) {
|
||||
@ -182,8 +188,10 @@ public class AddressbookBean
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
|
||||
} finally {
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
if( message.length() > 0 )
|
||||
message = "<p>" + message + "</p>";
|
||||
return message;
|
||||
@ -243,7 +251,11 @@ public class AddressbookBean
|
||||
{
|
||||
String filename = properties.getProperty( getBook() + "_addressbook" );
|
||||
|
||||
addressbook.store( new FileOutputStream( ConfigBean.addressbookPrefix + filename ), null );
|
||||
FileOutputStream fos = new FileOutputStream( ConfigBean.addressbookPrefix + filename );
|
||||
addressbook.store( fos, null );
|
||||
try {
|
||||
fos.close();
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
|
@ -38,8 +38,8 @@ public class ConfigBean implements Serializable {
|
||||
/*
|
||||
* as this is not provided as constant in addressbook, we define it here
|
||||
*/
|
||||
public static String addressbookPrefix = "addressbook/";
|
||||
public static String configFileName = addressbookPrefix + "config.txt";
|
||||
public static final String addressbookPrefix = "addressbook/";
|
||||
public static final String configFileName = addressbookPrefix + "config.txt";
|
||||
|
||||
private String action, config;
|
||||
private String serial, lastSerial;
|
||||
@ -80,8 +80,9 @@ public class ConfigBean implements Serializable {
|
||||
File file = new File( configFileName );
|
||||
if( file != null && file.isFile() ) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
BufferedReader br = new BufferedReader( new FileReader( file ) );
|
||||
br = new BufferedReader( new FileReader( file ) );
|
||||
String line;
|
||||
while( ( line = br.readLine() ) != null ) {
|
||||
buf.append( line );
|
||||
@ -95,6 +96,9 @@ public class ConfigBean implements Serializable {
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null)
|
||||
try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ import java.util.Properties;
|
||||
public class SubscriptionsBean
|
||||
{
|
||||
private String action, fileName, content, serial, lastSerial;
|
||||
private boolean saved;
|
||||
|
||||
Properties properties;
|
||||
|
||||
@ -53,13 +52,18 @@ public class SubscriptionsBean
|
||||
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
|
||||
return;
|
||||
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
properties.clear();
|
||||
properties.load( new FileInputStream( ConfigBean.configFileName ) );
|
||||
fis = new FileInputStream( ConfigBean.configFileName );
|
||||
properties.load( fis );
|
||||
configLastLoaded = currentTime;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
|
||||
} finally {
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
public String getAction() {
|
||||
@ -83,21 +87,24 @@ public class SubscriptionsBean
|
||||
File file = new File( getFileName() );
|
||||
if( file != null && file.isFile() ) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
BufferedReader br = new BufferedReader( new FileReader( file ) );
|
||||
br = new BufferedReader( new FileReader( file ) );
|
||||
String line;
|
||||
while( ( line = br.readLine() ) != null ) {
|
||||
buf.append( line );
|
||||
buf.append( "\n" );
|
||||
}
|
||||
content = buf.toString();
|
||||
saved = true;
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null)
|
||||
try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +117,6 @@ public class SubscriptionsBean
|
||||
out.print( content );
|
||||
out.flush();
|
||||
out.close();
|
||||
saved = true;
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@ -148,7 +154,6 @@ public class SubscriptionsBean
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
this.saved = false;
|
||||
|
||||
/*
|
||||
* as this is a property file we need a newline at the end of the last line!
|
||||
|
@ -26,6 +26,7 @@ package i2p.susi.util;
|
||||
import i2p.susi.debug.Debug;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@ -78,10 +79,15 @@ public class Config {
|
||||
} catch (Exception e) {
|
||||
Debug.debug( Debug.DEBUG, "Could not open WEB-INF/classes/susimail.properties (possibly in jar), reason: " + e.getMessage() );
|
||||
}
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
config.load( new FileInputStream( "susimail.config" ) );
|
||||
fis = new FileInputStream( "susimail.config" );
|
||||
config.load( fis );
|
||||
} catch (Exception e) {
|
||||
Debug.debug( Debug.DEBUG, "Could not open susimail.config, reason: " + e.getMessage() );
|
||||
} finally {
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -36,7 +36,6 @@ public class MailCache {
|
||||
public static final boolean FETCH_ALL = false;
|
||||
|
||||
private POP3MailBox mailbox;
|
||||
private String error;
|
||||
private Hashtable mails;
|
||||
private Object synchronizer;
|
||||
|
||||
|
@ -76,6 +76,8 @@ public class MailPart {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (decodedHeaders == null)
|
||||
return;
|
||||
headerLines = new String( decodedHeaders.content, decodedHeaders.offset, decodedHeaders.length ).split( "\r\n" );
|
||||
|
||||
for( int i = 0; i < headerLines.length; i++ )
|
||||
|
@ -97,7 +97,7 @@ public class RequestWrapper {
|
||||
cachedParameterNames = new Hashtable();
|
||||
String[] partNames = multiPartRequest.getPartNames();
|
||||
for( int i = 0; i < partNames.length; i++ )
|
||||
cachedParameterNames.put( partNames[i], new Integer( i ) );
|
||||
cachedParameterNames.put( partNames[i], Integer.valueOf( i ) );
|
||||
}
|
||||
return cachedParameterNames.keys();
|
||||
}
|
||||
|
@ -556,7 +556,6 @@ public class WebMail extends HttpServlet
|
||||
private void processLogin( SessionObject sessionObject, RequestWrapper request )
|
||||
{
|
||||
if( sessionObject.state == STATE_AUTH ) {
|
||||
String login = request.getParameter( LOGIN );
|
||||
String user = request.getParameter( USER );
|
||||
String pass = request.getParameter( PASS );
|
||||
String host = request.getParameter( HOST );
|
||||
@ -1330,8 +1329,9 @@ public class WebMail extends HttpServlet
|
||||
}
|
||||
}
|
||||
if( content != null ) {
|
||||
ZipOutputStream zip = null;
|
||||
try {
|
||||
ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() );
|
||||
zip = new ZipOutputStream( response.getOutputStream() );
|
||||
String name;
|
||||
if( part.filename != null )
|
||||
name = part.filename;
|
||||
@ -1350,6 +1350,9 @@ public class WebMail extends HttpServlet
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( zip != null)
|
||||
try { zip.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class EncodingFactory {
|
||||
|
||||
public static String CONFIG_ENCODING = "encodings";
|
||||
public static final String CONFIG_ENCODING = "encodings";
|
||||
|
||||
private static Hashtable encodings = null;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class POP3MailBox {
|
||||
private ReadBuffer getHeader( int id ) {
|
||||
synchronized( synchronizer ) {
|
||||
Debug.debug(Debug.DEBUG, "getHeader(" + id + ")");
|
||||
Integer idObj = new Integer(id);
|
||||
Integer idObj = Integer.valueOf(id);
|
||||
ReadBuffer header = null;
|
||||
if (id >= 1 && id <= mails) {
|
||||
/*
|
||||
@ -155,7 +155,7 @@ public class POP3MailBox {
|
||||
private ReadBuffer getBody(int id) {
|
||||
synchronized( synchronizer ) {
|
||||
Debug.debug(Debug.DEBUG, "getBody(" + id + ")");
|
||||
Integer idObj = new Integer(id);
|
||||
Integer idObj = Integer.valueOf(id);
|
||||
ReadBuffer body = null;
|
||||
if (id >= 1 && id <= mails) {
|
||||
body = (ReadBuffer)bodyList.get(idObj);
|
||||
@ -236,7 +236,7 @@ public class POP3MailBox {
|
||||
/*
|
||||
* find value in hashtable
|
||||
*/
|
||||
Integer resultObj = (Integer) sizes.get(new Integer(id));
|
||||
Integer resultObj = (Integer) sizes.get(Integer.valueOf(id));
|
||||
if (resultObj != null)
|
||||
result = resultObj.intValue();
|
||||
return result;
|
||||
@ -277,7 +277,7 @@ public class POP3MailBox {
|
||||
|
||||
readBuffer = sendCmdNa( "UIDL", DEFAULT_BUFSIZE );
|
||||
if( readBuffer != null ) {
|
||||
String[] lines = new String( readBuffer.toString() ).split( "\r\n" );
|
||||
String[] lines = readBuffer.toString().split( "\r\n" );
|
||||
|
||||
for( int i = 0; i < lines.length; i++ ) {
|
||||
int j = lines[i].indexOf( " " );
|
||||
@ -285,7 +285,7 @@ public class POP3MailBox {
|
||||
try {
|
||||
int n = Integer.parseInt( lines[i].substring( 0, j ) );
|
||||
String uidl = lines[i].substring( j+1 );
|
||||
uidlToID.put( uidl, new Integer( n ) );
|
||||
uidlToID.put( uidl, Integer.valueOf( n ) );
|
||||
uidlList.add( n-1, uidl );
|
||||
}
|
||||
catch( NumberFormatException nfe ) {
|
||||
@ -319,7 +319,7 @@ public class POP3MailBox {
|
||||
if (j != -1) {
|
||||
int key = Integer.parseInt(lines[i].substring(0, j));
|
||||
int value = Integer.parseInt(lines[i].substring(j + 1));
|
||||
sizes.put(new Integer(key), new Integer(value));
|
||||
sizes.put(Integer.valueOf(key), Integer.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +389,7 @@ public class POP3MailBox {
|
||||
updateSizes();
|
||||
}
|
||||
else {
|
||||
lastError = new String( lastLine );
|
||||
lastError = lastLine;
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@ -54,36 +54,36 @@ public class ConfigFile {
|
||||
private boolean readConfigFile() {
|
||||
|
||||
FileInputStream fileInputStream = null;
|
||||
|
||||
boolean rv = true;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(_configFile);
|
||||
_properties.load(fileInputStream);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
rv = false;
|
||||
}
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e) {
|
||||
// No worries.
|
||||
}
|
||||
return true;
|
||||
return rv;
|
||||
}
|
||||
|
||||
private boolean writeConfigFile() {
|
||||
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
boolean rv = true;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(_configFile);
|
||||
_properties.store(fileOutputStream, null);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
rv = false;
|
||||
}
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
// No worries.
|
||||
}
|
||||
return true;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -85,8 +85,10 @@ public class UrlLauncher {
|
||||
new File("browser.reg").delete();
|
||||
} catch (Exception e) {
|
||||
// Defaults to IE.
|
||||
} finally {
|
||||
if (bufferedReader != null)
|
||||
try { bufferedReader.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
if (_shellCommand.executeSilentAndWaitTimed(browserString + " " + url, 5))
|
||||
return true;
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class CPUID {
|
||||
public boolean IsC3Compatible() { return false; }
|
||||
}
|
||||
protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo {
|
||||
public boolean isC3Compatible() { return true; }
|
||||
public boolean IsC3Compatible() { return true; }
|
||||
public String getCPUModelString() { return "VIA C3"; }
|
||||
}
|
||||
protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
|
||||
|
@ -150,10 +150,10 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
|
||||
lastReseed = System.currentTimeMillis();
|
||||
}
|
||||
generator.nextBytes(buf);
|
||||
long now = System.currentTimeMillis();
|
||||
long diff = now-lastRefill;
|
||||
lastRefill = now;
|
||||
long refillTime = now-start;
|
||||
//long now = System.currentTimeMillis();
|
||||
//long diff = now-lastRefill;
|
||||
//lastRefill = now;
|
||||
//long refillTime = now-start;
|
||||
//System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime);
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,8 @@ class I2PClientImpl implements I2PClient {
|
||||
public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException {
|
||||
Destination d = new Destination();
|
||||
d.setCertificate(cert);
|
||||
PublicKey publicKey = new PublicKey();
|
||||
Object keypair[] = KeyGenerator.getInstance().generatePKIKeypair();
|
||||
publicKey = (PublicKey) keypair[0];
|
||||
PublicKey publicKey = (PublicKey) keypair[0];
|
||||
PrivateKey privateKey = (PrivateKey) keypair[1];
|
||||
Object signingKeys[] = KeyGenerator.getInstance().generateSigningKeypair();
|
||||
SigningPublicKey signingPubKey = (SigningPublicKey) signingKeys[0];
|
||||
|
@ -408,7 +408,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
public void available(long msgId, int size) {
|
||||
synchronized (AvailabilityNotifier.this) {
|
||||
_pendingIds.add(new Long(msgId));
|
||||
_pendingSizes.add(new Integer(size));
|
||||
_pendingSizes.add(Integer.valueOf(size));
|
||||
AvailabilityNotifier.this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
if (actuallyWait)
|
||||
state.waitFor(MessageStatusMessage.STATUS_SEND_ACCEPTED,
|
||||
_context.clock().now() + getTimeout());
|
||||
long afterWaitFor = _context.clock().now();
|
||||
long inRemovingSync = 0;
|
||||
//long afterWaitFor = _context.clock().now();
|
||||
//long inRemovingSync = 0;
|
||||
synchronized (_sendingStates) {
|
||||
inRemovingSync = _context.clock().now();
|
||||
//inRemovingSync = _context.clock().now();
|
||||
_sendingStates.remove(state);
|
||||
}
|
||||
long afterRemovingSync = _context.clock().now();
|
||||
|
@ -35,7 +35,7 @@ class MessagePayloadMessageHandler extends HandlerImpl {
|
||||
try {
|
||||
MessagePayloadMessage msg = (MessagePayloadMessage) message;
|
||||
long id = msg.getMessageId();
|
||||
Payload payload = decryptPayload(msg, session);
|
||||
decryptPayload(msg, session);
|
||||
session.addNewMessage(msg);
|
||||
|
||||
ReceiveMessageEndMessage m = new ReceiveMessageEndMessage();
|
||||
|
@ -50,7 +50,7 @@ class MessageState {
|
||||
|
||||
public void receive(int status) {
|
||||
synchronized (_receivedStatus) {
|
||||
_receivedStatus.add(new Integer(status));
|
||||
_receivedStatus.add(Integer.valueOf(status));
|
||||
_receivedStatus.notifyAll();
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ public class ElGamalAESEngine {
|
||||
System.arraycopy(elgEncr, 0, rv, 0, elgEncr.length);
|
||||
System.arraycopy(aesEncr, 0, rv, elgEncr.length, aesEncr.length);
|
||||
//_log.debug("Return length: " + rv.length);
|
||||
long finish = _context.clock().now();
|
||||
//long finish = _context.clock().now();
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("after the elgEngine.encrypt took a total of " + (finish - after) + "ms");
|
||||
return rv;
|
||||
|
@ -102,25 +102,25 @@ public class ElGamalEngine {
|
||||
System.arraycopy(hash.getData(), 0, d2, 1, Hash.HASH_LENGTH);
|
||||
System.arraycopy(data, 0, d2, 1+Hash.HASH_LENGTH, data.length);
|
||||
|
||||
long t0 = _context.clock().now();
|
||||
//long t0 = _context.clock().now();
|
||||
BigInteger m = new NativeBigInteger(1, d2);
|
||||
long t1 = _context.clock().now();
|
||||
//long t1 = _context.clock().now();
|
||||
if (m.compareTo(CryptoConstants.elgp) >= 0)
|
||||
throw new IllegalArgumentException("ARGH. Data cannot be larger than the ElGamal prime. FIXME");
|
||||
long t2 = _context.clock().now();
|
||||
//long t2 = _context.clock().now();
|
||||
BigInteger aalpha = new NativeBigInteger(1, publicKey.getData());
|
||||
long t3 = _context.clock().now();
|
||||
//long t3 = _context.clock().now();
|
||||
BigInteger yk[] = getNextYK();
|
||||
BigInteger k = yk[1];
|
||||
BigInteger y = yk[0];
|
||||
|
||||
long t7 = _context.clock().now();
|
||||
//long t7 = _context.clock().now();
|
||||
BigInteger d = aalpha.modPow(k, CryptoConstants.elgp);
|
||||
long t8 = _context.clock().now();
|
||||
//long t8 = _context.clock().now();
|
||||
d = d.multiply(m);
|
||||
long t9 = _context.clock().now();
|
||||
//long t9 = _context.clock().now();
|
||||
d = d.mod(CryptoConstants.elgp);
|
||||
long t10 = _context.clock().now();
|
||||
//long t10 = _context.clock().now();
|
||||
|
||||
byte[] ybytes = y.toByteArray();
|
||||
byte[] dbytes = d.toByteArray();
|
||||
|
@ -47,13 +47,13 @@ public class Base64 {
|
||||
return (source != null ? encode(source.getBytes()) : "");
|
||||
}
|
||||
public static String encode(byte[] source) {
|
||||
return (source != null ? encode(source, 0, (source != null ? source.length : 0)) : "");
|
||||
return (source != null ? encode(source, 0, source.length) : "");
|
||||
}
|
||||
public static String encode(byte[] source, int off, int len) {
|
||||
return (source != null ? encode(source, off, len, false) : "");
|
||||
}
|
||||
public static String encode(byte[] source, boolean useStandardAlphabet) {
|
||||
return (source != null ? encode(source, 0, (source != null ? source.length : 0), useStandardAlphabet) : "");
|
||||
return (source != null ? encode(source, 0, source.length, useStandardAlphabet) : "");
|
||||
}
|
||||
public static String encode(byte[] source, int off, int len, boolean useStandardAlphabet) {
|
||||
return (source != null ? safeEncode(source, off, len, useStandardAlphabet) : "");
|
||||
@ -241,9 +241,11 @@ public class Base64 {
|
||||
* @return four byte array in Base64 notation.
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static byte[] encode3to4(byte[] threeBytes) {
|
||||
return encode3to4(threeBytes, 3);
|
||||
} // end encodeToBytes
|
||||
******/
|
||||
|
||||
/**
|
||||
* Encodes up to the first three bytes of array <var>threeBytes</var>
|
||||
@ -379,9 +381,11 @@ public class Base64 {
|
||||
* @param source The data to convert
|
||||
* @since 1.4
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeBytes(byte[] source) {
|
||||
return encodeBytes(source, false); // don't add newlines
|
||||
} // end encodeBytes
|
||||
******/
|
||||
|
||||
/**
|
||||
* Same as encodeBytes, except uses a filesystem / URL friendly set of characters,
|
||||
@ -435,9 +439,11 @@ public class Base64 {
|
||||
* @param len Length of data to convert
|
||||
* @since 1.4
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeBytes(byte[] source, int off, int len) {
|
||||
return encodeBytes(source, off, len, true);
|
||||
} // end encodeBytes
|
||||
******/
|
||||
|
||||
private static String encodeBytes(byte[] source, int off, int len, boolean breakLines) {
|
||||
StringBuffer buf = new StringBuffer( (len*4)/3 );
|
||||
@ -455,7 +461,7 @@ public class Base64 {
|
||||
* @since 1.4
|
||||
*/
|
||||
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuffer out, byte alpha[]) {
|
||||
int len43 = len * 4 / 3;
|
||||
//int len43 = len * 4 / 3;
|
||||
//byte[] outBuff = new byte[(len43) // Main 4:3
|
||||
// + ((len % 3) > 0 ? 4 : 0) // Account for padding
|
||||
// + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines
|
||||
@ -494,9 +500,11 @@ public class Base64 {
|
||||
* @return the encoded string
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeString(String s) {
|
||||
return encodeString(s, true);
|
||||
} // end encodeString
|
||||
******/
|
||||
|
||||
/**
|
||||
* Encodes a string in Base64 notation with line breaks
|
||||
@ -525,6 +533,7 @@ public class Base64 {
|
||||
* @return array with decoded values
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static byte[] decode4to3(byte[] fourBytes) {
|
||||
byte[] outBuff1 = new byte[3];
|
||||
int count = decode4to3(fourBytes, 0, outBuff1, 0);
|
||||
@ -535,6 +544,7 @@ public class Base64 {
|
||||
|
||||
return outBuff2;
|
||||
}
|
||||
******/
|
||||
|
||||
/**
|
||||
* Decodes four bytes from array <var>source</var>
|
||||
|
@ -671,8 +671,6 @@ public class DataHelper {
|
||||
|
||||
public final static byte[] xor(byte lhs[], byte rhs[]) {
|
||||
if ((lhs == null) || (rhs == null) || (lhs.length != rhs.length)) return null;
|
||||
byte rv[] = new byte[lhs.length];
|
||||
|
||||
byte diff[] = new byte[lhs.length];
|
||||
xor(lhs, 0, rhs, 0, diff, 0, lhs.length);
|
||||
return diff;
|
||||
@ -821,9 +819,8 @@ public class DataHelper {
|
||||
DataStructure struct = (DataStructure) iter.next();
|
||||
tm.put(struct.calculateHash().toString(), struct);
|
||||
}
|
||||
for (Iterator iter = tm.keySet().iterator(); iter.hasNext();) {
|
||||
Object k = iter.next();
|
||||
rv.add(tm.get(k));
|
||||
for (Iterator iter = tm.values().iterator(); iter.hasNext();) {
|
||||
rv.add(iter.next());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -224,6 +224,8 @@ public class LeaseSet extends DataStructureImpl {
|
||||
}
|
||||
|
||||
private byte[] getBytes() {
|
||||
if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null))
|
||||
return null;
|
||||
int len = PublicKey.KEYSIZE_BYTES // dest
|
||||
+ SigningPublicKey.KEYSIZE_BYTES // dest
|
||||
+ 4 // cert
|
||||
@ -233,9 +235,6 @@ public class LeaseSet extends DataStructureImpl {
|
||||
+ _leases.size() * 44; // leases
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(len);
|
||||
try {
|
||||
if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null))
|
||||
return null;
|
||||
|
||||
_destination.writeBytes(out);
|
||||
_encryptionKey.writeBytes(out);
|
||||
_signingKey.writeBytes(out);
|
||||
|
@ -76,7 +76,7 @@ public class Frequency {
|
||||
long duration = now() - _start;
|
||||
if ((duration <= 0) || (_count <= 0)) return 0;
|
||||
|
||||
return duration / _count;
|
||||
return duration / (double) _count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ public class NtpClient {
|
||||
// Process response
|
||||
NtpMessage msg = new NtpMessage(packet.getData());
|
||||
|
||||
double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
|
||||
(msg.receiveTimestamp-msg.transmitTimestamp);
|
||||
//double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
|
||||
// (msg.receiveTimestamp-msg.transmitTimestamp);
|
||||
double localClockOffset = ((msg.receiveTimestamp - msg.originateTimestamp) +
|
||||
(msg.transmitTimestamp - destinationTimestamp)) / 2;
|
||||
socket.close();
|
||||
|
@ -24,7 +24,7 @@ public final class ByteCache {
|
||||
* @param size how large should the objects cached be?
|
||||
*/
|
||||
public static ByteCache getInstance(int cacheSize, int size) {
|
||||
Integer sz = new Integer(size);
|
||||
Integer sz = Integer.valueOf(size);
|
||||
ByteCache cache = null;
|
||||
synchronized (_caches) {
|
||||
if (!_caches.containsKey(sz))
|
||||
|
@ -508,8 +508,6 @@ public class EepGet {
|
||||
_actualURL = "http://" + url.getHost() + ":" + url.getPort() + "/" + _redirectLocation;
|
||||
if ( (_actualURL.indexOf('?') < 0) && (query.length() > 0) )
|
||||
_actualURL = _actualURL + "?" + query;
|
||||
else
|
||||
_actualURL = _actualURL;
|
||||
}
|
||||
} catch (MalformedURLException mue) {
|
||||
throw new IOException("Redirected from an invalid URL");
|
||||
@ -772,7 +770,7 @@ public class EepGet {
|
||||
_log.warn("ERR: status "+ line);
|
||||
return -1;
|
||||
}
|
||||
String protocol = tok.nextToken(); // ignored
|
||||
tok.nextToken(); // ignored (protocol)
|
||||
if (!tok.hasMoreTokens()) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("ERR: status "+ line);
|
||||
@ -874,7 +872,7 @@ public class EepGet {
|
||||
|
||||
timeout.setSocket(_proxy);
|
||||
|
||||
_proxyOut.write(DataHelper.getUTF8(req.toString()));
|
||||
_proxyOut.write(DataHelper.getUTF8(req));
|
||||
_proxyOut.flush();
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -162,7 +162,7 @@ public class EepPost {
|
||||
}
|
||||
|
||||
private void sendFile(OutputStream out, String separator, String field, File file) throws IOException {
|
||||
long len = file.length();
|
||||
//long len = file.length();
|
||||
out.write(("--" + separator + CRLF).getBytes());
|
||||
out.write(("Content-Disposition: form-data; name=\"" + field + "\"; filename=\"" + file.getName() + "\"" + CRLF).getBytes());
|
||||
//out.write(("Content-length: " + len + "\n").getBytes());
|
||||
|
14
history.txt
14
history.txt
@ -1,3 +1,17 @@
|
||||
2008-10-20 zzz
|
||||
* configclients.jsp: Handle clients with no args
|
||||
* index.jsp: Add readme_nl.html (thanks mathiasdm!),
|
||||
readme_sv.html (thanks hottuna!)
|
||||
* Big findbugs cleanup
|
||||
* Client: Prevent a race causing session reconnect
|
||||
* FloodfillMonitor:
|
||||
- Don't become ff if clock skew is high
|
||||
- Rebuild routerinfo immediately when ff status changes
|
||||
* FloodOnlySearchJob: Recover better if the floodfills
|
||||
you know are no longer floodfill or are gone
|
||||
* Installer: Bump min JRE to 1.5
|
||||
* ShellCommand: Fix main()
|
||||
|
||||
2008-10-14 zzz
|
||||
* index.jsp: Add multilanguage support for readme.html;
|
||||
add readme_de.html (thanks devzero!)
|
||||
|
@ -86,7 +86,7 @@ public class I2NPMessageHandler {
|
||||
* message - if it is an unknown type or has improper formatting, etc.
|
||||
*/
|
||||
public I2NPMessage readMessage(byte data[]) throws IOException, I2NPMessageException {
|
||||
int offset = readMessage(data, 0);
|
||||
readMessage(data, 0);
|
||||
return lastRead();
|
||||
}
|
||||
public int readMessage(byte data[], int offset) throws IOException, I2NPMessageException {
|
||||
|
@ -41,7 +41,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
|
||||
|
||||
/** unsynchronized as its pretty much read only (except at startup) */
|
||||
private static final Map _builders = new HashMap(8);
|
||||
public static final void registerBuilder(Builder builder, int type) { _builders.put(new Integer(type), builder); }
|
||||
public static final void registerBuilder(Builder builder, int type) { _builders.put(Integer.valueOf(type), builder); }
|
||||
/** interface for extending the types of messages handled */
|
||||
public interface Builder {
|
||||
/** instantiate a new I2NPMessage to be populated shortly */
|
||||
@ -103,7 +103,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Reading bytes: type = " + type + " / uniqueId : " + _uniqueId + " / expiration : " + _expiration);
|
||||
readMessage(buffer, 0, size, type);
|
||||
long time = _context.clock().now() - start;
|
||||
//long time = _context.clock().now() - start;
|
||||
//if (time > 50)
|
||||
// _context.statManager().addRateData("i2np.readTime", time, time);
|
||||
_read = true;
|
||||
@ -148,7 +148,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
|
||||
_log.debug("Reading bytes: type = " + type + " / uniqueId : " + _uniqueId + " / expiration : " + _expiration);
|
||||
readMessage(data, cur, size, type);
|
||||
cur += size;
|
||||
long time = _context.clock().now() - start;
|
||||
//long time = _context.clock().now() - start;
|
||||
//if (time > 50)
|
||||
// _context.statManager().addRateData("i2np.readTime", time, time);
|
||||
_read = true;
|
||||
@ -228,7 +228,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
|
||||
off += 2;
|
||||
System.arraycopy(h.getData(), 0, buffer, off, CHECKSUM_LENGTH);
|
||||
|
||||
long time = _context.clock().now() - start;
|
||||
//long time = _context.clock().now() - start;
|
||||
//if (time > 50)
|
||||
// _context.statManager().addRateData("i2np.writeTime", time, time);
|
||||
|
||||
@ -370,7 +370,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
|
||||
case TunnelBuildReplyMessage.MESSAGE_TYPE:
|
||||
return new TunnelBuildReplyMessage(context);
|
||||
default:
|
||||
Builder builder = (Builder)_builders.get(new Integer(type));
|
||||
Builder builder = (Builder)_builders.get(Integer.valueOf(type));
|
||||
if (builder == null)
|
||||
return null;
|
||||
else
|
||||
|
@ -95,7 +95,7 @@ public class TunnelGatewayMessage extends I2NPMessageImpl {
|
||||
if (_tunnelId.getTunnelId() <= 0)
|
||||
throw new I2NPMessageException("Invalid tunnel Id " + _tunnelId);
|
||||
|
||||
int size = (int)DataHelper.fromLong(data, curIndex, 2);
|
||||
DataHelper.fromLong(data, curIndex, 2);
|
||||
curIndex += 2;
|
||||
curIndex = handler.readMessage(data, curIndex);
|
||||
_msg = handler.lastRead();
|
||||
|
@ -209,7 +209,7 @@ public class InNetMessagePool implements Service {
|
||||
} else {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Message expiring on "
|
||||
+ (messageBody != null ? (messageBody.getMessageExpiration()+"") : " [unknown]")
|
||||
+ messageBody.getMessageExpiration()
|
||||
+ " was not handled by a HandlerJobBuilder - DROPPING: " + messageBody,
|
||||
new Exception("f00!"));
|
||||
_context.statManager().addRateData("inNetPool.dropped", 1, 0);
|
||||
|
@ -369,7 +369,7 @@ public class JobQueue {
|
||||
+ _queueRunners.size() + " to " + numThreads);
|
||||
for (int i = _queueRunners.size(); i < numThreads; i++) {
|
||||
JobQueueRunner runner = new JobQueueRunner(_context, i);
|
||||
_queueRunners.put(new Integer(i), runner);
|
||||
_queueRunners.put(Integer.valueOf(i), runner);
|
||||
Thread t = new I2PThread(runner);
|
||||
t.setName("JobQueue"+(_runnerId++));
|
||||
//t.setPriority(I2PThread.MAX_PRIORITY-1);
|
||||
@ -390,7 +390,7 @@ public class JobQueue {
|
||||
}
|
||||
}
|
||||
|
||||
void removeRunner(int id) { _queueRunners.remove(new Integer(id)); }
|
||||
void removeRunner(int id) { _queueRunners.remove(Integer.valueOf(id)); }
|
||||
|
||||
/**
|
||||
* Responsible for moving jobs from the timed queue to the ready queue,
|
||||
|
@ -289,7 +289,6 @@ public class Router {
|
||||
log.debug("Config file: " + filename, new Exception("location"));
|
||||
}
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
File f = new File(filename);
|
||||
if (f.canRead()) {
|
||||
@ -303,8 +302,6 @@ public class Router {
|
||||
} catch (Exception ioe) {
|
||||
if (log != null)
|
||||
log.error("Error loading the router configuration from " + filename, ioe);
|
||||
} finally {
|
||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
|
||||
public final static String VERSION = "0.6.4";
|
||||
public final static long BUILD = 5;
|
||||
public final static long BUILD = 6;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -52,8 +52,8 @@ class RouterWatchdog implements Runnable {
|
||||
|
||||
private void dumpStatus() {
|
||||
if (_log.shouldLog(Log.ERROR)) {
|
||||
Job cur = _context.jobQueue().getLastJob();
|
||||
/*
|
||||
Job cur = _context.jobQueue().getLastJob();
|
||||
if (cur != null)
|
||||
_log.error("Most recent job: " + cur);
|
||||
_log.error("Last job began: "
|
||||
|
@ -214,9 +214,6 @@ public class StatisticsManager implements Service {
|
||||
return stats;
|
||||
}
|
||||
|
||||
private void includeRate(String rateName, Properties stats) {
|
||||
includeRate(rateName, stats, null);
|
||||
}
|
||||
private void includeRate(String rateName, Properties stats, long selectedPeriods[]) {
|
||||
includeRate(rateName, stats, selectedPeriods, false);
|
||||
}
|
||||
@ -272,7 +269,6 @@ public class StatisticsManager implements Service {
|
||||
buf.append(num(rate.getLastEventCount())).append(';');
|
||||
if (numPeriods > 0) {
|
||||
double avgFrequency = rate.getLifetimeEventCount() / (double)numPeriods;
|
||||
double peakFrequency = rate.getExtremeEventCount();
|
||||
buf.append(num(avgFrequency)).append(';');
|
||||
buf.append(num(rate.getExtremeEventCount())).append(';');
|
||||
buf.append(num((double)rate.getLifetimeEventCount())).append(';');
|
||||
|
@ -84,9 +84,6 @@ public class SubmitMessageHistoryJob extends JobImpl {
|
||||
return;
|
||||
}
|
||||
long size = dataFile.length();
|
||||
int expectedSend = 512; // 512 for HTTP overhead
|
||||
if (size > 0)
|
||||
expectedSend += (int)size/10; // compression
|
||||
FileInputStream fin = new FileInputStream(dataFile);
|
||||
BandwidthLimitedInputStream in = new BandwidthLimitedInputStream(getContext(), fin, null, true);
|
||||
boolean sent = HTTPSendData.postData(url, size, in);
|
||||
|
@ -61,7 +61,6 @@ public class GarlicMessageParser {
|
||||
}
|
||||
|
||||
private CloveSet readCloveSet(byte data[]) throws DataFormatException {
|
||||
Set cloves = new HashSet();
|
||||
int offset = 0;
|
||||
|
||||
CloveSet set = new CloveSet();
|
||||
|
@ -69,7 +69,6 @@ class ExpireRoutersJob extends JobImpl {
|
||||
private Set selectKeysToExpire() {
|
||||
Set possible = getNotInUse();
|
||||
Set expiring = new HashSet(16);
|
||||
long earliestPublishDate = getContext().clock().now() - EXPIRE_DELAY;
|
||||
|
||||
for (Iterator iter = possible.iterator(); iter.hasNext(); ) {
|
||||
Hash key = (Hash)iter.next();
|
||||
|
@ -58,7 +58,7 @@ class KBucketImpl implements KBucket {
|
||||
// we want to make sure we've got the cache in place before calling cachedXor
|
||||
_local.prepareCache();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Local hash reset to " + (local == null ? "null" : DataHelper.toHexString(local.getData())));
|
||||
_log.debug("Local hash reset to " + DataHelper.toHexString(local.getData()));
|
||||
}
|
||||
|
||||
private byte[] distanceFromLocal(Hash key) {
|
||||
|
@ -777,7 +777,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
boolean removed = _kb.remove(dbEntry);
|
||||
_kb.remove(dbEntry);
|
||||
_context.peerManager().removeCapabilities(dbEntry);
|
||||
// if we dont know the key, lets make sure it isn't a now-dead peer
|
||||
}
|
||||
@ -1054,9 +1054,9 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
Integer val = (Integer)routerVersions.get(routerVersion);
|
||||
if (val == null)
|
||||
routerVersions.put(routerVersion, new Integer(1));
|
||||
routerVersions.put(routerVersion, Integer.valueOf(1));
|
||||
else
|
||||
routerVersions.put(routerVersion, new Integer(val.intValue() + 1));
|
||||
routerVersions.put(routerVersion, Integer.valueOf(val.intValue() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ class SearchJob extends JobImpl {
|
||||
} else if (!(ds instanceof RouterInfo)) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn(getJobId() + ": Error selecting closest hash that wasnt a router! "
|
||||
+ peer + " : " + (ds == null ? "null" : ds.getClass().getName()));
|
||||
+ peer + " : " + ds.getClass().getName());
|
||||
_state.replyTimeout(peer);
|
||||
} else {
|
||||
RouterInfo ri = (RouterInfo)ds;
|
||||
@ -375,10 +375,10 @@ class SearchJob extends JobImpl {
|
||||
|
||||
getContext().statManager().addRateData("netDb.searchMessageCount", 1, 0);
|
||||
|
||||
if (_isLease || true) // always send searches out tunnels
|
||||
//if (_isLease || true) // always send searches out tunnels
|
||||
sendLeaseSearch(router);
|
||||
else
|
||||
sendRouterSearch(router);
|
||||
//else
|
||||
// sendRouterSearch(router);
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,10 +308,6 @@ class StoreJob extends JobImpl {
|
||||
return;
|
||||
}
|
||||
TunnelId replyTunnelId = replyTunnel.getReceiveTunnelId(0);
|
||||
if (replyTunnel == null) {
|
||||
_log.warn("No reply inbound tunnels available!");
|
||||
return;
|
||||
}
|
||||
msg.setReplyToken(token);
|
||||
msg.setReplyTunnel(replyTunnelId);
|
||||
msg.setReplyGateway(replyTunnel.getPeer(0));
|
||||
|
@ -67,7 +67,7 @@ public class ReliabilityCalculator extends Calculator {
|
||||
|
||||
val -= profile.getCommError().getRate(24*60*60*1000).getCurrentEventCount() * 1;
|
||||
|
||||
long now = _context.clock().now();
|
||||
//long now = _context.clock().now();
|
||||
|
||||
long timeSinceRejection = 61*60*1000; // now - profile.getTunnelHistory().getLastRejected();
|
||||
if (timeSinceRejection > 60*60*1000) {
|
||||
|
@ -41,7 +41,7 @@ public class CreateRouterInfoJob extends JobImpl {
|
||||
public void runJob() {
|
||||
_log.debug("Creating the new router info");
|
||||
// create a new router info and store it where LoadRouterInfoJob looks
|
||||
RouterInfo info = createRouterInfo();
|
||||
createRouterInfo();
|
||||
getContext().jobQueue().addJob(_next);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@ public class OutboundMessageRegistry {
|
||||
public List getOriginalMessages(I2NPMessage message) {
|
||||
ArrayList matchedSelectors = null;
|
||||
ArrayList removedSelectors = null;
|
||||
long beforeSync = _context.clock().now();
|
||||
synchronized (_selectors) {
|
||||
for (int i = 0; i < _selectors.size(); i++) {
|
||||
MessageSelector sel = (MessageSelector)_selectors.get(i);
|
||||
|
@ -168,10 +168,10 @@ public class EstablishmentManager {
|
||||
if (_outboundStates.size() >= getMaxConcurrentEstablish()) {
|
||||
List queued = (List)_queuedOutbound.get(to);
|
||||
if (queued == null) {
|
||||
queued = new ArrayList(1);
|
||||
if (_queuedOutbound.size() > MAX_QUEUED_OUTBOUND) {
|
||||
rejected = true;
|
||||
} else {
|
||||
queued = new ArrayList(1);
|
||||
_queuedOutbound.put(to, queued);
|
||||
}
|
||||
}
|
||||
@ -336,11 +336,11 @@ public class EstablishmentManager {
|
||||
*/
|
||||
PeerState receiveData(OutboundEstablishState state) {
|
||||
state.dataReceived();
|
||||
int active = 0;
|
||||
int admitted = 0;
|
||||
int remaining = 0;
|
||||
//int active = 0;
|
||||
//int admitted = 0;
|
||||
//int remaining = 0;
|
||||
synchronized (_outboundStates) {
|
||||
active = _outboundStates.size();
|
||||
//active = _outboundStates.size();
|
||||
_outboundStates.remove(state.getRemoteHostId());
|
||||
if (_queuedOutbound.size() > 0) {
|
||||
// there shouldn't have been queued messages for this active state, but just in case...
|
||||
@ -350,9 +350,9 @@ public class EstablishmentManager {
|
||||
state.addMessage((OutNetMessage)queued.get(i));
|
||||
}
|
||||
|
||||
admitted = locked_admitQueued();
|
||||
//admitted = locked_admitQueued();
|
||||
}
|
||||
remaining = _queuedOutbound.size();
|
||||
//remaining = _queuedOutbound.size();
|
||||
}
|
||||
//if (admitted > 0)
|
||||
// _log.log(Log.CRIT, "Admitted " + admitted + " with " + remaining + " remaining queued and " + active + " active");
|
||||
@ -598,7 +598,6 @@ public class EstablishmentManager {
|
||||
}
|
||||
|
||||
private void sendRequest(OutboundEstablishState state) {
|
||||
long now = _context.clock().now();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Send request to: " + state.getRemoteHostId().toString());
|
||||
UDPPacket packet = _builder.buildSessionRequestPacket(state);
|
||||
@ -703,7 +702,6 @@ public class EstablishmentManager {
|
||||
}
|
||||
|
||||
private void sendConfirmation(OutboundEstablishState state) {
|
||||
long now = _context.clock().now();
|
||||
boolean valid = state.validateSessionCreated();
|
||||
if (!valid) // validate clears fields on failure
|
||||
return;
|
||||
@ -841,11 +839,11 @@ public class EstablishmentManager {
|
||||
long now = _context.clock().now();
|
||||
long nextSendTime = -1;
|
||||
OutboundEstablishState outboundState = null;
|
||||
int admitted = 0;
|
||||
int remaining = 0;
|
||||
int active = 0;
|
||||
//int admitted = 0;
|
||||
//int remaining = 0;
|
||||
//int active = 0;
|
||||
synchronized (_outboundStates) {
|
||||
active = _outboundStates.size();
|
||||
//active = _outboundStates.size();
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("# outbound states: " + _outboundStates.size());
|
||||
for (Iterator iter = _outboundStates.values().iterator(); iter.hasNext(); ) {
|
||||
@ -891,8 +889,8 @@ public class EstablishmentManager {
|
||||
}
|
||||
}
|
||||
|
||||
admitted = locked_admitQueued();
|
||||
remaining = _queuedOutbound.size();
|
||||
//admitted = locked_admitQueued();
|
||||
//remaining = _queuedOutbound.size();
|
||||
}
|
||||
|
||||
//if (admitted > 0)
|
||||
|
@ -903,9 +903,10 @@ public class PeerState {
|
||||
|
||||
/** we are resending a packet, so lets jack up the rto */
|
||||
public void messageRetransmitted(int packets) {
|
||||
long now = _context.clock().now();
|
||||
if (true || _retransmissionPeriodStart + 1000 <= now) {
|
||||
//long now = _context.clock().now();
|
||||
//if (true || _retransmissionPeriodStart + 1000 <= now) {
|
||||
_packetsRetransmitted += packets;
|
||||
/*****
|
||||
} else {
|
||||
_packetRetransmissionRate = (int)((float)(0.9f*_packetRetransmissionRate) + (float)(0.1f*_packetsRetransmitted));
|
||||
//_packetsPeriodTransmitted = _packetsTransmitted - _retransmissionPeriodStart;
|
||||
@ -913,21 +914,24 @@ public class PeerState {
|
||||
_retransmissionPeriodStart = now;
|
||||
_packetsRetransmitted = packets;
|
||||
}
|
||||
*****/
|
||||
congestionOccurred();
|
||||
_context.statManager().addRateData("udp.congestedRTO", _rto, _rttDeviation);
|
||||
adjustMTU();
|
||||
//_rto *= 2;
|
||||
}
|
||||
public void packetsTransmitted(int packets) {
|
||||
long now = _context.clock().now();
|
||||
//long now = _context.clock().now();
|
||||
_packetsTransmitted += packets;
|
||||
//_packetsPeriodTransmitted += packets;
|
||||
/*****
|
||||
if (false && _retransmissionPeriodStart + 1000 <= now) {
|
||||
_packetRetransmissionRate = (int)((float)(0.9f*_packetRetransmissionRate) + (float)(0.1f*_packetsRetransmitted));
|
||||
_retransmissionPeriodStart = 0;
|
||||
_packetsPeriodRetransmitted = (int)_packetsRetransmitted;
|
||||
_packetsRetransmitted = 0;
|
||||
}
|
||||
*****/
|
||||
}
|
||||
/** how long does it usually take to get a message ACKed? */
|
||||
public int getRTT() { return _rtt; }
|
||||
|
@ -34,7 +34,7 @@ public class UDPReceiver {
|
||||
public UDPReceiver(RouterContext ctx, UDPTransport transport, DatagramSocket socket, String name) {
|
||||
_context = ctx;
|
||||
_log = ctx.logManager().getLog(UDPReceiver.class);
|
||||
_id = ++_id;
|
||||
_id++;
|
||||
_name = name;
|
||||
_inboundQueue = new ArrayList(128);
|
||||
_socket = socket;
|
||||
|
@ -101,13 +101,13 @@ public class UDPSender {
|
||||
* @return number of packets queued
|
||||
*/
|
||||
public int add(UDPPacket packet, int blockTime) {
|
||||
long expiration = _context.clock().now() + blockTime;
|
||||
//long expiration = _context.clock().now() + blockTime;
|
||||
int remaining = -1;
|
||||
long lifetime = -1;
|
||||
boolean added = false;
|
||||
int removed = 0;
|
||||
while ( (_keepRunning) && (remaining < 0) ) {
|
||||
try {
|
||||
//try {
|
||||
synchronized (_outboundQueue) {
|
||||
// clear out any too-old packets
|
||||
UDPPacket head = null;
|
||||
@ -123,12 +123,13 @@ public class UDPSender {
|
||||
}
|
||||
}
|
||||
|
||||
if (true || (_outboundQueue.size() < MAX_QUEUED)) {
|
||||
//if (true || (_outboundQueue.size() < MAX_QUEUED)) {
|
||||
lifetime = packet.getLifetime();
|
||||
_outboundQueue.add(packet);
|
||||
added = true;
|
||||
remaining = _outboundQueue.size();
|
||||
_outboundQueue.notifyAll();
|
||||
/*****
|
||||
} else {
|
||||
long remainingTime = expiration - _context.clock().now();
|
||||
if (remainingTime > 0) {
|
||||
@ -139,8 +140,9 @@ public class UDPSender {
|
||||
}
|
||||
lifetime = packet.getLifetime();
|
||||
}
|
||||
*****/
|
||||
}
|
||||
} catch (InterruptedException ie) {}
|
||||
//} catch (InterruptedException ie) {}
|
||||
}
|
||||
_context.statManager().addRateData("udp.sendQueueSize", remaining, lifetime);
|
||||
if (!added)
|
||||
|
@ -23,7 +23,7 @@ import net.i2p.util.Log;
|
||||
public class BuildMessageGenerator {
|
||||
// cached, rather than creating lots of temporary Integer objects whenever we build a tunnel
|
||||
public static final Integer ORDER[] = new Integer[TunnelBuildMessage.RECORD_COUNT];
|
||||
static { for (int i = 0; i < ORDER.length; i++) ORDER[i] = new Integer(i); }
|
||||
static { for (int i = 0; i < ORDER.length; i++) ORDER[i] = Integer.valueOf(i); }
|
||||
|
||||
/** return null if it is unable to find a router's public key (etc) */
|
||||
public TunnelBuildMessage createInbound(RouterContext ctx, TunnelCreatorConfig cfg) {
|
||||
|
@ -362,6 +362,8 @@ public class FragmentHandler {
|
||||
}
|
||||
|
||||
private void receiveComplete(FragmentedMessage msg) {
|
||||
if (msg == null)
|
||||
return;
|
||||
_completed++;
|
||||
String stringified = null;
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
@ -370,8 +372,6 @@ public class FragmentHandler {
|
||||
int fragmentCount = msg.getFragmentCount();
|
||||
// toByteArray destroys the contents of the message completely
|
||||
byte data[] = msg.toByteArray();
|
||||
if (msg == null)
|
||||
return;
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("RECV(" + data.length + "): " + Base64.encode(data)
|
||||
+ " " + _context.sha().calculateHash(data).toBase64());
|
||||
|
@ -77,7 +77,7 @@ public class InboundEndpointProcessor {
|
||||
RouterContext ctx = null;
|
||||
if (_context instanceof RouterContext)
|
||||
ctx = (RouterContext)_context;
|
||||
if ( (ctx != null) && (_config != null) && (_config.getLength() > 0) ) {
|
||||
if ( (ctx != null) && (_config.getLength() > 0) ) {
|
||||
int rtt = 0; // dunno... may not be related to an rtt
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Received a " + length + "byte message through tunnel " + _config);
|
||||
|
@ -60,13 +60,10 @@ public class PumpedTunnelGateway extends TunnelGateway {
|
||||
*/
|
||||
public void add(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) {
|
||||
_messagesSent++;
|
||||
long startAdd = System.currentTimeMillis();
|
||||
Pending cur = new PendingImpl(msg, toRouter, toTunnel);
|
||||
long beforeLock = System.currentTimeMillis();
|
||||
long afterAdded = -1;
|
||||
synchronized (_prequeue) {
|
||||
_prequeue.add(cur);
|
||||
afterAdded = System.currentTimeMillis();
|
||||
}
|
||||
_pumper.wantsPumping(this);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -510,7 +510,7 @@ public class TunnelDispatcher implements Service {
|
||||
+ (before-msg.getMessageExpiration()) + "ms ago? "
|
||||
+ msg, new Exception("cause"));
|
||||
}
|
||||
long tid1 = (outboundTunnel != null ? outboundTunnel.getTunnelId() : -1);
|
||||
long tid1 = outboundTunnel.getTunnelId();
|
||||
long tid2 = (targetTunnel != null ? targetTunnel.getTunnelId() : -1);
|
||||
_context.messageHistory().tunnelDispatched(msg.getUniqueId(), tid1, tid2, targetPeer, "outbound gateway");
|
||||
gw.add(msg, targetPeer, targetTunnel);
|
||||
|
@ -245,7 +245,7 @@ class BuildHandler {
|
||||
// For each peer in the tunnel
|
||||
for (int i = 0; i < cfg.getLength(); i++) {
|
||||
Hash peer = cfg.getPeer(i);
|
||||
int record = order.indexOf(new Integer(i));
|
||||
int record = order.indexOf(Integer.valueOf(i));
|
||||
if (record < 0) {
|
||||
_log.error("Bad status index " + i);
|
||||
return;
|
||||
@ -483,7 +483,7 @@ class BuildHandler {
|
||||
int proactiveDrops = countProactiveDrops();
|
||||
long recvDelay = System.currentTimeMillis()-state.recvTime;
|
||||
if (response == 0) {
|
||||
float pDrop = recvDelay / (BuildRequestor.REQUEST_TIMEOUT*3);
|
||||
float pDrop = ((float) recvDelay) / (float) (BuildRequestor.REQUEST_TIMEOUT*3);
|
||||
pDrop = (float)Math.pow(pDrop, 16);
|
||||
if (_context.random().nextFloat() < pDrop) { // || (proactiveDrops > MAX_PROACTIVE_DROPS) ) ) {
|
||||
_context.statManager().addRateData("tunnel.rejectOverloaded", recvDelay, proactiveDrops);
|
||||
@ -648,7 +648,7 @@ class BuildHandler {
|
||||
+ ", waiting ids: " + ids + ", found matching tunnel? " + (cfg != null),
|
||||
null);//new Exception("source"));
|
||||
if (cfg != null) {
|
||||
BuildEndMessageState state = new BuildEndMessageState(cfg, receivedMessage, from, fromHash);
|
||||
BuildEndMessageState state = new BuildEndMessageState(cfg, receivedMessage);
|
||||
if (HANDLE_REPLIES_INLINE) {
|
||||
handleRequestAsInboundEndpoint(state);
|
||||
} else {
|
||||
@ -737,10 +737,10 @@ class BuildHandler {
|
||||
_log.debug("Receive tunnel build reply message " + receivedMessage.getUniqueId() + " from "
|
||||
+ (fromHash != null ? fromHash.toBase64() : from != null ? from.calculateHash().toBase64() : "a tunnel"));
|
||||
if (HANDLE_REPLIES_INLINE) {
|
||||
handleReply(new BuildReplyMessageState(receivedMessage, from, fromHash));
|
||||
handleReply(new BuildReplyMessageState(receivedMessage));
|
||||
} else {
|
||||
synchronized (_inboundBuildReplyMessages) {
|
||||
_inboundBuildReplyMessages.add(new BuildReplyMessageState(receivedMessage, from, fromHash));
|
||||
_inboundBuildReplyMessages.add(new BuildReplyMessageState(receivedMessage));
|
||||
}
|
||||
_exec.repoll();
|
||||
}
|
||||
@ -764,13 +764,9 @@ class BuildHandler {
|
||||
/** replies for outbound tunnels that we have created */
|
||||
private class BuildReplyMessageState {
|
||||
TunnelBuildReplyMessage msg;
|
||||
RouterIdentity from;
|
||||
Hash fromHash;
|
||||
long recvTime;
|
||||
public BuildReplyMessageState(I2NPMessage m, RouterIdentity f, Hash h) {
|
||||
public BuildReplyMessageState(I2NPMessage m) {
|
||||
msg = (TunnelBuildReplyMessage)m;
|
||||
from = f;
|
||||
fromHash = h;
|
||||
recvTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@ -778,14 +774,10 @@ class BuildHandler {
|
||||
private class BuildEndMessageState {
|
||||
TunnelBuildMessage msg;
|
||||
PooledTunnelCreatorConfig cfg;
|
||||
RouterIdentity from;
|
||||
Hash fromHash;
|
||||
long recvTime;
|
||||
public BuildEndMessageState(PooledTunnelCreatorConfig c, I2NPMessage m, RouterIdentity f, Hash h) {
|
||||
public BuildEndMessageState(PooledTunnelCreatorConfig c, I2NPMessage m) {
|
||||
cfg = c;
|
||||
msg = (TunnelBuildMessage)m;
|
||||
from = f;
|
||||
fromHash = h;
|
||||
recvTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class BuildRequestor {
|
||||
private static final List ORDER = new ArrayList(BuildMessageGenerator.ORDER.length);
|
||||
static {
|
||||
for (int i = 0; i < BuildMessageGenerator.ORDER.length; i++)
|
||||
ORDER.add(new Integer(i));
|
||||
ORDER.add(Integer.valueOf(i));
|
||||
}
|
||||
private static final int PRIORITY = 500;
|
||||
static final int REQUEST_TIMEOUT = 10*1000;
|
||||
|
@ -103,7 +103,6 @@ public abstract class TunnelPeerSelector {
|
||||
Log log = ctx.logManager().getLog(ClientPeerSelector.class);
|
||||
List rv = new ArrayList();
|
||||
StringTokenizer tok = new StringTokenizer(peers, ",");
|
||||
Hash h = new Hash();
|
||||
while (tok.hasMoreTokens()) {
|
||||
String peerStr = tok.nextToken();
|
||||
Hash peer = new Hash();
|
||||
@ -307,7 +306,6 @@ public abstract class TunnelPeerSelector {
|
||||
private static char[] getExcludeCaps(RouterContext ctx) {
|
||||
String excludeCaps = ctx.getProperty("router.excludePeerCaps",
|
||||
String.valueOf(Router.CAPABILITY_BW12));
|
||||
Set peers = new HashSet();
|
||||
if (excludeCaps != null) {
|
||||
char excl[] = excludeCaps.toCharArray();
|
||||
return excl;
|
||||
@ -342,7 +340,6 @@ public abstract class TunnelPeerSelector {
|
||||
String val = peer.getOption("stat_uptime");
|
||||
if (val != null) {
|
||||
long uptimeMs = 0;
|
||||
if (val != null) {
|
||||
long factor = 1;
|
||||
if (val.endsWith("ms")) {
|
||||
factor = 1;
|
||||
@ -362,10 +359,6 @@ public abstract class TunnelPeerSelector {
|
||||
}
|
||||
try { uptimeMs = Long.parseLong(val); } catch (NumberFormatException nfe) {}
|
||||
uptimeMs *= factor;
|
||||
} else {
|
||||
// not publishing an uptime, so exclude it
|
||||
return true;
|
||||
}
|
||||
|
||||
long infoAge = ctx.clock().now() - peer.getPublished();
|
||||
if (infoAge < 0) {
|
||||
@ -391,7 +384,7 @@ public abstract class TunnelPeerSelector {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not publishing stats, so exclude it
|
||||
// not publishing an uptime, so exclude it
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -336,13 +336,11 @@ public class TunnelPool {
|
||||
public void tunnelFailed(PooledTunnelCreatorConfig cfg) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn(toString() + ": Tunnel failed: " + cfg);
|
||||
int remaining = 0;
|
||||
LeaseSet ls = null;
|
||||
synchronized (_tunnels) {
|
||||
_tunnels.remove(cfg);
|
||||
if (_settings.isInbound() && (_settings.getDestination() != null) )
|
||||
ls = locked_buildNewLeaseSet();
|
||||
remaining = _tunnels.size();
|
||||
if (_lastSelected == cfg) {
|
||||
_lastSelected = null;
|
||||
_lastSelectionPeriod = 0;
|
||||
@ -403,12 +401,10 @@ public class TunnelPool {
|
||||
void refreshLeaseSet() {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(toString() + ": refreshing leaseSet on tunnel expiration (but prior to grace timeout)");
|
||||
int remaining = 0;
|
||||
LeaseSet ls = null;
|
||||
if (_settings.isInbound() && (_settings.getDestination() != null) ) {
|
||||
synchronized (_tunnels) {
|
||||
ls = locked_buildNewLeaseSet();
|
||||
remaining = _tunnels.size();
|
||||
}
|
||||
if (ls != null) {
|
||||
_context.clientManager().requestLeaseSet(_settings.getDestination(), ls);
|
||||
|
Reference in New Issue
Block a user