From 7bf1949061d8855a68bbd52c68841ce00fb64bde Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 26 Aug 2014 13:46:28 +0000 Subject: [PATCH 01/37] remove unused method --- apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index 0d2667d60..c79e274e0 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -265,6 +265,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { * Copy input stream to a byte array, so we can retry * @since 0.7.10 */ +/**** private static ByteArrayInputStream copyOfInputStream(InputStream is) throws IOException { byte[] buf = new byte[128]; ByteArrayOutputStream os = new ByteArrayOutputStream(768); @@ -279,6 +280,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { } return new ByteArrayInputStream(os.toByteArray()); } +****/ /** * Start running the I2PTunnelServer. From 3217b4ac906ad233110a76e5dd0309a706a8c292 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 26 Aug 2014 13:47:06 +0000 Subject: [PATCH 02/37] move radio buttons closer together thx Shinobiwan --- apps/i2ptunnel/jsp/editClient.jsp | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/i2ptunnel/jsp/editClient.jsp b/apps/i2ptunnel/jsp/editClient.jsp index 05c091b19..449f42949 100644 --- a/apps/i2ptunnel/jsp/editClient.jsp +++ b/apps/i2ptunnel/jsp/editClient.jsp @@ -341,6 +341,23 @@ input.default { width: 1px; height: 1px; visibility: hidden; }

+ +
+ +
+
+ + class="tickbox" /> +
+ <% } // !streamrclient %> + +
+
+
-
- -
-
- - class="tickbox" /> -
- <% } // !streamrclient %> - -
-
-
- <% if ("client".equals(tunnelType) || "ircclient".equals(tunnelType) || "socksirctunnel".equals(tunnelType) || "sockstunnel".equals(tunnelType)) { %>
diff --git a/apps/i2ptunnel/jsp/editServer.jsp b/apps/i2ptunnel/jsp/editServer.jsp index 6ceacc787..43b173503 100644 --- a/apps/i2ptunnel/jsp/editServer.jsp +++ b/apps/i2ptunnel/jsp/editServer.jsp @@ -79,7 +79,7 @@ input.default { width: 1px; height: 1px; visibility: hidden; } - +
<% } else { %>" /> - " /><% + " /><% } /* curPage 3 */ /* End page 3 */ %> @@ -484,7 +484,7 @@ - + <% if (!"streamrclient".equals(tunnelType)) { @@ -501,9 +501,9 @@ } if ("httpclient".equals(tunnelType) || "connectclient".equals(tunnelType) || "sockstunnel".equals(tunnelType) || "socksirctunnel".equals(tunnelType)) { %> - + - <% + <% } if ("httpclient".equals(tunnelType)) { %> Date: Tue, 2 Sep 2014 14:11:22 +0000 Subject: [PATCH 26/37] * CryptoChecker: Log tweaks, handle gij --- history.txt | 5 ++++ .../src/net/i2p/router/RouterVersion.java | 2 +- .../net/i2p/router/tasks/CryptoChecker.java | 29 ++++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/history.txt b/history.txt index 904a994da..474f1ec42 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,8 @@ +2014-08-31 zzz + * Build: Add support for bundling router infos in the package + * I2PTunnel: Allow changing of spoof host and target host/port without + restarting server tunnel + 2014-08-30 zzz * Console: - Re-enable plugin installation by default diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 7f4edb975..31c35f8c3 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 13; + public final static long BUILD = 14; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/tasks/CryptoChecker.java b/router/java/src/net/i2p/router/tasks/CryptoChecker.java index a870e887a..5cf80a9dc 100644 --- a/router/java/src/net/i2p/router/tasks/CryptoChecker.java +++ b/router/java/src/net/i2p/router/tasks/CryptoChecker.java @@ -1,7 +1,9 @@ package net.i2p.router.tasks; +import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; import net.i2p.crypto.SigType; import net.i2p.router.RouterContext; @@ -16,8 +18,9 @@ import net.i2p.util.SystemVersion; public class CryptoChecker { private static String JRE6 = "http://www.oracle.com/technetwork/java/javase/downloads/index.html"; - private static String JRE7 = "http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html"; - private static String JRE8 = "http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html"; + // these two are US-only and can change? + //private static String JRE7 = "http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html"; + //private static String JRE8 = "http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html"; public static void warnUnavailableCrypto(RouterContext ctx) { if (SystemVersion.isAndroid()) @@ -43,11 +46,11 @@ public class CryptoChecker { } if (!isUnlimited()) { String s = "Please consider installing the Java Cryptography Unlimited Strength Jurisdiction Policy Files from "; - if (SystemVersion.isJava8()) - s += JRE8; - else if (SystemVersion.isJava7()) - s += JRE7; - else + //if (SystemVersion.isJava8()) + // s += JRE8; + //else if (SystemVersion.isJava7()) + // s += JRE7; + //else s += JRE6; log.logAlways(log.WARN, s); System.out.println(s); @@ -59,9 +62,7 @@ public class CryptoChecker { } /** - * Following code adapted from Orchid - * According to http://www.subgraph.com/orchid.html , - * "Orchid is licensed under a three-clause BSD license." + * Copied from CryptixAESEngine */ private static boolean isUnlimited() { try { @@ -70,6 +71,14 @@ public class CryptoChecker { } catch (NoSuchAlgorithmException e) { return false; } catch (NoSuchMethodError e) { + // JamVM, gij + try { + Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); + SecretKeySpec key = new SecretKeySpec(new byte[32], "AES"); + cipher.init(Cipher.ENCRYPT_MODE, key); + } catch (GeneralSecurityException gse) { + return false; + } } return true; } From f87ebaf214c73368e138b7777b4b0c3f45edc02b Mon Sep 17 00:00:00 2001 From: kytv Date: Tue, 2 Sep 2014 20:54:49 +0000 Subject: [PATCH 27/37] re-enable i2p.mooo.com (ticket #1351) --- .../java/src/net/i2p/router/networkdb/reseed/Reseeder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java index f2c6fb864..b25641e0a 100644 --- a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java +++ b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java @@ -74,8 +74,7 @@ public class Reseeder { "http://reseed.i2p-projekt.de/" + "," + //"http://euve5653.vserver.de/netDb/" + "," + "http://cowpuncher.drollette.com/netdb/" + "," + - //Temp disabled (#1351) - //"http://i2p.mooo.com/netDb/" + "," + + "http://i2p.mooo.com/netDb/" + "," + "http://193.150.121.66/netDb/" + "," + "http://netdb.i2p2.no/" + "," + "http://reseed.info/" + "," + @@ -93,8 +92,7 @@ public class Reseeder { "https://reseed.i2p-projekt.de/" + "," + //"https://euve5653.vserver.de/netDb/" + "," + "https://cowpuncher.drollette.com/netdb/" + "," + - //Temp disabled (#1351) - //"https://i2p.mooo.com/netDb/" + "," + + "https://i2p.mooo.com/netDb/" + "," + "https://193.150.121.66/netDb/" + "," + "https://netdb.i2p2.no/" + "," + "https://reseed.info/" + "," + From ca7873eda78b58aa5a4874289a1ab456a62b8dd8 Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 3 Sep 2014 13:22:56 +0000 Subject: [PATCH 28/37] CryptoChecker: add main() --- .../net/i2p/router/tasks/CryptoChecker.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/router/java/src/net/i2p/router/tasks/CryptoChecker.java b/router/java/src/net/i2p/router/tasks/CryptoChecker.java index 5cf80a9dc..9e110bd93 100644 --- a/router/java/src/net/i2p/router/tasks/CryptoChecker.java +++ b/router/java/src/net/i2p/router/tasks/CryptoChecker.java @@ -22,6 +22,9 @@ public class CryptoChecker { //private static String JRE7 = "http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html"; //private static String JRE8 = "http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html"; + /** + * @param ctx if null, logs only to System.out (called from main) + */ public static void warnUnavailableCrypto(RouterContext ctx) { if (SystemVersion.isAndroid()) return; @@ -31,17 +34,20 @@ public class CryptoChecker { if (!t.isAvailable()) { if (!unavail) { unavail = true; - log = ctx.logManager().getLog(CryptoChecker.class); + if (ctx != null) + log = ctx.logManager().getLog(CryptoChecker.class); } String s = "Crypto " + t + " is not available"; - log.logAlways(log.WARN, s); + if (log != null) + log.logAlways(log.WARN, s); System.out.println("Warning: " + s); } } if (unavail) { if (!SystemVersion.isJava7()) { String s = "Java version: " + System.getProperty("java.version") + " Please consider upgrading to Java 7"; - log.logAlways(log.WARN, s); + if (log != null) + log.logAlways(log.WARN, s); System.out.println(s); } if (!isUnlimited()) { @@ -52,12 +58,17 @@ public class CryptoChecker { // s += JRE7; //else s += JRE6; - log.logAlways(log.WARN, s); + if (log != null) + log.logAlways(log.WARN, s); System.out.println(s); } String s = "This crypto will be required in a future release"; - log.logAlways(log.WARN, s); + if (log != null) + log.logAlways(log.WARN, s); System.out.println("Warning: " + s); + } else if (ctx == null) { + // called from main() + System.out.println("All crypto available"); } } @@ -82,5 +93,9 @@ public class CryptoChecker { } return true; } + + public static void main(String[] args) { + warnUnavailableCrypto(null); + } } From f84b86a7523d645b305419ba641372d25896c924 Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 3 Sep 2014 15:19:18 +0000 Subject: [PATCH 29/37] * BundleRouterInfos: - Move to its own class - Run GeoIP, exclude bad countries - Exclude class K - Exclude dup IPs - GeoIP mods for use in I2PAppContext --- .../networkdb/kademlia/BundleRouterInfos.java | 249 ++++++++++++++++++ .../kademlia/PersistentDataStore.java | 177 +------------ .../i2p/router/transport/BadCountries.java | 2 +- .../src/net/i2p/router/transport/GeoIP.java | 42 +-- 4 files changed, 281 insertions(+), 189 deletions(-) create mode 100644 router/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java b/router/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java new file mode 100644 index 000000000..ebcde49c6 --- /dev/null +++ b/router/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java @@ -0,0 +1,249 @@ +package net.i2p.router.networkdb.kademlia; +/* + * free (adj.): unencumbered; not under the control of others + * Written by jrandom in 2003 and released into the public domain + * with no warranty of any kind, either expressed or implied. + * It probably won't make your computer catch on fire, or eat + * your children, but it might. Use at your own risk. + * + */ + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import gnu.getopt.Getopt; + +import net.i2p.I2PAppContext; +import net.i2p.data.Hash; +import net.i2p.data.RouterAddress; +import net.i2p.data.RouterInfo; +import net.i2p.router.transport.BadCountries; +import net.i2p.router.transport.GeoIP; +import net.i2p.util.FileUtil; + +/** + * Copy a random selection of 'count' router infos from configDir/netDb + * to 'toDir'. Skip your own router info, and old, hidden, unreachable, and + * introduced routers, and those from bad countries. + * + * Used in the build process. + * + * @since 0.9.15 + * + */ +public class BundleRouterInfos { + + /** + * Usage: PersistentDataStore -i configDir -o toDir -c count + * + * Copy a random selection of 'count' router infos from configDir/netDb + * to 'toDir'. Skip your own router info, and old, hidden, unreachable, and + * introduced routers, and those from bad countries. + * + * @since 0.9.15 + */ + public static void main(String[] args) { + Getopt g = new Getopt("PersistentDataStore", args, "i:o:c:"); + String in = System.getProperty("user.home") + "/.i2p"; + String out = "netDb"; + int count = 200; + boolean error = false; + int c; + while ((c = g.getopt()) != -1) { + switch (c) { + case 'i': + in = g.getOptarg(); + break; + + case 'o': + out = g.getOptarg(); + break; + + case 'c': + String scount = g.getOptarg(); + try { + count = Integer.parseInt(scount); + } catch (NumberFormatException nfe) { + error = true; + } + break; + + case '?': + case ':': + default: + error = true; + } + } + if (error) { + usage(); + System.exit(1); + } + + Properties props = new Properties(); + props.setProperty(GeoIP.PROP_GEOIP_DIR, System.getProperty("user.dir") + "/installer/resources"); + GeoIP geoIP = new GeoIP(new I2PAppContext(props)); + + File confDir = new File(in); + File dbDir = new File(confDir, "netDb"); + if (!dbDir.exists()) { + System.out.println("NetDB directory " + dbDir + " does not exist"); + System.exit(1); + } + File myFile = new File(confDir, "router.info"); + File toDir = new File(out); + toDir.mkdirs(); + InputStream fis = null; + Hash me = null; + try { + fis = new BufferedInputStream(new FileInputStream(myFile)); + RouterInfo ri = new RouterInfo(); + ri.readBytes(fis, true); // true = verify sig on read + me = ri.getIdentity().getHash(); + } catch (Exception e) { + //System.out.println("Can't determine our identity"); + } finally { + if (fis != null) try { fis.close(); } catch (IOException ioe) {} + } + + int routerCount = 0; + List toRead = new ArrayList(2048); + for (int j = 0; j < PersistentDataStore.B64.length(); j++) { + File subdir = new File(dbDir, PersistentDataStore.DIR_PREFIX + PersistentDataStore.B64.charAt(j)); + File[] files = subdir.listFiles(PersistentDataStore.RouterInfoFilter.getInstance()); + if (files == null) + continue; + routerCount += files.length; + for (int i = 0; i < files.length; i++) { + toRead.add(files[i]); + } + } + if (toRead.isEmpty()) { + System.out.println("No files to copy in " + dbDir); + System.exit(1); + } + Collections.shuffle(toRead); + int copied = 0; + long tooOld = System.currentTimeMillis() - 7*24*60*60*1000L; + Map ipMap = new HashMap(count); + for (File file : toRead) { + if (copied >= count) + break; + Hash key = PersistentDataStore.getRouterInfoHash(file.getName()); + if (key == null) { + System.out.println("Skipping bad " + file); + continue; + } + if (key.equals(me)) { + System.out.println("Skipping my RI"); + continue; + } + fis = null; + try { + fis = new BufferedInputStream(new FileInputStream(file)); + RouterInfo ri = new RouterInfo(); + ri.readBytes(fis, true); // true = verify sig on read + try { fis.close(); } catch (IOException ioe) {} + fis = null; + if (ri.getPublished() < tooOld) { + System.out.println("Skipping too old " + key); + continue; + } + if (ri.getCapabilities().contains("U")) { + System.out.println("Skipping unreachable " + key); + continue; + } + if (ri.getCapabilities().contains("K")) { + System.out.println("Skipping slow " + key); + continue; + } + Collection addrs = ri.getAddresses(); + if (addrs.isEmpty()) { + System.out.println("Skipping hidden " + key); + continue; + } + boolean hasIntro = false; + boolean hasIPv4 = false; + boolean dupIP = false; + for (RouterAddress addr : addrs) { + if ("SSU".equals(addr.getTransportStyle()) && addr.getOption("ihost0") != null) { + hasIntro = true; + break; + } + String host = addr.getHost(); + if (host != null && host.contains(".")) { + hasIPv4 = true; + geoIP.add(host); + String old = ipMap.put(host, file.getName()); + if (old != null && !old.equals(file.getName())) { + dupIP = true; + break; + } + } + } + if (dupIP) { + System.out.println("Skipping dup IP " + key); + continue; + } + if (hasIntro) { + System.out.println("Skipping introduced " + key); + continue; + } + if (!hasIPv4) { + System.out.println("Skipping IPv6-only " + key); + continue; + } + File toFile = new File(toDir, file.getName()); + // We could call ri.write() to avoid simultaneous change by the router + boolean ok = FileUtil.copy(file, toFile, true, true); + if (ok) + copied++; + else + System.out.println("Failed copy of " + file + " to " + toDir); + } catch (Exception e) { + System.out.println("Skipping bad " + file); + } finally { + if (fis != null) try { fis.close(); } catch (IOException ioe) {} + } + } + if (copied > 0) { + // now do all the geoip lookups, and delete any bad countries + geoIP.blockingLookup(); + for (Map.Entry e : ipMap.entrySet()) { + String co = geoIP.get(e.getKey()); + if (co != null) { + if (BadCountries.contains(co)) { + String name = e.getValue(); + File toFile = new File(toDir, name); + if (toFile.delete()) { + String full = geoIP.fullName(co); + if (full == null) + full = co; + System.out.println("Skipping " + full + ": " + name); + copied--; + } + } + } + } + } + if (copied > 0) { + System.out.println("Copied " + copied + " router info files to " + toDir); + } else { + System.out.println("Failed to copy any files to " + toDir); + System.exit(1); + } + } + + private static void usage() { + System.err.println("Usage: PersistentDataStore [-i $HOME/.i2p] [-o netDb/] [-c 200]"); + } +} diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java index 5e8d863e1..620679b7e 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -26,13 +25,10 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.concurrent.ConcurrentHashMap; -import gnu.getopt.Getopt; - import net.i2p.data.Base64; import net.i2p.data.DatabaseEntry; import net.i2p.data.DataFormatException; import net.i2p.data.Hash; -import net.i2p.data.RouterAddress; import net.i2p.data.RouterInfo; import net.i2p.router.JobImpl; import net.i2p.router.Router; @@ -58,8 +54,8 @@ class PersistentDataStore extends TransientDataStore { private final static int READ_DELAY = 2*60*1000; private static final String PROP_FLAT = "router.networkDatabase.flat"; - private static final String DIR_PREFIX = "r"; - private static final String B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-~"; + static final String DIR_PREFIX = "r"; + static final String B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-~"; /** * @param dbDir relative path @@ -618,7 +614,7 @@ class PersistentDataStore extends TransientDataStore { return DIR_PREFIX + b64.charAt(0) + File.separatorChar + ROUTERINFO_PREFIX + b64 + ROUTERINFO_SUFFIX; } - private static Hash getRouterInfoHash(String filename) { + static Hash getRouterInfoHash(String filename) { return getHash(filename, ROUTERINFO_PREFIX, ROUTERINFO_SUFFIX); } @@ -655,7 +651,7 @@ class PersistentDataStore extends TransientDataStore { } } - private final static class RouterInfoFilter implements FilenameFilter { + static class RouterInfoFilter implements FilenameFilter { private static final FilenameFilter _instance = new RouterInfoFilter(); public static final FilenameFilter getInstance() { return _instance; } public boolean accept(File dir, String name) { @@ -664,169 +660,4 @@ class PersistentDataStore extends TransientDataStore { return (name.startsWith(ROUTERINFO_PREFIX.toUpperCase(Locale.US)) && name.endsWith(ROUTERINFO_SUFFIX.toUpperCase(Locale.US))); } } - - /** - * Usage: PersistentDataStore -i configDir -o toDir -c count - * - * Copy a random selection of 'count' router infos from configDir/netDb - * to 'toDir'. Skip your own router info, and old, hidden, unreachable, and - * introduced routers. - * - * Used in the build process, do not comment out. - * - * @since 0.9.15 - */ - public static void main(String[] args) { - Getopt g = new Getopt("PersistentDataStore", args, "i:o:c:"); - String in = System.getProperty("user.home") + "/.i2p"; - String out = "netDb"; - int count = 200; - boolean error = false; - int c; - while ((c = g.getopt()) != -1) { - switch (c) { - case 'i': - in = g.getOptarg(); - break; - - case 'o': - out = g.getOptarg(); - break; - - case 'c': - String scount = g.getOptarg(); - try { - count = Integer.parseInt(scount); - } catch (NumberFormatException nfe) { - error = true; - } - break; - - case '?': - case ':': - default: - error = true; - } - } - if (error) { - usage(); - System.exit(1); - } - - File confDir = new File(in); - File dbDir = new File(confDir, "netDb"); - if (!dbDir.exists()) { - System.out.println("NetDB directory " + dbDir + " does not exist"); - System.exit(1); - } - File myFile = new File(confDir, "router.info"); - File toDir = new File(out); - toDir.mkdirs(); - InputStream fis = null; - Hash me = null; - try { - fis = new BufferedInputStream(new FileInputStream(myFile)); - RouterInfo ri = new RouterInfo(); - ri.readBytes(fis, true); // true = verify sig on read - me = ri.getIdentity().getHash(); - } catch (Exception e) { - //System.out.println("Can't determine our identity"); - } finally { - if (fis != null) try { fis.close(); } catch (IOException ioe) {} - } - - int routerCount = 0; - List toRead = new ArrayList(2048); - for (int j = 0; j < B64.length(); j++) { - File subdir = new File(dbDir, DIR_PREFIX + B64.charAt(j)); - File[] files = subdir.listFiles(RouterInfoFilter.getInstance()); - if (files == null) - continue; - routerCount += files.length; - for (int i = 0; i < files.length; i++) { - toRead.add(files[i]); - } - } - if (toRead.isEmpty()) { - System.out.println("No files to copy in " + dbDir); - System.exit(1); - } - Collections.shuffle(toRead); - int copied = 0; - long tooOld = System.currentTimeMillis() - 7*24*60*60*1000L; - for (File file : toRead) { - if (copied >= count) - break; - Hash key = getRouterInfoHash(file.getName()); - if (key == null) { - System.out.println("Skipping bad " + file); - continue; - } - if (key.equals(me)) { - System.out.println("Skipping my RI"); - continue; - } - fis = null; - try { - fis = new BufferedInputStream(new FileInputStream(file)); - RouterInfo ri = new RouterInfo(); - ri.readBytes(fis, true); // true = verify sig on read - try { fis.close(); } catch (IOException ioe) {} - fis = null; - if (ri.getPublished() < tooOld) { - System.out.println("Skipping too old " + key); - continue; - } - if (ri.getCapabilities().contains("U")) { - System.out.println("Skipping unreachable " + key); - continue; - } - Collection addrs = ri.getAddresses(); - if (addrs.isEmpty()) { - System.out.println("Skipping hidden " + key); - continue; - } - boolean hasIntro = false; - boolean hasIPv4 = false; - for (RouterAddress addr : addrs) { - if ("SSU".equals(addr.getTransportStyle()) && addr.getOption("ihost0") != null) { - hasIntro = true; - break; - } - String host = addr.getHost(); - if (host != null && host.contains(".")) - hasIPv4 = true; - } - if (hasIntro) { - System.out.println("Skipping introduced " + key); - continue; - } - if (!hasIPv4) { - System.out.println("Skipping IPv6-only " + key); - continue; - } - File toFile = new File(toDir, file.getName()); - // We could call ri.write() to avoid simultaneous change by the router - boolean ok = FileUtil.copy(file, toFile, true, true); - if (ok) - copied++; - else - System.out.println("Failed copy of " + file + " to " + toDir); - } catch (Exception e) { - System.out.println("Skipping bad " + file); - } finally { - if (fis != null) try { fis.close(); } catch (IOException ioe) {} - } - } - if (copied > 0) { - System.out.println("Copied " + copied + " router info files to " + toDir); - } else { - System.out.println("Failed to copy any files to " + toDir); - System.exit(1); - } - } - - private static void usage() { - System.err.println("Usage: PersistentDataStore [-i $HOME/.i2p] [-o netDb/] [-c 200]"); - } } diff --git a/router/java/src/net/i2p/router/transport/BadCountries.java b/router/java/src/net/i2p/router/transport/BadCountries.java index 4a85f2644..dc848d859 100644 --- a/router/java/src/net/i2p/router/transport/BadCountries.java +++ b/router/java/src/net/i2p/router/transport/BadCountries.java @@ -9,7 +9,7 @@ import java.util.Set; * Maintain a list of bad places. * @since 0.8.13 */ -abstract class BadCountries { +public abstract class BadCountries { private static final Set _countries; diff --git a/router/java/src/net/i2p/router/transport/GeoIP.java b/router/java/src/net/i2p/router/transport/GeoIP.java index 3f0990dd3..e379ce05f 100644 --- a/router/java/src/net/i2p/router/transport/GeoIP.java +++ b/router/java/src/net/i2p/router/transport/GeoIP.java @@ -16,6 +16,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; +import net.i2p.I2PAppContext; import net.i2p.data.Hash; import net.i2p.router.Router; import net.i2p.router.RouterContext; @@ -38,11 +39,9 @@ import net.i2p.util.Log; * * @author zzz */ -class GeoIP { +public class GeoIP { private final Log _log; - // change to test with main() - //private final I2PAppContext _context; - private final RouterContext _context; + private final I2PAppContext _context; private final Map _codeToName; /** code to itself to prevent String proliferation */ private final Map _codeCache; @@ -56,8 +55,10 @@ class GeoIP { private final AtomicBoolean _lock; private int _lookupRunCount; - //public GeoIP(I2PAppContext context) { - public GeoIP(RouterContext context) { + /** + * @param context RouterContext in production, I2PAppContext for testing only + */ + public GeoIP(I2PAppContext context) { _context = context; _log = context.logManager().getLog(GeoIP.class); _codeToName = new ConcurrentHashMap(512); @@ -71,6 +72,7 @@ class GeoIP { } static final String PROP_GEOIP_ENABLED = "routerconsole.geoip.enable"; + public static final String PROP_GEOIP_DIR = "geoip.dir"; static final String GEOIP_DIR_DEFAULT = "geoip"; static final String GEOIP_FILE_DEFAULT = "geoip.txt"; static final String COUNTRY_FILE_DEFAULT = "countries.txt"; @@ -187,7 +189,10 @@ class GeoIP { * */ private void readCountryFile() { - File geoFile = new File(_context.getBaseDir(), GEOIP_DIR_DEFAULT); + String geoDir = _context.getProperty(PROP_GEOIP_DIR, GEOIP_DIR_DEFAULT); + File geoFile = new File(geoDir); + if (!geoFile.isAbsolute()) + geoFile = new File(_context.getBaseDir(), geoDir); geoFile = new File(geoFile, COUNTRY_FILE_DEFAULT); if (!geoFile.exists()) { if (_log.shouldLog(Log.WARN)) @@ -246,7 +251,10 @@ class GeoIP { * */ private String[] readGeoIPFile(Long[] search) { - File geoFile = new File(_context.getBaseDir(), GEOIP_DIR_DEFAULT); + String geoDir = _context.getProperty(PROP_GEOIP_DIR, GEOIP_DIR_DEFAULT); + File geoFile = new File(geoDir); + if (!geoFile.isAbsolute()) + geoFile = new File(_context.getBaseDir(), geoDir); geoFile = new File(geoFile, GEOIP_FILE_DEFAULT); if (!geoFile.exists()) { if (_log.shouldLog(Log.WARN)) @@ -300,24 +308,28 @@ class GeoIP { /** * Put our country code in the config, where others (such as Timestamper) can get it, * and it will be there next time at startup. + * + * Does nothing in I2PAppContext */ private void updateOurCountry() { - /**** comment out to test with main() */ - String oldCountry = _context.router().getConfigSetting(PROP_IP_COUNTRY); - Hash ourHash = _context.routerHash(); + if (! (_context instanceof RouterContext)) + return; + RouterContext ctx = (RouterContext) _context; + String oldCountry = ctx.router().getConfigSetting(PROP_IP_COUNTRY); + Hash ourHash = ctx.routerHash(); // we should always have a RouterInfo by now, but we had one report of an NPE here if (ourHash == null) return; - String country = _context.commSystem().getCountry(ourHash); + String country = ctx.commSystem().getCountry(ourHash); if (country != null && !country.equals(oldCountry)) { - _context.router().saveConfig(PROP_IP_COUNTRY, country); - if (_context.commSystem().isInBadCountry() && _context.getProperty(Router.PROP_HIDDEN_HIDDEN) == null) { + ctx.router().saveConfig(PROP_IP_COUNTRY, country); + if (ctx.commSystem().isInBadCountry() && ctx.getProperty(Router.PROP_HIDDEN_HIDDEN) == null) { String name = fullName(country); if (name == null) name = country; _log.logAlways(Log.WARN, "Setting hidden mode to protect you in " + name + ", you may override on the network configuration page"); - _context.router().rebuildRouterInfo(); + ctx.router().rebuildRouterInfo(); } } /****/ From 86935f10a8978308c3a2c44c993a6b91b0d05e85 Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 4 Sep 2014 15:14:33 +0000 Subject: [PATCH 30/37] update link --- core/java/src/net/i2p/util/NativeBigInteger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/src/net/i2p/util/NativeBigInteger.java b/core/java/src/net/i2p/util/NativeBigInteger.java index 1b28397f7..fd307ceec 100644 --- a/core/java/src/net/i2p/util/NativeBigInteger.java +++ b/core/java/src/net/i2p/util/NativeBigInteger.java @@ -475,7 +475,7 @@ public class NativeBigInteger extends BigInteger { } if (!_nativeOk) { warn("Native BigInteger library jbigi not loaded - using pure Java - " + - "poor performance may result - see http://www.i2p2.i2p/jbigi for help"); + "poor performance may result - see http://i2p-projekt.i2p/jbigi for help"); } } catch(Exception e) { warn("Native BigInteger library jbigi not loaded, using pure java", e); From 0f1036b0e1f72a6dc536fe038b14c514c94cffe6 Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 4 Sep 2014 15:21:03 +0000 Subject: [PATCH 31/37] better message on EOF reading data --- core/java/src/net/i2p/data/SimpleDataStructure.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/src/net/i2p/data/SimpleDataStructure.java b/core/java/src/net/i2p/data/SimpleDataStructure.java index 441bcffac..3983be17d 100644 --- a/core/java/src/net/i2p/data/SimpleDataStructure.java +++ b/core/java/src/net/i2p/data/SimpleDataStructure.java @@ -81,7 +81,9 @@ public abstract class SimpleDataStructure extends DataStructureImpl { int length = length(); _data = new byte[length]; int read = read(in, _data); - if (read != length) throw new DataFormatException("Not enough bytes to read the data"); + if (read != length) + throw new DataFormatException("EOF reading " + getClass().getSimpleName() + + ", read: " + read + ", required: " + length); } public void writeBytes(OutputStream out) throws DataFormatException, IOException { From 84ad155ab8b507c50e02efc1c3d004e127f7535b Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 6 Sep 2014 18:21:41 +0000 Subject: [PATCH 32/37] remove extraneous trailing whitespace --- installer/resources/certificates/reseed/swat_at_mail.i2p.crt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/resources/certificates/reseed/swat_at_mail.i2p.crt b/installer/resources/certificates/reseed/swat_at_mail.i2p.crt index 60659598c..276c8be36 100644 --- a/installer/resources/certificates/reseed/swat_at_mail.i2p.crt +++ b/installer/resources/certificates/reseed/swat_at_mail.i2p.crt @@ -1,4 +1,4 @@ ------BEGIN CERTIFICATE----- +-----BEGIN CERTIFICATE----- MIIFVjCCAz6gAwIBAgIEU71jgDANBgkqhkiG9w0BAQ0FADBtMQswCQYDVQQGEwJY WDELMAkGA1UECBMCWFgxCzAJBgNVBAcTAlhYMR4wHAYDVQQKExVJMlAgQW5vbnlt b3VzIE5ldHdvcmsxDDAKBgNVBAsTA0kyUDEWMBQGA1UEAwwNc3dhdEBtYWlsLmky From 3c95144b8380d85eddd720fe554f406833aa42e2 Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 6 Sep 2014 22:10:15 +0000 Subject: [PATCH 33/37] close tag --- installer/resources/eepsite/docroot/help/index_na.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/resources/eepsite/docroot/help/index_na.html b/installer/resources/eepsite/docroot/help/index_na.html index 7a5edc3ba..06da52e89 100644 --- a/installer/resources/eepsite/docroot/help/index_na.html +++ b/installer/resources/eepsite/docroot/help/index_na.html @@ -10,7 +10,7 @@

I2P Anonymous Webserver

-EnglishEnglish 中文 Deutsch Español From 80d6921a66ce4f74aa9d489547edd48cbd0b983f Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 6 Sep 2014 22:11:06 +0000 Subject: [PATCH 34/37] fix certificate line endings --- .../certificates/ssl/i2p.mooo.com.crt | 46 +++++++++---------- .../certificates/ssl/reseed.info.crt | 40 ++++++++-------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/installer/resources/certificates/ssl/i2p.mooo.com.crt b/installer/resources/certificates/ssl/i2p.mooo.com.crt index 4be89d6af..ac10e1ff4 100644 --- a/installer/resources/certificates/ssl/i2p.mooo.com.crt +++ b/installer/resources/certificates/ssl/i2p.mooo.com.crt @@ -1,23 +1,23 @@ ------BEGIN CERTIFICATE----- -MIIDvjCCAyegAwIBAgICZhcwDQYJKoZIhvcNAQEFBQAwdTELMAkGA1UEBhMCVVMx -DTALBgNVBAgMBG5vbmUxDTALBgNVBAcMBG5vbmUxDTALBgNVBAoMBG5vbmUxDTAL -BgNVBAsMBG5vbmUxFTATBgNVBAMMDGkycC5tb29vLmNvbTETMBEGCSqGSIb3DQEJ -ARYEbm9uZTAeFw0xMTEwMjMyMTM2NDFaFw0xOTEwMjMyMTM2NDFaMGYxCzAJBgNV -BAYTAlVTMQ0wCwYDVQQIDARub25lMQ0wCwYDVQQKDARub25lMQ0wCwYDVQQLDARu -b25lMRUwEwYDVQQDDAxpMnAubW9vby5jb20xEzARBgkqhkiG9w0BCQEWBG5vbmUw -ggGPMA0GCSqGSIb3DQEBAQUAA4IBfAAwggF3AoIBbgMG1O7HRVa7UoiKbQTmKy5m -x79Na8vjD3etcOwfc4TSenQFvn+GbAWkJwKpM8uvOcgj1CxNeHWdSaeTFH1OwJsw -vl3leJ7clMdo3hpQDhPeGzBLyOiWwFHVn15YKa9xcM7S9Op5Q6rKBHUyyx1vGSz+ -/NBmkktpI6rcGFfP3ISRL0auR+db+adWv4TS6W8YiwQIVZNbSlKP6FNO9Mv1kxQZ -KoHPn8vT/LtAh1fcI6ryBuy3F5oHfbGumIwsS5dpowryFxQzwg5vtMA7AMCMKyXv -hP/W6OuaaEP5MCIxkWjQs35gOYa8eF1dLoy3AD9yVVhoNrA8Bc5FnVFJ32Qv7ag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eTFH1OwJsw +vl3leJ7clMdo3hpQDhPeGzBLyOiWwFHVn15YKa9xcM7S9Op5Q6rKBHUyyx1vGSz+ +/NBmkktpI6rcGFfP3ISRL0auR+db+adWv4TS6W8YiwQIVZNbSlKP6FNO9Mv1kxQZ +KoHPn8vT/LtAh1fcI6ryBuy3F5oHfbGumIwsS5dpowryFxQzwg5vtMA7AMCMKyXv +hP/W6OuaaEP5MCIxkWjQs35gOYa8eF1dLoy3AD9yVVhoNrA8Bc5FnVFJ32Qv7agy +qRY85cXBA6hT/Qzs/wWwp7WrrnZuifaSv/u/Ayi5vX42/bf86PSM2IRNIESoA98A +NFz4U2KGq9s1K2JbkQmnFy8IU0w7CMq6PvNEm/uNjSk6OE1rcCXML+EuX0zmXy8d +PjRbLzC9csSg2CqMtQIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQf +Fh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUdjuOczdG +hUpYzH0UXqKrOleT8GkwHwYDVR0jBBgwFoAU+SKWC49cM5sCodv89AFin3pkS0Yw +DQYJKoZIhvcNAQEFBQADgYEAKYyWlDIStjjbn/ZzVScKR174I8whTbdqrX/vp9dr +2hMv5m4F+aswX4Jr58WneKg2LvRaL6xEhoL7OAQ6aB/7xVSpDjIrrBLZd513NAam +X6bOPYJ6IH7Vw9ClFY3AlfzsNlgRMXno7rySKKzhg24kusNwKDH2yCphZy4BgjMn +y6A= +-----END CERTIFICATE----- diff --git a/installer/resources/certificates/ssl/reseed.info.crt b/installer/resources/certificates/ssl/reseed.info.crt index 83d1a33e3..31302c52b 100644 --- a/installer/resources/certificates/ssl/reseed.info.crt +++ b/installer/resources/certificates/ssl/reseed.info.crt @@ -1,20 +1,20 @@ ------BEGIN CERTIFICATE----- -MIIDRDCCAiwCCQDCm/Zrmali9zANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJB -VTETMBEGA1UECBMKU29tZS1Td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0ugMTAxS2NmtVahwAqa2IjpqR7aEQ2wLvxQzDqrXo93L93+b2FKRUQXH +Duud/n/w0kVV3DaIGikOsJayoanR+9HD +-----END CERTIFICATE----- From c4d7f9924f9b783260a5fc20767520be7257cd35 Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 6 Sep 2014 22:14:06 +0000 Subject: [PATCH 35/37] checkcerts.sh: check for extraneous spaces (trying to catch the problem noted at http://zzz.i2p/topics/1663) --- tests/scripts/checkcerts.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/scripts/checkcerts.sh b/tests/scripts/checkcerts.sh index 55820a213..0a0f69872 100755 --- a/tests/scripts/checkcerts.sh +++ b/tests/scripts/checkcerts.sh @@ -164,6 +164,14 @@ do else compute_dates fi + if grep '\s$' $i > /dev/null 2>&1; then + echo "********* Trailing whitespace found in file $i *********" + FAIL=1 + fi + if grep '^\s' $i > /dev/null 2>&1; then + echo "********* Leading whitespace found in file $i *********" + FAIL=1 + fi done if [ -n "$FAIL" ]; then From 00bd469f8e66110dcfba716e826deb8fb4f5a009 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 9 Sep 2014 16:13:49 +0000 Subject: [PATCH 36/37] bump -15-rc --- router/java/src/net/i2p/router/RouterVersion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 31c35f8c3..25340f779 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,10 +18,10 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 14; + public final static long BUILD = 15; /** for example "-test" */ - public final static String EXTRA = ""; + public final static String EXTRA = "-rc"; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public static void main(String args[]) { System.out.println("I2P Router version: " + FULL_VERSION); From 09dfea7dea9284a2192e97f8d666bc2859591282 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 9 Sep 2014 19:23:12 +0000 Subject: [PATCH 37/37] * i2psnark: Escape fixes - fix ':' in name (again) - Change priority key from file name to file number so we don't hav to escape --- .../java/src/org/klomp/snark/Storage.java | 54 +++++++++++-------- .../org/klomp/snark/web/I2PSnarkServlet.java | 19 +++---- .../java/src/org/klomp/snark/web/URIUtil.java | 7 +++ history.txt | 3 ++ .../src/net/i2p/router/RouterVersion.java | 2 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/apps/i2psnark/java/src/org/klomp/snark/Storage.java b/apps/i2psnark/java/src/org/klomp/snark/Storage.java index edcab93cb..04b9f7c11 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/Storage.java +++ b/apps/i2psnark/java/src/org/klomp/snark/Storage.java @@ -316,15 +316,34 @@ public class Storage } /** + * Get index to pass to remaining(), getPriority(), setPriority() + * * @param file non-canonical path (non-directory) + * @return internal index of file; -1 if unknown file + * @since 0.9.15 + */ + public int indexOf(File file) { + for (int i = 0; i < _torrentFiles.size(); i++) { + File f = _torrentFiles.get(i).RAFfile; + if (f.equals(file)) + return i; + } + return -1; + } + + /** + * @param fileIndex as obtained from indexOf * @return number of bytes remaining; -1 if unknown file * @since 0.7.14 */ - public long remaining(File file) { + public long remaining(int fileIndex) { + if (fileIndex < 0 || fileIndex >= _torrentFiles.size()) + return -1; long bytes = 0; - for (TorrentFile tf : _torrentFiles) { - File f = tf.RAFfile; - if (f.equals(file)) { + for (int i = 0; i < _torrentFiles.size(); i++) { + TorrentFile tf = _torrentFiles.get(i); + if (i == fileIndex) { + File f = tf.RAFfile; if (complete()) return 0; int psz = piece_size; @@ -350,37 +369,30 @@ public class Storage } /** - * @param file non-canonical path (non-directory) + * @param fileIndex as obtained from indexOf * @since 0.8.1 */ - public int getPriority(File file) { + public int getPriority(int fileIndex) { if (complete() || metainfo.getFiles() == null) return 0; - for (TorrentFile tf : _torrentFiles) { - File f = tf.RAFfile; - if (f.equals(file)) - return tf.priority; - } - return 0; + if (fileIndex < 0 || fileIndex >= _torrentFiles.size()) + return 0; + return _torrentFiles.get(fileIndex).priority; } /** * Must call Snark.updatePiecePriorities() * (which calls getPiecePriorities()) after calling this. - * @param file non-canonical path (non-directory) + * @param fileIndex as obtained from indexOf * @param pri default 0; <0 to disable * @since 0.8.1 */ - public void setPriority(File file, int pri) { + public void setPriority(int fileIndex, int pri) { if (complete() || metainfo.getFiles() == null) return; - for (TorrentFile tf : _torrentFiles) { - File f = tf.RAFfile; - if (f.equals(file)) { - tf.priority = pri; - return; - } - } + if (fileIndex < 0 || fileIndex >= _torrentFiles.size()) + return; + _torrentFiles.get(fileIndex).priority = pri; } /** diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java index e8fdcff91..9e346db71 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java +++ b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java @@ -1432,8 +1432,7 @@ public class I2PSnarkServlet extends BasicServlet { out.write(""); + out.write(" onclick=\"document.location='" + encodedBaseName + "/';\">"); } else { out.write('>'); } @@ -2692,6 +2691,7 @@ public class I2PSnarkServlet extends BasicServlet { boolean complete = false; String status = ""; long length = item.length(); + int fileIndex = -1; int priority = 0; if (item.isDirectory()) { complete = true; @@ -2703,8 +2703,9 @@ public class I2PSnarkServlet extends BasicServlet { status = toImg("cancel") + ' ' + _("Torrent not found?"); } else { Storage storage = snark.getStorage(); + fileIndex = storage.indexOf(item); - long remaining = storage.remaining(item); + long remaining = storage.remaining(fileIndex); if (remaining < 0) { complete = true; status = toImg("cancel") + ' ' + _("File not found in torrent?"); @@ -2712,7 +2713,7 @@ public class I2PSnarkServlet extends BasicServlet { complete = true; status = toImg("tick") + ' ' + _("Complete"); } else { - priority = storage.getPriority(item); + priority = storage.getPriority(fileIndex); if (priority < 0) status = toImg("cancel"); else if (priority == 0) @@ -2764,17 +2765,17 @@ public class I2PSnarkServlet extends BasicServlet { if (showPriority) { buf.append(""); if ((!complete) && (!item.isDirectory())) { - buf.append(" 0) buf.append("checked=\"true\""); buf.append('>').append(_("High")); - buf.append("').append(_("Normal")); - buf.append("').append(_("Skip")); @@ -2873,10 +2874,10 @@ public class I2PSnarkServlet extends BasicServlet { String key = entry.getKey(); if (key.startsWith("pri.")) { try { - File file = new File(key.substring(4)); + int fileIndex = Integer.parseInt(key.substring(4)); String val = entry.getValue()[0]; // jetty arrays int pri = Integer.parseInt(val); - storage.setPriority(file, pri); + storage.setPriority(fileIndex, pri); //System.err.println("Priority now " + pri + " for " + file); } catch (Throwable t) { t.printStackTrace(); } } diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/URIUtil.java b/apps/i2psnark/java/src/org/klomp/snark/web/URIUtil.java index aae95b515..10f33b022 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/web/URIUtil.java +++ b/apps/i2psnark/java/src/org/klomp/snark/web/URIUtil.java @@ -84,6 +84,7 @@ class URIUtil case '<': case '>': case ' ': + case ':': buf=new StringBuilder(path.length()*2); break loop; default: @@ -139,6 +140,9 @@ class URIUtil case 0x7f: buf.append("%7F"); continue; + case ':': + buf.append("%3A"); + continue; default: if (c <= 0x1f) // includes negative toHex(c,buf); @@ -183,6 +187,9 @@ class URIUtil case ' ': buf.append("%20"); continue; + case ':': + buf.append("%3A"); + continue; default: if (c <= 0x1f || (c >= 0x7f && c <= 0x9f) || Character.isSpaceChar(c)) toHex(c,buf); diff --git a/history.txt b/history.txt index 474f1ec42..42de88f60 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2014-09-09 zzz + * i2psnark: Escape fixes + 2014-08-31 zzz * Build: Add support for bundling router infos in the package * I2PTunnel: Allow changing of spoof host and target host/port without diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 25340f779..421ff4f63 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 15; + public final static long BUILD = 16; /** for example "-test" */ public final static String EXTRA = "-rc";