Changeset 60297f56
- Timestamp:
- Dec 13, 2011 9:19:32 PM (9 years ago)
- Branches:
- master
- Children:
- 27f0587
- Parents:
- c92c664
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/transport/GeoIP.java
rc92c664 r60297f56 19 19 import java.util.concurrent.atomic.AtomicBoolean; 20 20 21 import net.i2p.I2PAppContext; 21 22 import net.i2p.data.DataHelper; 22 23 import net.i2p.data.Hash; … … 42 43 class GeoIP { 43 44 private final Log _log; 45 // change to test with main() 46 //private final I2PAppContext _context; 44 47 private final RouterContext _context; 45 48 private final Map<String, String> _codeToName; … … 52 55 private int _lookupRunCount; 53 56 57 //public GeoIP(I2PAppContext context) { 54 58 public GeoIP(RouterContext context) { 55 59 _context = context; … … 219 223 try { 220 224 in = new FileInputStream(GeoFile); 221 StringBuilder buf = new StringBuilder(128); 222 while (DataHelper.readLine(in, buf) && idx < search.length) { 225 String buf = null; 226 BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1")); 227 while ((buf = br.readLine()) != null && idx < search.length) { 223 228 try { 224 229 if (buf.charAt(0) == '#') { 225 buf.setLength(0);226 230 continue; 227 231 } 228 String[] s = buf. toString().split(",");232 String[] s = buf.split(","); 229 233 long ip1 = Long.parseLong(s[0]); 230 234 long ip2 = Long.parseLong(s[1]); … … 243 247 } catch (NumberFormatException nfe) { 244 248 } 245 buf.setLength(0);246 249 } 247 250 } catch (IOException ioe) { … … 263 266 */ 264 267 private void updateOurCountry() { 268 /**** comment out to test with main() */ 265 269 String oldCountry = _context.router().getConfigSetting(PROP_IP_COUNTRY); 266 270 Hash ourHash = _context.routerHash(); … … 273 277 _context.router().saveConfig(); 274 278 } 279 /****/ 275 280 } 276 281 … … 357 362 for (int i = 0; i < tests.length; i++) 358 363 g.add(tests[i]); 364 long start = System.currentTimeMillis(); 359 365 g.blockingLookup(); 366 System.out.println("Lookup took " + (System.currentTimeMillis() - start)); 360 367 for (int i = 0; i < tests.length; i++) 361 368 System.out.println(tests[i] + " : " + g.get(tests[i]));
Note: See TracChangeset
for help on using the changeset viewer.