From 4d7417401cdc2f9a9b22ad3feb89eb8521578e78 Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 26 Mar 2008 20:15:47 +0000 Subject: [PATCH] * ReseedHandler: Support multiple urls, add netdb.i2p2.de as a 2nd default --- .../src/net/i2p/router/web/ReseedHandler.java | 33 ++++++++++++++++--- history.txt | 4 +++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java index c6ebc0b4b..2f953df40 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java @@ -7,9 +7,13 @@ import java.io.OutputStream; import java.net.Socket; import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; +import java.util.StringTokenizer; import net.i2p.I2PAppContext; import net.i2p.router.RouterContext; @@ -31,7 +35,7 @@ public class ReseedHandler { // Reject unreasonably big files, because we download into a ByteArrayOutputStream. private static final long MAX_RESEED_RESPONSE_SIZE = 8 * 1024 * 1024; - private static final String DEFAULT_SEED_URL = "http://i2pdb.tin0.de/netDb/"; + private static final String DEFAULT_SEED_URL = "http://i2pdb.tin0.de/netDb/,http://netdb.i2p2.de/"; public ReseedHandler() { this(ContextHelper.getContext(null)); @@ -121,10 +125,28 @@ public class ReseedHandler { "and if nothing helps, read FAQ about reseeding manually."; private void reseed(boolean echoStatus) { + List URLList = new ArrayList(); + String URLs = _context.getProperty("i2p.reseedURL", DEFAULT_SEED_URL); + StringTokenizer tok = new StringTokenizer(URLs, " ,"); + while (tok.hasMoreTokens()) + URLList.add(tok.nextToken().trim()); + Collections.shuffle(URLList); + for (int i = 0; i < URLList.size() && _isRunning; i++) + reseedOne((String) URLList.get(i), echoStatus); + } + + /** + * Fetch a directory listing and then all the routerInfo files in the listing. + * The listing must contain (exactly) strings that match: + * href="routerInfo-{hash}.dat"> + * and then it fetches the files + * {seedURL}routerInfo-{hash}.dat + * after appending a '/' to seedURL if it doesn't have one. + * Essentially this means that the seedURL must be a directory, it + * can't end with 'index.html', for example. + **/ + private void reseedOne(String seedURL, boolean echoStatus) { - String seedURL = _context.getProperty("i2p.reseedURL", DEFAULT_SEED_URL); - if ( (seedURL == null) || (seedURL.trim().length() <= 0) ) - seedURL = DEFAULT_SEED_URL; try { System.setProperty("net.i2p.router.web.ReseedHandler.errorMessage",""); System.setProperty("net.i2p.router.web.ReseedHandler.statusMessage","Reseeding: fetching seed URL."); @@ -194,6 +216,9 @@ public class ReseedHandler { "Last reseed failed (" + failPercent + "% of " + urls.size() + "). " + RESEED_TIPS); } + // Don't go on to the next URL if we have enough + if (fetched > 25) + _isRunning = false; } catch (Throwable t) { System.setProperty("net.i2p.router.web.ReseedHandler.errorMessage", "Last reseed failed fully (exception caught). " + diff --git a/history.txt b/history.txt index 6012fdb7f..9c0217bd0 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2008-03-26 zzz + * ReseedHandler: Support multiple urls, + add netdb.i2p2.de as a 2nd default + 2008-03-25 zzz * i2psnark: - Add support for secondary open trackers diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 286b45aa9..e0c9f007a 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -17,7 +17,7 @@ import net.i2p.CoreVersion; public class RouterVersion { public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $"; public final static String VERSION = "0.6.1.32"; - public final static long BUILD = 11; + public final static long BUILD = 12; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);