Changeset 606300a


Ignore:
Timestamp:
May 22, 2011 6:36:08 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4ea5622
Parents:
96cf5986
Message:
  • GeoIP: Read countries.txt in UTF-8
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r96cf5986 r606300a  
     12011-05-22 zzz
     2    * GeoIP: Read countries.txt in UTF-8
     3    * Jetty: Fix build error that omitted local jetty patches from org.mortbay.jetty.jar;
     4             affected 0.8.4 and 0.8.6 installers. Include jar in the updater for the next release.
     5
    162011-05-21 sponge
    27    * mbuild.sh document and fixes
  • router/java/src/net/i2p/router/RouterVersion.java

    r96cf5986 r606300a  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 2;
     21    public final static long BUILD = 3;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/GeoIP.java

    r96cf5986 r606300a  
    55 */
    66
     7import java.io.BufferedReader;
    78import java.io.IOException;
    89import java.io.File;
    910import java.io.FileInputStream;
    1011import java.net.InetAddress;
     12import java.io.InputStreamReader;
    1113import java.net.UnknownHostException;
    1214import java.util.Arrays;
     
    3840 */
    3941class GeoIP {
    40     private Log _log;
    41     private RouterContext _context;
     42    private final Log _log;
     43    private final RouterContext _context;
    4244    private final Map<String, String> _codeToName;
    4345    private final Map<Long, String> _IPToCountry;
     
    143145        File GeoFile = new File(_context.getBaseDir(), GEOIP_DIR_DEFAULT);
    144146        GeoFile = new File(GeoFile, COUNTRY_FILE_DEFAULT);
    145         if (GeoFile == null || (!GeoFile.exists())) {
     147        if (!GeoFile.exists()) {
    146148            if (_log.shouldLog(Log.WARN))
    147149                _log.warn("Country file not found: " + GeoFile.getAbsolutePath());
     
    151153        try {
    152154            in = new FileInputStream(GeoFile);
    153             StringBuilder buf = new StringBuilder(128);
    154             while (DataHelper.readLine(in, buf)) {
     155            BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
     156            String line = null;
     157            while ( (line = br.readLine()) != null) {
    155158                try {
    156                     if (buf.charAt(0) == '#') {
    157                         buf.setLength(0);
     159                    if (line.charAt(0) == '#') {
    158160                        continue;
    159161                    }
    160                     String[] s = buf.toString().split(",");
    161                     // todo convert name to mixed upper/lower case
     162                    String[] s = line.split(",");
    162163                    _codeToName.put(s[0].toLowerCase(), s[1]);
    163164                } catch (IndexOutOfBoundsException ioobe) {
    164165                }
    165                 buf.setLength(0);
    166166            }
    167167        } catch (IOException ioe) {
Note: See TracChangeset for help on using the changeset viewer.