Cleanup after prop from i2p.i2p:
- Remove I2PFile, FileStreamFactory hacks - Remove custom reseed stuff
This commit is contained in:
@ -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>
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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 '/'
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user