* Config files: Add some encoding help
* DataHelper, Router: - Save config files in UTF-8 rather than the default encoding, since we read them in UTF-8 * jetty.xml: Change encoding to UTF-8 * logs.jsp: Add system encoding * NTCP: Clean up clock skew shitlist message * Shitlist: Clean up expire message * WorkingDir: Ensure modified files are processed with UTF-8 encoding
This commit is contained in:
@ -1013,12 +1013,17 @@ public class Router {
|
||||
* Save the current config options (returning true if save was
|
||||
* successful, false otherwise)
|
||||
*
|
||||
* Note that unlike DataHelper.storeProps(),
|
||||
* this does escape the \r or \n that are unescaped in DataHelper.loadProps().
|
||||
* Note that the escaping of \r or \n was probably a mistake and should be taken out.
|
||||
*
|
||||
*/
|
||||
public boolean saveConfig() {
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(_configFilename);
|
||||
StringBuilder buf = new StringBuilder(8*1024);
|
||||
buf.append("# NOTE: This I2P config file must use UTF-8 encoding\n");
|
||||
synchronized (_config) {
|
||||
TreeSet ordered = new TreeSet(_config.keySet());
|
||||
for (Iterator iter = ordered.iterator() ; iter.hasNext(); ) {
|
||||
@ -1031,7 +1036,7 @@ public class Router {
|
||||
buf.append(key).append('=').append(val).append('\n');
|
||||
}
|
||||
}
|
||||
fos.write(buf.toString().getBytes());
|
||||
fos.write(buf.toString().getBytes("UTF-8"));
|
||||
} catch (IOException ioe) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error saving the config to " + _configFilename, ioe);
|
||||
|
@ -264,8 +264,12 @@ public class Shitlist {
|
||||
Hash key = e.getKey();
|
||||
Entry entry = e.getValue();
|
||||
buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
|
||||
buf.append(" expiring in ");
|
||||
buf.append(DataHelper.formatDuration(entry.expireOn-_context.clock().now()));
|
||||
long expires = entry.expireOn-_context.clock().now();
|
||||
if (expires < 5l*24*60*60*1000)
|
||||
buf.append(" Temporary ban expiring in ");
|
||||
else
|
||||
buf.append(" Banned until restart or in ");
|
||||
buf.append(DataHelper.formatDuration(expires));
|
||||
Set transports = entry.transports;
|
||||
if ( (transports != null) && (transports.size() > 0) )
|
||||
buf.append(" on the following transport: ").append(transports);
|
||||
|
@ -4,8 +4,9 @@ import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
@ -190,7 +191,7 @@ public class WorkingDir {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
in = new FileInputStream(oldFile);
|
||||
out = new PrintWriter(new BufferedWriter(new FileWriter(newFile)));
|
||||
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF-8")));
|
||||
out.println("# Modified by I2P User dir migration script");
|
||||
String s = null;
|
||||
while ((s = DataHelper.readLine(in)) != null) {
|
||||
@ -229,7 +230,7 @@ public class WorkingDir {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
in = new FileInputStream(oldFile);
|
||||
out = new PrintWriter(new BufferedWriter(new FileWriter(newFile)));
|
||||
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF-8")));
|
||||
String s = null;
|
||||
while ((s = DataHelper.readLine(in)) != null) {
|
||||
if (s.indexOf("./eepsite/") >= 0) {
|
||||
|
@ -368,7 +368,8 @@ public class EstablishState {
|
||||
if (diff >= Router.CLOCK_FUDGE_FACTOR) {
|
||||
_context.statManager().addRateData("ntcp.invalidOutboundSkew", diff, 0);
|
||||
_transport.markReachable(_con.getRemotePeer().calculateHash(), false);
|
||||
_context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(), "Outbound clock skew of " + diff + " ms");
|
||||
_context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(),
|
||||
"Excessive clock skew: " + DataHelper.formatDuration(diff));
|
||||
fail("Clocks too skewed (" + diff + " ms)", null, true);
|
||||
return;
|
||||
} else if (_log.shouldLog(Log.DEBUG)) {
|
||||
|
Reference in New Issue
Block a user