separate YaCy networks:

- added server-side network unit identification
- added server-side network access authorization
- enhanced client-side network authentification essentials generation
- implemented first peer-peer salted-magic authentification method

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3953 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent a9e73b6852
commit f40566f9bb

@ -57,6 +57,7 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class crawlOrder {
@ -65,9 +66,9 @@ public final class crawlOrder {
// return variable that accumulates replacements
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
//int proxyPrefetchDepth = Integer.parseInt(env.getConfig("proxyPrefetchDepth", "0"));
//int crawlingdepth = Integer.parseInt(env.getConfig("crawlingDepth", "0"));
@ -77,6 +78,8 @@ public final class crawlOrder {
String process = post.get("process", ""); // process type
String key = post.get("key", ""); // transmission key
int orderDepth = post.getInt("depth", 0); // crawl depth
String unitName = post.get("network.unit.name", yacySeed.DFLT_NETWORK_UNIT); // the network unit
if (!unitName.equals(env.getConfig("network.unit.name", yacySeed.DFLT_NETWORK_UNIT))) return null;
// response values
/*

@ -57,6 +57,7 @@ import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.crypt;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class crawlReceipt {
@ -73,6 +74,7 @@ public final class crawlReceipt {
serverLog log = switchboard.getLog();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
//int proxyPrefetchDepth = Integer.parseInt(env.getConfig("proxyPrefetchDepth", "0"));
//int crawlingDepth = Integer.parseInt(env.getConfig("crawlingDepth", "0"));

@ -57,21 +57,22 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyClient;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyVersion;
public final class hello {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) throws InterruptedException {
if (post == null || ss == null || yacyCore.seedDB == null || yacyCore.seedDB.mySeed == null) { return null; }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws InterruptedException {
if (post == null || env == null || yacyCore.seedDB == null || yacyCore.seedDB.mySeed == null) { return null; }
plasmaSwitchboard sb = (plasmaSwitchboard) ss;
plasmaSwitchboard sb = (plasmaSwitchboard) env;
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
if (prop == null) { return null; }
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
// final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
// final String pattern = (String) post.get("pattern", ""); //
// final String mytime = (String) post.get(MYTIME, ""); //
final String key = post.get("key", ""); // transmission key for response
final String seed = post.get("seed", "");

@ -63,20 +63,23 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class list {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
if (post == null || ss == null)
throw new NullPointerException("post: " + post + ", sb: " + ss);
plasmaSwitchboard sb = (plasmaSwitchboard) ss;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
if (post == null || env == null)
throw new NullPointerException("post: " + post + ", sb: " + env);
plasmaSwitchboard sb = (plasmaSwitchboard) env;
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
final String col = post.get("col", "");
final File listsPath = new File(ss.getRootPath(),ss.getConfig("listsPath", "DATA/LISTS"));
final File listsPath = new File(env.getRootPath(),env.getConfig("listsPath", "DATA/LISTS"));
String otherPeerName = null;
if (post.containsKey("iam")) {
@ -93,7 +96,7 @@ public final class list {
if (col.equals("black")) {
final StringBuffer out = new StringBuffer();
final String filenames=ss.getConfig("BlackLists.Shared", "");
final String filenames=env.getConfig("BlackLists.Shared", "");
final String[] filenamesarray = filenames.split(",");
if(filenamesarray.length > 0){
@ -109,7 +112,7 @@ public final class list {
}
// start contrib by [FB]
else if (col.length() == 0 && post.get("list", "").equals("queueUrls")) {
final URLFetcherStack db = CrawlURLFetchStack_p.getURLFetcherStack(ss);
final URLFetcherStack db = CrawlURLFetchStack_p.getURLFetcherStack(env);
final String display = post.get("display", "list");
if (display.equals("list")) {
// list urls from remote crawler queue for other peers

@ -62,6 +62,7 @@ import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.crypt;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class message {
@ -71,13 +72,14 @@ public final class message {
return SimpleFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
if (post == null || ss == null) { return null; }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
if (post == null || env == null) { return null; }
// return variable that accumulates replacements
plasmaSwitchboard sb = (plasmaSwitchboard) ss;
plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
if (prop == null || sb == null) { return null; }
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
String process = post.get("process", "permission");
String key = post.get("key", "");
@ -153,7 +155,7 @@ public final class message {
yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,
subject, mb));
messageForwardingViaEmail(ss, msgEntry);
messageForwardingViaEmail(env, msgEntry);
// finally write notification
File notifierSource = new File(sb.getRootPath(), sb.getConfig("htRootPath","htroot") + "/env/grafics/message.gif");

@ -59,14 +59,16 @@ import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyNetwork;
public final class profile {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
// return variable that accumulates replacements
serverObjects prop = new serverObjects();
plasmaSwitchboard sb = (plasmaSwitchboard) ss;
if (prop == null) { return null; }
plasmaSwitchboard sb = (plasmaSwitchboard) env;
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
if ((sb.isRobinsonMode()) &&
(!sb.isPublicRobinson()) &&

@ -53,6 +53,7 @@ import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
public final class query {
@ -61,8 +62,10 @@ public final class query {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
if (sb == null) { return null; }
final serverObjects prop = new serverObjects();
if ((post == null) || (ss == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, ss)) return prop;
if ((sb.isRobinsonMode()) &&
(!sb.isPublicRobinson()) &&

@ -72,16 +72,18 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyDHTAction;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
import de.anomic.tools.crypt;
public final class search {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
if (post == null || ss == null) { return null; }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
//System.out.println("yacy: search received request = " + post.toString());
@ -113,9 +115,7 @@ public final class search {
// http://localhost:8080/yacy/search.html?query=gh8DKIhGKXws (search for book)
// http://localhost:8080/yacy/search.html?query=4galTpdpDM5Qgh8DKIhGKXws&abstracts=auto (search for linux and book, generate abstract automatically)
// http://localhost:8080/yacy/search.html?query=&abstracts=4galTpdpDM5Q (only abstracts for linux)
serverObjects prop = new serverObjects();
if ((sb.isRobinsonMode()) &&
(!((sb.isPublicRobinson()) ||
(sb.isInMyCluster((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))))) {

@ -55,15 +55,17 @@ import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class transfer {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
if (post == null || env == null) return null;
plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
String process = post.get("process", ""); // permission or store
//String key = post.get("key", ""); // a transmission key from the client
String otherpeer = post.get("iam", ""); // identification of the client (a peer-hash)

@ -60,17 +60,18 @@ import de.anomic.server.serverSwitch;
import de.anomic.tools.nxTools;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyDHTAction;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class transferRWI {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) throws InterruptedException {
if (post == null || ss == null) { return null; }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws InterruptedException {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
if (prop == null || sb == null) { return null; }
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
// request values
final String iam = post.get("iam", ""); // seed hash of requester

@ -57,22 +57,22 @@ import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNetwork;
import de.anomic.yacy.yacySeed;
public final class transferURL {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) throws InterruptedException {
if (post == null || ss == null) { return null; }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) throws InterruptedException {
long start = System.currentTimeMillis();
long freshdate = 0;
try {freshdate = plasmaURL.shortDayFormatter.parse("20061101").getTime();} catch (ParseException e1) {}
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
if (prop == null || sb == null) { return null; }
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
// request values
final String iam = post.get("iam", ""); // seed hash of requester

File diff suppressed because it is too large Load Diff

@ -0,0 +1,101 @@
// yacyNetwork.java
// ----------------
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 04.07.2007 on http://yacy.net
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2007-07-03 22:55:47 +0000 (Di, 03 Jul 2007) $
// $LastChangedRevision: 3950 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.yacy;
import java.util.Date;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.crypt;
public class yacyNetwork {
public static final boolean authentifyRequest(serverObjects post, serverSwitch env) {
if ((post == null) || (env == null)) return false;
// identify network
String unitName = post.get("network.unit.name", yacySeed.DFLT_NETWORK_UNIT); // the network unit
if (!unitName.equals(env.getConfig("network.unit.name", yacySeed.DFLT_NETWORK_UNIT))) {
return false;
}
// check authentification method
String authentificationControl = env.getConfig("network.unit.protocol.control", "uncontrolled");
if (authentificationControl.equals("uncontrolled")) return true;
String authentificationMethod = env.getConfig("network.unit.protocol.request.authentification.method", "");
if (authentificationMethod.length() == 0) {
return false;
}
if (authentificationMethod.equals("salted-magic-sim")) {
// authentify the peer using the md5-magic
String salt = post.get("key", "");
String iam = post.get("iam", "");
String magic = env.getConfig("network.unit.protocol.request.authentification.essentials", "");
String md5 = serverCodings.encodeMD5Hex(salt + iam + magic);
return post.get("magicmd5", "").equals(md5);
}
// unknown authentification method
return false;
}
public static final String enrichRequestPost(serverObjects post, serverSwitch env, String targetHash) {
// put in all the essentials for routing and network authentification
// generate a session key
final String salt = crypt.randomSalt();
post.put("key", salt);
// just standard identification essentials
post.put("iam", yacyCore.seedDB.mySeed.hash);
if (targetHash != null) post.put("youare", targetHash);
// time information for synchronization
post.put("mytime", yacyCore.universalDateShortString(new Date()));
post.put("myUTC", System.currentTimeMillis());
// network identification
post.put("network.unit.name", plasmaSwitchboard.getSwitchboard().getConfig("network.unit.name", yacySeed.DFLT_NETWORK_UNIT));
// authentification essentials
String authentificationControl = env.getConfig("network.unit.protocol.control", "uncontrolled");
String authentificationMethod = env.getConfig("network.unit.protocol.request.authentification.method", "");
if ((authentificationControl.equals("controlled")) && (authentificationMethod.length() > 0)) {
if (authentificationMethod.equals("salted-magic-sim")) {
// generate an authentification essential using the salt, the iam-hash and the network magic
String magic = env.getConfig("network.unit.protocol.request.authentification.essentials", "");
String md5 = serverCodings.encodeMD5Hex(salt + yacyCore.seedDB.mySeed.hash + magic);
post.put("magicmd5", md5);
}
}
return salt;
}
}

@ -69,8 +69,8 @@ network.unit.update.location1 = http://latest.yacy.net
network.unit.update.location2 = http://latest.yacy-forum.net
# properties for in-protocol response authentification:
#network.unit.protocol.control = uncontrolled
#network.unit.protocol.request.authentification.method = salted-magic
network.unit.protocol.control = uncontrolled
#network.unit.protocol.request.authentification.method = salted-magic-sim
#network.unit.protocol.request.authentification.essentials =
#network.unit.protocol.response.authentification.method = challenge-pwresponse
#network.unit.protocol.response.authentification.essentials =

Loading…
Cancel
Save