I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit 9cbd7643 authored by zzz's avatar zzz
Browse files

Tools: Add CLI reseed test

parent 4d5a3fc7
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ public class CommandLine extends net.i2p.util.CommandLine {
"net.i2p.router.RouterVersion",
"net.i2p.router.crypto.FamilyKeyCrypto",
"net.i2p.router.naming.BlockfileNamingService",
"net.i2p.router.networkdb.reseed.Reseeder",
"net.i2p.router.peermanager.ProfileOrganizer",
"net.i2p.router.tasks.CryptoChecker",
"net.i2p.router.time.NtpClient",
......
......@@ -1219,15 +1219,83 @@ public class Reseeder {
return Translate.getString(n, s, p, _context, BUNDLE_NAME);
}
/******
public static void main(String args[]) {
if ( (args != null) && (args.length == 1) && (!Boolean.parseBoolean(args[0])) ) {
System.out.println("Not reseeding, as requested");
return; // not reseeding on request
/**
* @since 0.9.58
*/
public static void main(String args[]) throws Exception {
File f = new File("certificates");
if (!f.exists()) {
System.out.println("Must be run from $I2P or have symlink to $I2P/certificates in this directory");
System.exit(1);
}
String[] urls = (args.length > 0) ? args : DataHelper.split(DEFAULT_SSL_SEED_URL, ",");
int pass = 0, fail = 0;
SSLEepGet.SSLState sslState = null;
I2PAppContext ctx = I2PAppContext.getGlobalContext();
for (String url : urls) {
url += SU3_FILENAME + NETID_PARAM + '2';
URI uri = new URI(url);
String host = uri.getHost();
System.out.println("Testing " + host);
File su3 = new File(host + ".su3");
try {
SSLEepGet get;
if (sslState == null) {
get = new SSLEepGet(ctx, su3.getPath(), url);
sslState = get.getSSLState();
} else {
get = new SSLEepGet(ctx, su3.getPath(), url, sslState);
}
if (get.fetch()) {
int rc = get.getStatusCode();
if (rc == 200) {
SU3File su3f = new SU3File(su3);
File zip = new File(host + ".zip");
su3f.verifyAndMigrate(zip);
SU3File.main(new String[] {"showversion", su3.getPath()});
String version = su3f.getVersionString();
try {
Long ver = Long.parseLong(version.trim());
ver *= 1000;
if (ver < System.currentTimeMillis() - MAX_FILE_AGE / 4)
throw new IOException("su3 file too old");
} catch (NumberFormatException nfe) {}
java.util.zip.ZipFile zipf = new java.util.zip.ZipFile(zip);
java.util.Enumeration<? extends java.util.zip.ZipEntry> entries = zipf.entries();
int ri = 0;
while (entries.hasMoreElements()) {
entries.nextElement();
ri++;
}
zipf.close();
System.out.println("Test passed for " + host + ", returned " + ri + " router infos");
pass++;
} else {
System.out.println("Test failed for " + host + " return code: " + rc);
su3.delete();
fail++;
}
} else {
int rc = get.getStatusCode();
System.out.println("Test failed for " + host + " return code: " + rc);
su3.delete();
fail++;
}
} catch (IOException ioe) {
System.out.println("Test failed for " + host + ": " + ioe);
ioe.printStackTrace();
if (su3.exists()) {
try {
SU3File.main(new String[] {"showversion", su3.getPath()});
} catch (Exception e) {}
su3.delete();
}
fail++;
}
System.out.println();
}
System.out.println("Reseeding");
Reseeder reseedHandler = new Reseeder();
reseedHandler.requestReseed();
System.out.println("Passed: " + pass + "; Failed: " + fail);
if (fail > 0)
System.exit(1);
}
******/
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment