From db45e74fcc9d564d818271a707625f481d21c6b8 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Mon, 29 Jun 2009 14:51:02 +0000 Subject: [PATCH] Cleanup after prop from i2p.i2p: - Remove I2PFile, FileStreamFactory hacks - Remove custom reseed stuff --- android/build.xml | 16 +---- android/src/net/i2p/router/I2PAndroid.java | 8 +-- .../src/net/i2p/router/web/ReseedChecker.java | 39 ----------- .../src/net/i2p/util/FileStreamFactory.java | 64 ------------------- android/src/net/i2p/util/I2PFile.java | 29 --------- core/java/src/net/i2p/data/DataHelper.java | 3 +- .../src/net/i2p/util/FileStreamFactory.java | 36 ----------- core/java/src/net/i2p/util/I2PFile.java | 24 ------- .../java/src/net/i2p/router/KeyManager.java | 5 +- .../i2p/router/startup/LoadRouterInfoJob.java | 2 +- 10 files changed, 10 insertions(+), 216 deletions(-) delete mode 100644 android/src/net/i2p/router/web/ReseedChecker.java delete mode 100644 android/src/net/i2p/util/FileStreamFactory.java delete mode 100644 android/src/net/i2p/util/I2PFile.java delete mode 100644 core/java/src/net/i2p/util/FileStreamFactory.java delete mode 100644 core/java/src/net/i2p/util/I2PFile.java diff --git a/android/build.xml b/android/build.xml index 5875c5fed..56cec083d 100644 --- a/android/build.xml +++ b/android/build.xml @@ -155,17 +155,7 @@ </target> <target name="buildrouter" depends="dirs" > - <!-- for now, we just need the ReseedHandler from routerconsole --> - <ant dir="../apps/routerconsole/java" target="compile" /> - <jar destfile="${external-libs}/routerconsole.jar" > - <fileset dir="../apps/routerconsole/java/build/obj/" > - <include name="net/i2p/router/web/ContextHelper.class" /> - <include name="net/i2p/router/web/ReseedHandler.class" /> - <include name="net/i2p/router/web/ReseedHandler$ReseedRunner.class" /> - </fileset> - </jar> - - <!-- build router and core (actually the routerconsole builds these anyway) --> + <!-- build router and core --> <ant dir=".." target="buildrouter" /> <!-- router --> @@ -175,8 +165,6 @@ <mkdir dir="tmp" /> <unjar src="../build/i2p.jar" dest="tmp/" /> <delete file="tmp/net/i2p/util/LogWriter.class" /> - <delete file="tmp/net/i2p/util/FileStreamFactory.class" /> - <delete file="tmp/net/i2p/util/I2PFile.class" /> <!-- org.bouncycastle.crypto already in android but we need a little trickery because our HMac is incompatible... and the libs aren't in the SDK to compile against??? --> @@ -206,7 +194,7 @@ <!-- some resources --> <mkdir dir="res/drawable/" /> - <copy file="../apps/routerconsole/jsp/i2plogo.png" todir="res/drawable/" /> + <copy file="../installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" /> <copy file="../installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" /> </target> diff --git a/android/src/net/i2p/router/I2PAndroid.java b/android/src/net/i2p/router/I2PAndroid.java index bb77d290b..0d89bfb7b 100644 --- a/android/src/net/i2p/router/I2PAndroid.java +++ b/android/src/net/i2p/router/I2PAndroid.java @@ -13,8 +13,7 @@ import java.io.IOException; import net.i2p.router.Router; import net.i2p.router.web.ContextHelper; -import net.i2p.router.web.ReseedChecker; -import net.i2p.util.I2PFile; +// import net.i2p.util.NativeBigInteger; public class I2PAndroid extends Activity { @@ -30,6 +29,9 @@ public class I2PAndroid extends Activity _context = this; // Activity extends Context debugStuff(); initialize(); + // 300ms per run + // 5x slower than java on my server and 50x slower than native on my server + // NativeBigInteger.main(null); } public void onRestart() @@ -44,8 +46,6 @@ public class I2PAndroid extends Activity super.onStart(); Router.main(null); System.err.println("Router.main finished"); - - ReseedChecker.checkReseed(); } public void onResume() diff --git a/android/src/net/i2p/router/web/ReseedChecker.java b/android/src/net/i2p/router/web/ReseedChecker.java deleted file mode 100644 index 8c8ff7bf9..000000000 --- a/android/src/net/i2p/router/web/ReseedChecker.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.i2p.router.web; - -import java.io.File; - -import net.i2p.router.web.ReseedHandler; -import net.i2p.util.I2PFile; - -/** - * Copied from RouterConsoleRunner.java - */ -public class ReseedChecker { - - public static void checkReseed() { - - System.err.println("Checking to see if we should reseed"); - // we check the i2p installation directory (.) for a flag telling us not to reseed, - // but also check the home directory for that flag too, since new users installing i2p - // don't have an installation directory that they can put the flag in yet. - File noReseedFile = new I2PFile(new I2PFile(System.getProperty("user.home")), ".i2pnoreseed"); - File noReseedFileAlt1 = new I2PFile(new I2PFile(System.getProperty("user.home")), "noreseed.i2p"); - File noReseedFileAlt2 = new I2PFile(".i2pnoreseed"); - File noReseedFileAlt3 = new I2PFile("noreseed.i2p"); - if (!noReseedFile.exists() && !noReseedFileAlt1.exists() && !noReseedFileAlt2.exists() && !noReseedFileAlt3.exists()) { - File netDb = new I2PFile("netDb"); - // sure, some of them could be "my.info" or various leaseSet- files, but chances are, - // if someone has those files, they've already been seeded (at least enough to let them - // get i2p started - they can reseed later in the web console) - String names[] = (netDb.exists() ? netDb.list() : null); - if ( (names == null) || (names.length < 15) ) { - System.err.println("Yes, reseeding now"); - ReseedHandler reseedHandler = new ReseedHandler(); - reseedHandler.requestReseed(); - } else { - System.err.println("No, we have " + names.length + " routers in the netDb"); - } - } - } - -} diff --git a/android/src/net/i2p/util/FileStreamFactory.java b/android/src/net/i2p/util/FileStreamFactory.java deleted file mode 100644 index b7a65e4f2..000000000 --- a/android/src/net/i2p/util/FileStreamFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This is free software, do as you please. - */ - -package net.i2p.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; - -import net.i2p.router.I2PAndroid; - -/** - * Use android static file stream methods - * gaaah: - * 1) the CWD is / - * 2) we can only access /data/data/net.i2p.router/files/ - * 3) you can't change your CWD in Java - * so we have this lovely and the one in I2PFile. - * - * @author zzz - */ -public class FileStreamFactory { - private static final String DIR = "/data/data/net.i2p.router/files/"; - - /** hopefully no path separators in string */ - public static FileInputStream getFileInputStream(String f) throws FileNotFoundException { - System.err.println("Input file-s: " + I2PAndroid.getContext().getFileStreamPath(f).getAbsolutePath()); - return I2PAndroid.getContext().openFileInput(f); - } - - public static FileInputStream getFileInputStream(File f) throws FileNotFoundException { - System.err.println("Input file-f: " + getPath(f) + - ' ' + f.getAbsolutePath()); - //return I2PAndroid.getContext().openFileInput(f.getName()); - return new FileInputStream(getPath(f)); - } - - /** hopefully no path separators in string */ - public static FileOutputStream getFileOutputStream(String f) throws FileNotFoundException { - System.err.println("Output file-s: " + I2PAndroid.getContext().getFileStreamPath(f).getAbsolutePath()); - return I2PAndroid.getContext().openFileOutput(f, 0); - } - - public static FileOutputStream getFileOutputStream(File f) throws FileNotFoundException { - System.err.println("Output file-f: " + getPath(f) + - ' ' + f.getAbsolutePath()); - //return I2PAndroid.getContext().openFileOutput(f.getName(), 0); - return new FileOutputStream(getPath(f)); - } - - /** - * preserve path but convert /foo/blah to /data/data/net.i2p.router/files/foo/blah - * Although if the File arg was created with new I2PFile() then this isn't required - * - */ - private static String getPath(File f) { - String abs = f.getAbsolutePath(); - if (abs.startsWith(DIR)) - return abs; - return DIR + abs.substring(1); // strip extra '/' - } -} diff --git a/android/src/net/i2p/util/I2PFile.java b/android/src/net/i2p/util/I2PFile.java deleted file mode 100644 index 94bda029b..000000000 --- a/android/src/net/i2p/util/I2PFile.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This is free software, do as you please. - */ - -package net.i2p.util; - -import java.io.File; - -/** - * gaaah: - * 1) the CWD is / - * 2) we can only access /data/data/net.i2p.router/files/ - * 3) you can't change your CWD in Java - * so we have this lovely and the one in FileStreamFactory. - * - * @author zzz - */ -public class I2PFile extends File { - - public I2PFile (String f) { - super("/data/data/net.i2p.router/files/" + f); - } - - /** one level deep only */ - public I2PFile (File p, String f) { - super("/data/data/net.i2p.router/files/" + p.getName(), f); - } - -} diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 55b424562..53e32a347 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -37,7 +37,6 @@ import java.util.TreeMap; import java.util.zip.Deflater; import net.i2p.util.ByteCache; -import net.i2p.util.FileStreamFactory; import net.i2p.util.OrderedProperties; import net.i2p.util.ReusableGZIPInputStream; import net.i2p.util.ReusableGZIPOutputStream; @@ -218,7 +217,7 @@ public class DataHelper { loadProps(props, file, false); } public static void loadProps(Properties props, File file, boolean forceLowerCase) throws IOException { - loadProps(props, FileStreamFactory.getFileInputStream(file), forceLowerCase); + loadProps(props, new FileInputStream(file), forceLowerCase); } public static void loadProps(Properties props, InputStream inStr) throws IOException { loadProps(props, inStr, false); diff --git a/core/java/src/net/i2p/util/FileStreamFactory.java b/core/java/src/net/i2p/util/FileStreamFactory.java deleted file mode 100644 index 01d505665..000000000 --- a/core/java/src/net/i2p/util/FileStreamFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * public domain - */ - -package net.i2p.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; - - -/** - * This is pulled out and replaced in the android build. - * - * @author zzz - */ -public class FileStreamFactory { - - public static FileInputStream getFileInputStream(String f) throws FileNotFoundException { - return new FileInputStream(f); - } - - public static FileInputStream getFileInputStream(File f) throws FileNotFoundException { - return new FileInputStream(f); - } - - public static FileOutputStream getFileOutputStream(String f) throws FileNotFoundException { - return new FileOutputStream(f); - } - - public static FileOutputStream getFileOutputStream(File f) throws FileNotFoundException { - return new FileOutputStream(f); - } - -} diff --git a/core/java/src/net/i2p/util/I2PFile.java b/core/java/src/net/i2p/util/I2PFile.java deleted file mode 100644 index 107286edf..000000000 --- a/core/java/src/net/i2p/util/I2PFile.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * public domain - */ - -package net.i2p.util; - -import java.io.File; - -/** - * This is pulled out and replaced in the android build. - * - * @author zzz - */ -public class I2PFile extends File { - - public I2PFile (String f) { - super(f); - } - - public I2PFile (File p, String f) { - super(p, f); - } - -} diff --git a/router/java/src/net/i2p/router/KeyManager.java b/router/java/src/net/i2p/router/KeyManager.java index f82f9f824..711759a40 100644 --- a/router/java/src/net/i2p/router/KeyManager.java +++ b/router/java/src/net/i2p/router/KeyManager.java @@ -26,7 +26,6 @@ import net.i2p.data.PublicKey; import net.i2p.data.SigningPrivateKey; import net.i2p.data.SigningPublicKey; import net.i2p.util.Clock; -import net.i2p.util.FileStreamFactory; import net.i2p.util.Log; /** @@ -204,12 +203,12 @@ public class KeyManager { FileInputStream in = null; try { if (exists) { - out = FileStreamFactory.getFileOutputStream(keyFile); + out = new FileOutputStream(keyFile); structure.writeBytes(out); return structure; } else { if (keyFile.exists()) { - in = FileStreamFactory.getFileInputStream(keyFile); + in = new FileInputStream(keyFile); structure.readBytes(in); return structure; } else { diff --git a/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java b/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java index fea9c461e..f3428c447 100644 --- a/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java +++ b/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java @@ -76,7 +76,7 @@ public class LoadRouterInfoJob extends JobImpl { } if (_keysExist) { - fis2 = FileStreamFactory.getFileInputStream(rkf); + fis2 = new FileInputStream(rkf); PrivateKey privkey = new PrivateKey(); privkey.readBytes(fis2); SigningPrivateKey signingPrivKey = new SigningPrivateKey(); -- GitLab