When doing bootstraping, always accept one seedlist-File without

checking the date of the file. This should help to start the peer in
case that the user has a completely wrong date setting.
pull/1/head
Michael Peter Christen 11 years ago
parent 16e3b357b3
commit 82621bead0

@ -3632,12 +3632,12 @@ public final class Switchboard extends serverSwitch {
} }
c++; c++;
if ( seedListFileURL.startsWith("http://") || seedListFileURL.startsWith("https://") ) { if ( seedListFileURL.startsWith("http://") || seedListFileURL.startsWith("https://") ) {
loadSeedListConcurrently(this.peers, seedListFileURL, scc, (int) getConfigLong("bootstrapLoadTimeout", 20000)); loadSeedListConcurrently(this.peers, seedListFileURL, scc, (int) getConfigLong("bootstrapLoadTimeout", 20000), c > 0);
} }
} }
} }
private static void loadSeedListConcurrently(final SeedDB peers, final String seedListFileURL, final AtomicInteger scc, final int timeout) { private static void loadSeedListConcurrently(final SeedDB peers, final String seedListFileURL, final AtomicInteger scc, final int timeout, final boolean checkAge) {
// uses the superseed to initialize the database with known seeds // uses the superseed to initialize the database with known seeds
Thread seedLoader = new Thread() { Thread seedLoader = new Thread() {
@ -3656,52 +3656,48 @@ public final class Switchboard extends serverSwitch {
client.HEADResponse(url.toString()); client.HEADResponse(url.toString());
int statusCode = client.getHttpResponse().getStatusLine().getStatusCode(); int statusCode = client.getHttpResponse().getStatusLine().getStatusCode();
ResponseHeader header = new ResponseHeader(statusCode, client.getHttpResponse().getAllHeaders()); ResponseHeader header = new ResponseHeader(statusCode, client.getHttpResponse().getAllHeaders());
//final long loadtime = System.currentTimeMillis() - start; if (checkAge) {
/*if (header == null) { if ( header.lastModified() == null ) {
if (loadtime > getConfigLong("bootstrapLoadTimeout", 6000)) { Network.log.warn("BOOTSTRAP: seed-list URL "
yacyCore.log.logWarning("BOOTSTRAP: seed-list URL " + seedListFileURL + " not available, time-out after " + loadtime + " milliseconds"); + seedListFileURL
} else { + " not usable, last-modified is missing");
yacyCore.log.logWarning("BOOTSTRAP: seed-list URL " + seedListFileURL + " not available, no content"); return;
} else if ( (header.age() > 86400000) && (scc.get() > 0) ) {
Network.log.info("BOOTSTRAP: seed-list URL "
+ seedListFileURL
+ " too old ("
+ (header.age() / 86400000)
+ " days)");
return;
} }
} else*/if ( header.lastModified() == null ) { }
Network.log.warn("BOOTSTRAP: seed-list URL " scc.incrementAndGet();
+ seedListFileURL final byte[] content = client.GETbytes(url);
+ " not usable, last-modified is missing"); Iterator<String> enu = FileUtils.strings(content);
} else if ( (header.age() > 86400000) && (scc.get() > 0) ) { int lc = 0;
Network.log.info("BOOTSTRAP: seed-list URL " while ( enu.hasNext() ) {
+ seedListFileURL try {
+ " too old (" Seed ys = Seed.genRemoteSeed(enu.next(), false, null);
+ (header.age() / 86400000) if ( (ys != null)
+ " days)"); && (!peers.mySeedIsDefined() || !peers.mySeed().hash.equals(ys.hash)) ) {
} else { final long lastseen = Math.abs((System.currentTimeMillis() - ys.getLastSeenUTC()) / 1000 / 60);
scc.incrementAndGet(); if ( lastseen < 60 ) {
final byte[] content = client.GETbytes(url); if ( peers.peerActions.connectPeer(ys, false) ) {
Iterator<String> enu = FileUtils.strings(content); lc++;
int lc = 0;
while ( enu.hasNext() ) {
try {
Seed ys = Seed.genRemoteSeed(enu.next(), false, null);
if ( (ys != null)
&& (!peers.mySeedIsDefined() || !peers.mySeed().hash.equals(ys.hash)) ) {
final long lastseen = Math.abs((System.currentTimeMillis() - ys.getLastSeenUTC()) / 1000 / 60);
if ( lastseen < 60 ) {
if ( peers.peerActions.connectPeer(ys, false) ) {
lc++;
}
} }
} }
} catch (final IOException e ) {
Network.log.info("BOOTSTRAP: bad seed from " + seedListFileURL + ": " + e.getMessage());
} }
} catch (final IOException e ) {
Network.log.info("BOOTSTRAP: bad seed from " + seedListFileURL + ": " + e.getMessage());
} }
Network.log.info("BOOTSTRAP: "
+ lc
+ " seeds from seed-list URL "
+ seedListFileURL
+ ", AGE="
+ (header.age() / 3600000)
+ "h");
} }
Network.log.info("BOOTSTRAP: "
+ lc
+ " seeds from seed-list URL "
+ seedListFileURL
+ ", AGE="
+ (header.age() / 3600000)
+ "h");
} catch (final IOException e ) { } catch (final IOException e ) {
// this is when wget fails, commonly because of timeout // this is when wget fails, commonly because of timeout

Loading…
Cancel
Save