forked from I2P_Developers/i2p.i2p
@@ -45,11 +45,11 @@
|
|||||||
</p><p>
|
</p><p>
|
||||||
<%
|
<%
|
||||||
if (ERROR_THROWABLE != null) {
|
if (ERROR_THROWABLE != null) {
|
||||||
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(2048);
|
java.io.StringWriter sw = new java.io.StringWriter(2048);
|
||||||
java.io.PrintStream ps = new java.io.PrintStream(baos);
|
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
|
||||||
ERROR_THROWABLE.printStackTrace(ps);
|
ERROR_THROWABLE.printStackTrace(pw);
|
||||||
ps.close();
|
pw.flush();
|
||||||
String trace = baos.toString();
|
String trace = sw.toString();
|
||||||
trace = trace.replace("&", "&").replace("<", "<").replace(">", ">");
|
trace = trace.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||||
trace = trace.replace("\n", "<br> \n");
|
trace = trace.replace("\n", "<br> \n");
|
||||||
out.print(trace);
|
out.print(trace);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
@@ -235,7 +236,7 @@ public class SingleFileNamingService extends NamingService {
|
|||||||
// FIXME fails if previous last line didn't have a trailing \n
|
// FIXME fails if previous last line didn't have a trailing \n
|
||||||
out.write(hostname.getBytes("UTF-8"));
|
out.write(hostname.getBytes("UTF-8"));
|
||||||
out.write('=');
|
out.write('=');
|
||||||
out.write(d.toBase64().getBytes());
|
out.write(DataHelper.getASCII(d.toBase64()));
|
||||||
out.write('\n');
|
out.write('\n');
|
||||||
out.close();
|
out.close();
|
||||||
for (NamingServiceListener nsl : _listeners) {
|
for (NamingServiceListener nsl : _listeners) {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class RateStat {
|
|||||||
buf.append("# Rate: ").append(_groupName).append(": ").append(_statName).append(NL);
|
buf.append("# Rate: ").append(_groupName).append(": ").append(_statName).append(NL);
|
||||||
buf.append("# ").append(_description).append(NL);
|
buf.append("# ").append(_description).append(NL);
|
||||||
buf.append("# ").append(NL).append(NL);
|
buf.append("# ").append(NL).append(NL);
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes("UTF-8"));
|
||||||
buf.setLength(0);
|
buf.setLength(0);
|
||||||
for (Rate r: _rates){
|
for (Rate r: _rates){
|
||||||
buf.append("#######").append(NL);
|
buf.append("#######").append(NL);
|
||||||
@@ -193,7 +193,7 @@ public class RateStat {
|
|||||||
buf.append(NL);
|
buf.append(NL);
|
||||||
String curPrefix = prefix + "." + DataHelper.formatDuration(r.getPeriod());
|
String curPrefix = prefix + "." + DataHelper.formatDuration(r.getPeriod());
|
||||||
r.store(curPrefix, buf);
|
r.store(curPrefix, buf);
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes("UTF-8"));
|
||||||
buf.setLength(0);
|
buf.setLength(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hexdump class (well, it's actually a namespace with some functions,
|
* Hexdump class (well, it's actually a namespace with some functions,
|
||||||
* but let's stick with java terminology :-). These methods generate
|
* but let's stick with java terminology :-). These methods generate
|
||||||
@@ -25,7 +27,7 @@ public class HexDump {
|
|||||||
|
|
||||||
private static final int FORMAT_OFFSET_PADDING = 8;
|
private static final int FORMAT_OFFSET_PADDING = 8;
|
||||||
private static final int FORMAT_BYTES_PER_ROW = 16;
|
private static final int FORMAT_BYTES_PER_ROW = 16;
|
||||||
private static final byte[] HEXCHARS = "0123456789abcdef".getBytes();
|
private static final byte[] HEXCHARS = DataHelper.getASCII("0123456789abcdef");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump a byte array in a String.
|
* Dump a byte array in a String.
|
||||||
@@ -37,11 +39,10 @@ public class HexDump {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
dump(data, 0, data.length, out);
|
dump(data, 0, data.length, out);
|
||||||
|
return out.toString("ISO-8859-1");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("no 8859?", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,11 +57,10 @@ public class HexDump {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
dump(data, off, len, out);
|
dump(data, off, len, out);
|
||||||
|
return out.toString("ISO-8859-1");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("no 8859?", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,9 +91,10 @@ public class HexDump {
|
|||||||
hexoff = Integer.toString(dumpoff, 16);
|
hexoff = Integer.toString(dumpoff, 16);
|
||||||
hexofflen = hexoff.length();
|
hexofflen = hexoff.length();
|
||||||
for (i = 0; i < FORMAT_OFFSET_PADDING - hexofflen; ++i) {
|
for (i = 0; i < FORMAT_OFFSET_PADDING - hexofflen; ++i) {
|
||||||
hexoff = "0" + hexoff;
|
out.write('0');
|
||||||
}
|
}
|
||||||
out.write((hexoff + " ").getBytes());
|
out.write(DataHelper.getASCII(hexoff));
|
||||||
|
out.write(' ');
|
||||||
|
|
||||||
// Bytes to be printed in the current line
|
// Bytes to be printed in the current line
|
||||||
nextbytes = (FORMAT_BYTES_PER_ROW < (end - dumpoff) ? FORMAT_BYTES_PER_ROW : (end - dumpoff));
|
nextbytes = (FORMAT_BYTES_PER_ROW < (end - dumpoff) ? FORMAT_BYTES_PER_ROW : (end - dumpoff));
|
||||||
@@ -101,15 +102,15 @@ public class HexDump {
|
|||||||
for (i = 0; i < FORMAT_BYTES_PER_ROW; ++i) {
|
for (i = 0; i < FORMAT_BYTES_PER_ROW; ++i) {
|
||||||
// Put two spaces to separate 8-bytes blocks
|
// Put two spaces to separate 8-bytes blocks
|
||||||
if ((i % 8) == 0) {
|
if ((i % 8) == 0) {
|
||||||
out.write(" ".getBytes());
|
out.write(' ');
|
||||||
}
|
}
|
||||||
if (i >= nextbytes) {
|
if (i >= nextbytes) {
|
||||||
out.write(" ".getBytes());
|
out.write(DataHelper.getASCII(" "));
|
||||||
} else {
|
} else {
|
||||||
val = data[dumpoff + i] & 0xff;
|
val = data[dumpoff + i] & 0xff;
|
||||||
out.write(HEXCHARS[val >>> 4]);
|
out.write(HEXCHARS[val >>> 4]);
|
||||||
out.write(HEXCHARS[val & 0xf]);
|
out.write(HEXCHARS[val & 0xf]);
|
||||||
out.write(" ".getBytes());
|
out.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,19 +118,32 @@ public class HexDump {
|
|||||||
|
|
||||||
for (i = 0; i < FORMAT_BYTES_PER_ROW; ++i) {
|
for (i = 0; i < FORMAT_BYTES_PER_ROW; ++i) {
|
||||||
if (i >= nextbytes) {
|
if (i >= nextbytes) {
|
||||||
out.write(" ".getBytes());
|
out.write(' ');
|
||||||
} else {
|
} else {
|
||||||
val = data[i + dumpoff];
|
val = data[i + dumpoff];
|
||||||
// Is it a printable character?
|
// Is it a printable character?
|
||||||
if ((val > 31) && (val < 127)) {
|
if ((val > 31) && (val < 127)) {
|
||||||
out.write(val);
|
out.write(val);
|
||||||
} else {
|
} else {
|
||||||
out.write(".".getBytes());
|
out.write('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write("|\n".getBytes());
|
out.write('|');
|
||||||
|
out.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.21
|
||||||
|
*/
|
||||||
|
/****
|
||||||
|
public static void main(String[] args) {
|
||||||
|
byte[] b = new byte[9993];
|
||||||
|
RandomSource.getInstance().nextBytes(b);
|
||||||
|
System.out.println(dump(b));
|
||||||
|
System.out.println(dump("test test test abcde xyz !!!".getBytes()));
|
||||||
|
}
|
||||||
|
****/
|
||||||
|
}
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ class LogRecordFormatter {
|
|||||||
buf.append(NL);
|
buf.append(NL);
|
||||||
if (rec.getThrowable() != null) {
|
if (rec.getThrowable() != null) {
|
||||||
StringWriter sw = new StringWriter(512);
|
StringWriter sw = new StringWriter(512);
|
||||||
PrintWriter pw = new PrintWriter(sw, true);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
rec.getThrowable().printStackTrace(pw);
|
rec.getThrowable().printStackTrace(pw);
|
||||||
sw.flush();
|
pw.flush();
|
||||||
buf.append(sw.toString());
|
buf.append(sw.toString());
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ public class DBHistory {
|
|||||||
add(buf, "unpromptedDbStoreOld", _unpromptedDbStoreOld, "How times have they sent us something we didn't ask for but have seen before?");
|
add(buf, "unpromptedDbStoreOld", _unpromptedDbStoreOld, "How times have they sent us something we didn't ask for but have seen before?");
|
||||||
add(buf, "lastLookupReceived", _lastLookupReceived, "When was the last time they send us a lookup? (milliseconds since the epoch)");
|
add(buf, "lastLookupReceived", _lastLookupReceived, "When was the last time they send us a lookup? (milliseconds since the epoch)");
|
||||||
add(buf, "avgDelayBetweenLookupsReceived", _avgDelayBetweenLookupsReceived, "How long is it typically between each db lookup they send us? (in milliseconds)");
|
add(buf, "avgDelayBetweenLookupsReceived", _avgDelayBetweenLookupsReceived, "How long is it typically between each db lookup they send us? (in milliseconds)");
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes("UTF-8"));
|
||||||
_failedLookupRate.store(out, "dbHistory.failedLookupRate");
|
_failedLookupRate.store(out, "dbHistory.failedLookupRate");
|
||||||
_invalidReplyRate.store(out, "dbHistory.invalidReplyRate");
|
_invalidReplyRate.store(out, "dbHistory.invalidReplyRate");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ class ProfilePersistenceHelper {
|
|||||||
add(buf, "tunnelPeakTunnel1mThroughput", profile.getPeakTunnel1mThroughputKBps(), "KBytes/sec");
|
add(buf, "tunnelPeakTunnel1mThroughput", profile.getPeakTunnel1mThroughputKBps(), "KBytes/sec");
|
||||||
buf.append(NL);
|
buf.append(NL);
|
||||||
|
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes("UTF-8"));
|
||||||
|
|
||||||
if (profile.getIsExpanded()) {
|
if (profile.getIsExpanded()) {
|
||||||
// only write out expanded data if, uh, we've got it
|
// only write out expanded data if, uh, we've got it
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class TunnelHistory {
|
|||||||
add(buf, "lifetimeAgreedTo", _lifetimeAgreedTo.get(), "How many tunnels has the peer ever agreed to participate in?");
|
add(buf, "lifetimeAgreedTo", _lifetimeAgreedTo.get(), "How many tunnels has the peer ever agreed to participate in?");
|
||||||
add(buf, "lifetimeFailed", _lifetimeFailed.get(), "How many tunnels has the peer ever agreed to participate in that failed prematurely?");
|
add(buf, "lifetimeFailed", _lifetimeFailed.get(), "How many tunnels has the peer ever agreed to participate in that failed prematurely?");
|
||||||
add(buf, "lifetimeRejected", _lifetimeRejected.get(), "How many tunnels has the peer ever refused to participate in?");
|
add(buf, "lifetimeRejected", _lifetimeRejected.get(), "How many tunnels has the peer ever refused to participate in?");
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes("UTF-8"));
|
||||||
_rejectRate.store(out, "tunnelHistory.rejectRate");
|
_rejectRate.store(out, "tunnelHistory.rejectRate");
|
||||||
_failRate.store(out, "tunnelHistory.failRate");
|
_failRate.store(out, "tunnelHistory.failRate");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ public class WorkingDir {
|
|||||||
}
|
}
|
||||||
System.setProperty(PROP_WRAPPER_LOG, logfile.getAbsolutePath());
|
System.setProperty(PROP_WRAPPER_LOG, logfile.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
PrintStream ps = new PrintStream(new SecureFileOutputStream(logfile, true));
|
PrintStream ps = new PrintStream(new SecureFileOutputStream(logfile, true), true, "UTF-8");
|
||||||
System.setOut(ps);
|
System.setOut(ps);
|
||||||
System.setErr(ps);
|
System.setErr(ps);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SecureFileOutputStream;
|
import net.i2p.util.SecureFileOutputStream;
|
||||||
@@ -45,7 +46,7 @@ public class MarkLiveliness implements SimpleTimer.TimedEvent {
|
|||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
fos = new SecureFileOutputStream(_pingFile);
|
fos = new SecureFileOutputStream(_pingFile);
|
||||||
fos.write(Long.toString(System.currentTimeMillis()).getBytes());
|
fos.write(DataHelper.getASCII(Long.toString(System.currentTimeMillis())));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (!_errorLogged) {
|
if (!_errorLogged) {
|
||||||
Log log = _router.getContext().logManager().getLog(MarkLiveliness.class);
|
Log log = _router.getContext().logManager().getLog(MarkLiveliness.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user