propagate from branch 'i2p.i2p.zzz.test2' (head 8fa44268a1dd2b7baaf01806e6994281ab031870)

to branch 'i2p.i2p' (head 44afdaa15ce8a95c112c7d58a5908f401c1a0145)
This commit is contained in:
zzz
2015-11-22 16:00:16 +00:00
148 changed files with 1130 additions and 638 deletions

View File

@@ -7,7 +7,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
@@ -57,9 +56,7 @@ class ConnThrottler {
_log = log;
// for logging
_fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
String systemTimeZone = I2PAppContext.getGlobalContext().getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
_fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
_fmt.setTimeZone(DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext()));
new Cleaner();
}

View File

@@ -105,7 +105,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getTotalRead() {
try {
return inf.getBytesRead();
} catch (Exception e) {
} catch (RuntimeException e) {
return 0;
}
}
@@ -116,7 +116,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getTotalExpanded() {
try {
return inf.getBytesWritten();
} catch (Exception e) {
} catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -128,7 +128,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getRemaining() {
try {
return inf.getRemaining();
} catch (Exception e) {
} catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -140,7 +140,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public boolean getFinished() {
try {
return inf.finished();
} catch (Exception e) {
} catch (RuntimeException e) {
// possible NPE in some implementations
return true;
}

View File

@@ -1873,7 +1873,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
try {
result.fromByteArray(content);
return result;
} catch (Exception ex) {
} catch (RuntimeException ex) {
if (log.shouldLog(Log.INFO))
log.info("File is not a binary destination - trying base64");
try {

View File

@@ -3,6 +3,7 @@
*/
package net.i2p.i2ptunnel;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketAddress;
import net.i2p.data.Destination;
@@ -122,7 +124,17 @@ public class I2PTunnelClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//t.start();
t.run();
} catch (Exception ex) {
} catch (IOException ex) {
if (_log.shouldLog(Log.INFO))
_log.info("Error connecting", ex);
//l.log("Error connecting: " + ex.getMessage());
closeSocket(s);
if (i2ps != null) {
synchronized (sockLock) {
mySockets.remove(sockLock);
}
}
} catch (I2PException ex) {
if (_log.shouldLog(Log.INFO))
_log.info("Error connecting", ex);
//l.log("Error connecting: " + ex.getMessage());

View File

@@ -414,7 +414,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
_log.debug(getPrefix(requestId) + "First line [" + line + "]");
}
String[] params = line.split(" ", 3);
String[] params = DataHelper.split(line, " ", 3);
if(params.length != 3) {
break;
}
@@ -1252,7 +1252,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
String s = getTunnel().getClientOptions().getProperty(PROP_SSL_OUTPROXIES);
if (s == null)
return null;
String[] p = s.split("[,; \r\n\t]");
String[] p = DataHelper.split(s, "[,; \r\n\t]");
if (p.length == 0)
return null;
// todo doesn't check for ""

View File

@@ -285,7 +285,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
// We send Accept-Charset: UTF-8 in the 407 so hopefully it comes back that way inside the B64 ?
try {
String dec = new String(decoded, "UTF-8");
String[] parts = dec.split(":");
String[] parts = DataHelper.split(dec, ":");
String user = parts[0];
String pw = parts[1];
// first try pw for that user

View File

@@ -664,7 +664,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
*/
@Override
protected String filterResponseLine(String line) {
String[] s = line.split(" ", 3);
String[] s = DataHelper.split(line, " ", 3);
if (s.length > 1 &&
(s[1].startsWith("3") || s[1].startsWith("5")))
_dataExpected = 0;
@@ -742,7 +742,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
public long getTotalRead() {
try {
return def.getTotalIn();
} catch (Exception e) {
} catch (RuntimeException e) {
// j2se 1.4.2_08 on linux is sometimes throwing an NPE in the getTotalIn() implementation
return 0;
}
@@ -750,7 +750,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
public long getTotalCompressed() {
try {
return def.getTotalOut();
} catch (Exception e) {
} catch (RuntimeException e) {
// j2se 1.4.2_08 on linux is sometimes throwing an NPE in the getTotalOut() implementation
return 0;
}

View File

@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketAddress;
import net.i2p.data.DataHelper;
@@ -142,7 +143,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//out.start();
out.run();
} catch (Exception ex) {
} catch (IOException ex) {
// generally NoRouteToHostException
if (_log.shouldLog(Log.WARN))
_log.warn("Error connecting", ex);
@@ -160,6 +161,23 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
mySockets.remove(sockLock);
}
}
} catch (I2PException ex) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error connecting", ex);
//l.log("Error connecting: " + ex.getMessage());
try {
// Send a response so the user doesn't just see a disconnect
// and blame his router or the network.
String name = addr != null ? addr.getHostName() : "undefined";
String msg = ":" + name + " 499 you :" + ex + "\r\n";
s.getOutputStream().write(DataHelper.getUTF8(msg));
} catch (IOException ioe) {}
closeSocket(s);
if (i2ps != null) {
synchronized (sockLock) {
mySockets.remove(sockLock);
}
}
}
}

View File

@@ -13,6 +13,7 @@ import java.util.Properties;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.crypto.SHA256Generator;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
import net.i2p.data.Base32;
@@ -277,7 +278,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Got line: " + s);
String field[]=s.split(" ",5);
String field[] = DataHelper.split(s, " ", 5);
String command;
int idx=0;

View File

@@ -182,7 +182,7 @@ public class I2PTunnelOutproxyRunner extends I2PAppThread {
} catch (IllegalStateException ise) {
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", ise);
} catch (Exception e) {
} catch (RuntimeException e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Internal error", e);
} finally {

View File

@@ -326,7 +326,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
// at net.i2p.i2ptunnel.I2PTunnelRunner.run(I2PTunnelRunner.java:167)
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", ise);
} catch (Exception e) {
} catch (RuntimeException e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Internal error", e);
} finally {

View File

@@ -517,7 +517,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
break;
} catch(SocketTimeoutException ste) {
// ignored, we never set the timeout
} catch (Exception e) {
} catch (RuntimeException e) {
// streaming borkage
if (_log.shouldLog(Log.ERROR))
_log.error("Uncaught exception accepting", e);

View File

@@ -19,6 +19,7 @@ import net.i2p.I2PException;
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.util.EventDispatcher;
import net.i2p.util.I2PAppThread;
@@ -93,7 +94,7 @@ public class I2Ping extends I2PTunnelClientBase {
int localPort = 0;
int remotePort = 0;
boolean error = false;
String[] argv = cmd.split(" ");
String[] argv = DataHelper.split(cmd, " ");
Getopt g = new Getopt("ping", argv, "t:m:n:chl:f:p:");
int c;
while ((c = g.getopt()) != -1) {

View File

@@ -230,7 +230,7 @@ public class TunnelController implements Logging {
}
try {
doStartTunnel();
} catch (Exception e) {
} catch (RuntimeException e) {
_log.error("Error starting the tunnel " + getName(), e);
log("Error starting the tunnel " + getName() + ": " + e.getMessage());
// if we don't acquire() then the release() in stopTunnel() won't work

View File

@@ -6,6 +6,7 @@ package net.i2p.i2ptunnel.irc;
import java.net.Socket;
import java.io.IOException;
import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.client.streaming.I2PSocketOptions;
@@ -80,7 +81,14 @@ public class I2PTunnelDCCClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//t.start();
t.run();
} catch (Exception ex) {
} catch (IOException ex) {
_log.error("Could not make DCC connection to " + _dest + ':' + _remotePort, ex);
closeSocket(s);
if (i2ps != null) {
try { i2ps.close(); } catch (IOException ioe) {}
}
notifyEvent(CONNECT_STOP_EVENT, Integer.valueOf(getLocalPort()));
} catch (I2PException ex) {
_log.error("Could not make DCC connection to " + _dest + ':' + _remotePort, ex);
closeSocket(s);
if (i2ps != null) {

View File

@@ -33,7 +33,7 @@ abstract class IRCFilter {
*/
public static String inboundFilter(String s, StringBuffer expectedPong, DCCHelper helper) {
String field[]=s.split(" ",4);
String field[] = DataHelper.split(s, " ", 4);
String command;
int idx=0;
final String[] allowedCommands =
@@ -274,7 +274,7 @@ abstract class IRCFilter {
*/
public static String outboundFilter(String s, StringBuffer expectedPong, DCCHelper helper) {
String field[]=s.split(" ",3);
String field[] = DataHelper.split(s, " ",3);
if(field[0].length()==0)
return null; // W T F?
@@ -420,7 +420,7 @@ abstract class IRCFilter {
int ctcp = msg.indexOf(0x01);
if (ctcp > 0)
msg = msg.substring(0, ctcp);
String[] args = msg.split(" ", 5);
String[] args = DataHelper.split(msg, " ", 5);
if (args.length <= 0)
return null;
String type = args[0];
@@ -512,7 +512,7 @@ abstract class IRCFilter {
int ctcp = msg.indexOf(0x01);
if (ctcp > 0)
msg = msg.substring(0, ctcp);
String[] args = msg.split(" ", 5);
String[] args = DataHelper.split(msg, " ", 5);
if (args.length <= 0)
return null;
String type = args[0];

View File

@@ -9,6 +9,7 @@ import java.util.Properties;
import java.util.TreeMap;
import net.i2p.I2PAppContext;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper;
@@ -341,7 +342,8 @@ public class GeneralHelper {
rv = pkf.getDestination();
if (rv != null)
return rv;
} catch (Exception e) {}
} catch (I2PException e) {
} catch (IOException e) {}
}
}
return null;

View File

@@ -8,8 +8,11 @@ package net.i2p.i2ptunnel.web;
*
*/
import java.io.IOException;
import java.util.List;
import java.util.Set;
import net.i2p.I2PException;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
@@ -87,7 +90,8 @@ public class EditBean extends IndexBean {
//System.err.println("Signing " + spoof + " with " + Base64.encode(privKey.getData()));
Signature sig = _context.dsa().sign(spoof.getBytes("UTF-8"), privKey);
return Base64.encode(sig.getData());
} catch (Exception e) {}
} catch (I2PException e) {
} catch (IOException e) {}
}
return "";
}

View File

@@ -9,12 +9,14 @@ package net.i2p.i2ptunnel.web;
*/
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import net.i2p.I2PAppContext;
import net.i2p.I2PException;
import net.i2p.app.ClientAppManager;
import net.i2p.app.Outproxy;
import net.i2p.data.Certificate;
@@ -266,7 +268,7 @@ public class IndexBean {
if (_action != null) {
try {
buf.append(processAction()).append('\n');
} catch (Exception e) {
} catch (RuntimeException e) {
_log.log(Log.CRIT, "Error processing " + _action, e);
buf.append("Error: ").append(e.toString()).append('\n');
}
@@ -972,7 +974,9 @@ public class IndexBean {
PrivateKeyFile pkf = new PrivateKeyFile(keyFile);
try {
pkf.createIfAbsent();
} catch (Exception e) {
} catch (I2PException e) {
return "Create private key file failed: " + e;
} catch (IOException e) {
return "Create private key file failed: " + e;
}
switch (_certType) {
@@ -1011,7 +1015,9 @@ public class IndexBean {
try {
pkf.write();
newdest = pkf.getDestination();
} catch (Exception e) {
} catch (I2PException e) {
return "Modification failed: " + e;
} catch (IOException e) {
return "Modification failed: " + e;
}
return "Destination modified - " +