mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
more logging about bad seeds
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7275 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
959b8c6fa0
commit
25a8e55bc9
|
@ -27,6 +27,7 @@
|
|||
// javac -classpath .:../../classes hello.java
|
||||
// if the shell's current path is HTROOT
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
|
@ -86,7 +87,14 @@ public final class hello {
|
|||
prop.put("message", "your seed is too long (" + seed.length() + ")");
|
||||
return prop;
|
||||
}
|
||||
final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, true);
|
||||
yacySeed remoteSeed;
|
||||
try {
|
||||
remoteSeed = yacySeed.genRemoteSeed(seed, key, true);
|
||||
} catch (IOException e) {
|
||||
yacyCore.log.logInfo("hello/server: bad seed: " + e.getMessage());
|
||||
prop.put("message", "bad seed: " + e.getMessage());
|
||||
return prop;
|
||||
}
|
||||
|
||||
// System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));
|
||||
if (remoteSeed == null || remoteSeed.hash == null) {
|
||||
|
|
|
@ -108,7 +108,13 @@ public final class message {
|
|||
return prop;
|
||||
}
|
||||
//Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time
|
||||
final yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key, false);
|
||||
yacySeed otherSeed;
|
||||
try {
|
||||
otherSeed = yacySeed.genRemoteSeed(otherSeedString, key, false);
|
||||
} catch (IOException e) {
|
||||
prop.put("response", "-1"); // don't accept messages for bad seeds
|
||||
return prop;
|
||||
}
|
||||
|
||||
String subject = crypt.simpleDecode(post.get("subject", ""), key); // message's subject
|
||||
String message = crypt.simpleDecode(post.get("message", ""), key); // message body
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
// javac -classpath .:../../Classes search.java
|
||||
// if the shell's current path is htroot/yacy
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
@ -173,7 +174,13 @@ public final class search {
|
|||
final HandleSet abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts);
|
||||
|
||||
// store accessing peer
|
||||
final yacySeed remoteSeed = yacySeed.genRemoteSeed(oseed, key, false);
|
||||
yacySeed remoteSeed;
|
||||
try {
|
||||
remoteSeed = yacySeed.genRemoteSeed(oseed, key, false);
|
||||
} catch (IOException e) {
|
||||
yacyCore.log.logInfo("yacy.search: access with bad seed: " + e.getMessage());
|
||||
remoteSeed = null;
|
||||
}
|
||||
if (sb.peers == null) {
|
||||
yacyCore.log.logSevere("yacy.search: seed cache not initialized");
|
||||
} else {
|
||||
|
|
|
@ -2463,13 +2463,17 @@ public final class Switchboard extends serverSwitch {
|
|||
enu = FileUtils.strings(content);
|
||||
lc = 0;
|
||||
while (enu.hasNext()) {
|
||||
ys = yacySeed.genRemoteSeed(enu.next(), null, false);
|
||||
if ((ys != null) &&
|
||||
((!peers.mySeedIsDefined()) || !peers.mySeed().hash.equals(ys.hash))) {
|
||||
if (peers.peerActions.connectPeer(ys, false)) lc++;
|
||||
//seedDB.writeMap(ys.hash, ys.getMap(), "init");
|
||||
//System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());
|
||||
//lc++;
|
||||
try {
|
||||
ys = yacySeed.genRemoteSeed(enu.next(), null, false);
|
||||
if ((ys != null) &&
|
||||
((!peers.mySeedIsDefined()) || !peers.mySeed().hash.equals(ys.hash))) {
|
||||
if (peers.peerActions.connectPeer(ys, false)) lc++;
|
||||
//seedDB.writeMap(ys.hash, ys.getMap(), "init");
|
||||
//System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());
|
||||
//lc++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
yacyCore.log.logInfo("BOOTSTRAP: bad seed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
yacyCore.log.logInfo("BOOTSTRAP: " + lc + " seeds from seed-list URL " + seedListFileURL + ", AGE=" + (header.age() / 3600000) + "h");
|
||||
|
|
|
@ -165,11 +165,16 @@ public final class yacyClient {
|
|||
if (seed.length() > yacySeed.maxsize) {
|
||||
yacyCore.log.logInfo("hello/client 0: rejected contacting seed; too large (" + seed.length() + " > " + yacySeed.maxsize + ")");
|
||||
} else {
|
||||
otherPeer = yacySeed.genRemoteSeed(seed, salt, false);
|
||||
if (otherPeer == null || !otherPeer.hash.equals(otherHash)) {
|
||||
yacyCore.log.logInfo("yacyClient.publishMySeed: consistency error: other peer '" + ((otherPeer==null) ? ("seed=" + seed) : otherPeer.getName()) + "' wrong");
|
||||
return -1; // no success
|
||||
}
|
||||
try {
|
||||
otherPeer = yacySeed.genRemoteSeed(seed, salt, false);
|
||||
if (!otherPeer.hash.equals(otherHash)) {
|
||||
yacyCore.log.logInfo("yacyClient.publishMySeed: consistency error: otherPeer.hash = " + otherPeer.hash + ", otherHash = " + otherHash);
|
||||
return -1; // no success
|
||||
}
|
||||
} catch (IOException e) {
|
||||
yacyCore.log.logInfo("yacyClient.publishMySeed: consistency error: other seed bad:" + e.getMessage() + ", seed=" + seed);
|
||||
return -1; // no success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,13 +232,19 @@ public final class yacyClient {
|
|||
int i = 0;
|
||||
int count = 0;
|
||||
String seedStr;
|
||||
yacySeed s;
|
||||
while ((seedStr = result.get("seed" + i++)) != null) {
|
||||
// integrate new seed into own database
|
||||
// the first seed, "seed0" is the seed of the responding peer
|
||||
if (seedStr.length() > yacySeed.maxsize) {
|
||||
yacyCore.log.logInfo("hello/client: rejected contacting seed; too large (" + seedStr.length() + " > " + yacySeed.maxsize + ")");
|
||||
} else {
|
||||
if (peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, salt, false), (i == 1))) count++;
|
||||
try {
|
||||
s = yacySeed.genRemoteSeed(seedStr, salt, false);
|
||||
if (peerActions.peerArrival(s, (i == 1))) count++;
|
||||
} catch (IOException e) {
|
||||
yacyCore.log.logInfo("hello/client: rejected contacting seed; bad (" + e.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
|
|
@ -764,27 +764,26 @@ public class yacySeed implements Cloneable {
|
|||
return hash.getBytes();
|
||||
}
|
||||
|
||||
public static yacySeed genRemoteSeed(final String seedStr, final String key, final boolean ownSeed) {
|
||||
public static yacySeed genRemoteSeed(final String seedStr, final String key, final boolean ownSeed) throws IOException {
|
||||
// this method is used to convert the external representation of a seed into a seed object
|
||||
// yacyCore.log.logFinest("genRemoteSeed: seedStr=" + seedStr + " key=" + key);
|
||||
|
||||
// check protocol and syntax of seed
|
||||
if (seedStr == null || seedStr.length() == 0) return null;
|
||||
if (seedStr == null) throw new IOException("seedStr == null");
|
||||
if (seedStr.length() == 0) throw new IOException("seedStr.length() == 0");
|
||||
final String seed = crypt.simpleDecode(seedStr, key);
|
||||
if (seed == null || seed.length() == 0) return null;
|
||||
if (seed == null) throw new IOException("seed == null");
|
||||
if (seed.length() == 0) throw new IOException("seed.length() == 0");
|
||||
|
||||
// extract hash
|
||||
final ConcurrentHashMap<String, String> dna = MapTools.string2map(seed, ",");
|
||||
final String hash = dna.remove(yacySeed.HASH);
|
||||
if (hash == null) return null;
|
||||
if (hash == null) throw new IOException("hash == null");
|
||||
final yacySeed resultSeed = new yacySeed(hash, dna);
|
||||
|
||||
// check semantics of content
|
||||
final String testResult = resultSeed.isProper(ownSeed);
|
||||
if (testResult != null) {
|
||||
if (yacyCore.log.isFinest()) yacyCore.log.logFinest("seed is not proper (" + testResult + "): " + resultSeed);
|
||||
return null;
|
||||
}
|
||||
if (testResult != null) throw new IOException("seed is not proper (" + testResult + "): " + resultSeed);
|
||||
|
||||
// seed ok
|
||||
return resultSeed;
|
||||
|
@ -874,7 +873,7 @@ public class yacySeed implements Cloneable {
|
|||
fr.read(b, 0, b.length);
|
||||
fr.close();
|
||||
final yacySeed mySeed = genRemoteSeed(new String(b), null, true);
|
||||
if (mySeed == null) return null;
|
||||
assert mySeed != null; // in case of an error, an IOException is thrown
|
||||
mySeed.dna.put(yacySeed.IP, ""); // set own IP as unknown
|
||||
return mySeed;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user