Changeset be9523f


Ignore:
Timestamp:
Aug 17, 2009 10:14:39 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a9054a3
Parents:
66831c6
Message:
  • 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
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/java/src/addressbook/ConfigParser.java

    r66831c6 rbe9523f  
    4040 * format, and subscription file format.
    4141 *
     42 * TODO: Change file encoding from default to UTF-8?
     43 *       Or switch to the DataHelper loadProps/storeProps methods?
     44 *
    4245 * @author Ragnarok
    4346 */
  • apps/i2psnark/i2psnark.config

    r66831c6 rbe9523f  
     1# NOTE: This I2P config file must use UTF-8 encoding
    12#
    23# If you have a 'split' directory installation, with configuration
  • apps/routerconsole/jsp/logs.jsp

    r66831c6 rbe9523f  
    2020CPU <%=net.i2p.util.NativeBigInteger.cpuModel()%> (<%=net.i2p.util.NativeBigInteger.cpuType()%>)<br />
    2121jbigi <%=net.i2p.util.NativeBigInteger.loadStatus()%><br />
     22Encoding <%=System.getProperty("file.encoding")%><br>
    2223 </p>
    2324 <hr />
  • core/java/src/net/i2p/data/DataHelper.java

    r66831c6 rbe9523f  
    1818import java.io.File;
    1919import java.io.FileInputStream;
    20 import java.io.FileWriter;
     20import java.io.FileOutputStream;
    2121import java.io.IOException;
    2222import java.io.InputStream;
    2323import java.io.InputStreamReader;
    2424import java.io.OutputStream;
     25import java.io.OutputStreamWriter;
    2526import java.io.PrintWriter;
    2627import java.io.UnsupportedEncodingException;
     
    218219     * - Leading whitespace is not trimmed
    219220     * - '=' is the only key-termination character (not ':' or whitespace)
     221     *
     222     * Note that the escaping of \r or \n was probably a mistake and should be taken out.
     223     *
    220224     */
    221225    public static void loadProps(Properties props, File file) throws IOException {
     
    258262    }
    259263   
     264    /**
     265     * Note that this does not escape the \r or \n that are unescaped in loadProps() above.
     266     */
    260267    public static void storeProps(Properties props, File file) throws IOException {
    261268        PrintWriter out = null;
    262269        try {
    263             out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
     270            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")));
     271            out.println("# NOTE: This I2P config file must use UTF-8 encoding");
    264272            for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
    265273                String name = (String)iter.next();
  • installer/resources/clients.config

    r66831c6 rbe9523f  
     1# NOTE: This I2P config file must use UTF-8 encoding
    12#
    23# If you have a 'split' directory installation, with configuration
  • installer/resources/i2ptunnel.config

    r66831c6 rbe9523f  
     1# NOTE: This I2P config file must use UTF-8 encoding
    12#
    23# If you have a 'split' directory installation, with configuration
  • installer/resources/jetty.xml

    r66831c6 rbe9523f  
    1 <?xml version="1.0" encoding="ISO-8859-1" ?>
     1<?xml version="1.0" encoding="UTF-8" ?>
    22<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
    33
     
    2727<!-- Jetty errors and warnings will appear in wrapper.log, check there         -->
    2828<!-- to diagnose problems.                                                     -->
     29<!--                                                                           -->
     30<!-- Note that the XML encoding for this file is UTF-8.                        -->
     31<!--                                                                           -->
     32<!-- If you have a 'split' directory installation, with configuration          -->
     33<!-- files in ~/.i2p (Linux) or %APPDATA%\I2P (Windows), be sure to            -->
     34<!-- edit the file in the configuration directory, NOT the install directory.  -->
     35<!--                                                                           -->
    2936<!-- ========================================================================= -->
    3037
  • router/java/src/net/i2p/router/Router.java

    r66831c6 rbe9523f  
    10141014     * successful, false otherwise)
    10151015     *
     1016     * Note that unlike DataHelper.storeProps(),
     1017     * this does escape the \r or \n that are unescaped in DataHelper.loadProps().
     1018     * Note that the escaping of \r or \n was probably a mistake and should be taken out.
     1019     *
    10161020     */
    10171021    public boolean saveConfig() {
     
    10201024            fos = new FileOutputStream(_configFilename);
    10211025            StringBuilder buf = new StringBuilder(8*1024);
     1026            buf.append("# NOTE: This I2P config file must use UTF-8 encoding\n");
    10221027            synchronized (_config) {
    10231028                TreeSet ordered = new TreeSet(_config.keySet());
     
    10321037                }
    10331038            }
    1034             fos.write(buf.toString().getBytes());
     1039            fos.write(buf.toString().getBytes("UTF-8"));
    10351040        } catch (IOException ioe) {
    10361041            if (_log.shouldLog(Log.ERROR))
  • router/java/src/net/i2p/router/Shitlist.java

    r66831c6 rbe9523f  
    265265            Entry entry = e.getValue();
    266266            buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
    267             buf.append(" expiring in ");
    268             buf.append(DataHelper.formatDuration(entry.expireOn-_context.clock().now()));
     267            long expires = entry.expireOn-_context.clock().now();
     268            if (expires < 5l*24*60*60*1000)
     269                buf.append(" Temporary ban expiring in ");
     270            else
     271                buf.append(" Banned until restart or in ");
     272            buf.append(DataHelper.formatDuration(expires));
    269273            Set transports = entry.transports;
    270274            if ( (transports != null) && (transports.size() > 0) )
  • router/java/src/net/i2p/router/startup/WorkingDir.java

    r66831c6 rbe9523f  
    55import java.io.FileInputStream;
    66import java.io.FileOutputStream;
    7 import java.io.FileWriter;
     7import java.io.OutputStreamWriter;
    88import java.io.IOException;
     9import java.io.OutputStreamWriter;
    910import java.io.PrintWriter;
    1011import java.util.Properties;
     
    191192        try {
    192193            in = new FileInputStream(oldFile);
    193             out = new PrintWriter(new BufferedWriter(new FileWriter(newFile)));
     194            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF-8")));
    194195            out.println("# Modified by I2P User dir migration script");
    195196            String s = null;
     
    230231        try {
    231232            in = new FileInputStream(oldFile);
    232             out = new PrintWriter(new BufferedWriter(new FileWriter(newFile)));
     233            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF-8")));
    233234            String s = null;
    234235            while ((s = DataHelper.readLine(in)) != null) {
  • router/java/src/net/i2p/router/transport/ntcp/EstablishState.java

    r66831c6 rbe9523f  
    369369                    _context.statManager().addRateData("ntcp.invalidOutboundSkew", diff, 0);
    370370                    _transport.markReachable(_con.getRemotePeer().calculateHash(), false);
    371                     _context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(), "Outbound clock skew of " + diff + " ms");
     371                    _context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(),
     372                                                       "Excessive clock skew: " + DataHelper.formatDuration(diff));
    372373                    fail("Clocks too skewed (" + diff + " ms)", null, true);
    373374                    return;
Note: See TracChangeset for help on using the changeset viewer.