Cleanup after prop from i2p.i2p:

- Remove I2PFile, FileStreamFactory hacks
- Remove custom reseed stuff
This commit is contained in:
zzz
2009-06-29 14:51:02 +00:00
parent 206e45b9e8
commit db45e74fcc
10 changed files with 10 additions and 216 deletions

View File

@ -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()

View File

@ -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");
}
}
}
}

View File

@ -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 '/'
}
}

View File

@ -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);
}
}