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