- removed 'peerName' property from the yacy settings file because this information is stored in the yacy seed file

- the own seed file gets the lead for storage of the peer name
- exchanged default peer name generation method with one that does not use the local ip
- default peer names are now strings starting with '_anon'
- added another switch to suppress forwarding to ConfigBasic if the name was already changed
- replaced all usages of the yacy.conf peerName with access to the local seed
- changes to the peer name are now applied directly and not after the next peer ping


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7453 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 8bc66b9e84
commit 6c35b68f17

@ -431,12 +431,6 @@ seedScpAccount=
seedScpPassword=
seedScpPath=
# every peer should have a name. inded, we try to give every peer an unique ID,
# which is necessary for internal organization of the index sharing, but the
# peer's name is purely informal. No function but information is applied.
# please change this at your pleasure
peerName=anomic
# every peer periodically scans for other peers. you can set the time
# of the period here (minutes)
peerCycle=2

@ -75,7 +75,7 @@
<dl>
<dt><label for="peername">Peer Name: </label></dt>
<dd>
<input type="text" name="peername" id="peername" value="#[defaultName]#" size="20" maxlength="32" />
<input type="text" name="peername" id="peername" value="#[defaultName]#" size="32" maxlength="32" />
</dd>
</dl>
</fieldset>
@ -99,9 +99,8 @@
</dl>
</fieldset>
</li>
<li>
<fieldset>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="set" value="Set Configuration" /></fieldset>
</li>
</ol>
</form>
<p><strong>What you should do next:</strong></p>

@ -91,7 +91,7 @@ public class ConfigBasic {
}
// peer name settings
final String peerName = (post == null) ? env.getConfig("peerName","") : post.get("peername", "");
final String peerName = (post == null) ? sb.peers.mySeed().getName() : post.get("peername", "");
// port settings
final long port;
@ -103,10 +103,10 @@ public class ConfigBasic {
// check if peer name already exists
final yacySeed oldSeed = sb.peers.lookupByName(peerName);
if (oldSeed == null && !env.getConfig("peerName", "").equals(peerName)) {
if (oldSeed == null && !sb.peers.mySeed().getName().equals(peerName)) {
// the name is new
if (Pattern.compile("[A-Za-z0-9\\-_]{3,80}").matcher(peerName).matches()) {
env.setConfig("peerName", peerName);
sb.peers.mySeed().setName(peerName);
}
}
@ -219,7 +219,7 @@ public class ConfigBasic {
// check if values are proper
final boolean properPassword = (sb.getConfig(HTTPDemon.ADMIN_ACCOUNT_B64MD5, "").length() > 0) || sb.getConfigBool("adminAccountForLocalhost", false);
final boolean properName = (env.getConfig("peerName","").length() >= 3) && (!(yacySeed.isDefaultPeerName(env.getConfig("peerName",""))));
final boolean properName = (sb.peers.mySeed().getName().length() >= 3) && (!(yacySeed.isDefaultPeerName(sb.peers.mySeed().getName())));
final boolean properPort = (sb.peers.mySeed().isSenior()) || (sb.peers.mySeed().isPrincipal());
if ((env.getConfig("defaultFiles", "").startsWith("ConfigBasic.html,"))) {
@ -253,7 +253,7 @@ public class ConfigBasic {
}
// set default values
prop.putHTML("defaultName", env.getConfig("peerName", ""));
prop.putHTML("defaultName", sb.peers.mySeed().getName());
prop.putHTML("defaultPort", env.getConfig("port", "8080"));
lang = env.getConfig("locale.language", "default"); // re-assign lang, may have changed
if ("default".equals(lang)) {

@ -78,7 +78,7 @@ public final class Settings_p {
prop.put("port", env.getConfig("port", "8080"));
prop.putHTML("peerName", env.getConfig("peerName", "nameless"));
prop.putHTML("peerName", sb.peers.mySeed().getName());
prop.putHTML("staticIP", env.getConfig("staticIP", ""));
String peerLang = env.getConfig("locale.language", "default");
if (peerLang.equals("default")) peerLang = "en";

@ -60,7 +60,9 @@ public class Status {
// check if the basic configuration was accessed before and forward
prop.put("forwardToConfigBasic", 0);
if ((post == null || !post.containsKey("noforward")) && sb.getConfig("server.servlets.submitted", "").indexOf("ConfigBasic.html") < 0) {
if ((post == null || !post.containsKey("noforward")) &&
sb.getConfig("server.servlets.submitted", "").indexOf("ConfigBasic.html") < 0 &&
yacySeed.isDefaultPeerName(sb.peers.mySeed().getName())) {
// forward to ConfigBasic
prop.put("forwardToConfigBasic", 1);
}
@ -201,7 +203,7 @@ public class Status {
// peer information
String thisHash = "";
final String thisName = sb.getConfig("peerName", "<nameless>");
final String thisName = sb.peers.mySeed().getName();
if (sb.peers.mySeed() == null) {
thisHash = "not assigned";
prop.put("peerAddress", "0"); // not assigned
@ -223,7 +225,7 @@ public class Status {
} else {
prop.put("peerAddress", "1"); // Address
prop.put("peerAddress_address", sb.peers.mySeed().getPublicAddress());
prop.putXML("peerAddress_peername", sb.getConfig("peerName", "<nameless>").toLowerCase());
prop.putXML("peerAddress_peername", sb.peers.mySeed().getName().toLowerCase());
}
}
final String peerStatus = ((sb.peers.mySeed() == null) ? yacySeed.PEERTYPE_VIRGIN : sb.peers.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN));

@ -50,8 +50,8 @@ public class welcome {
// update seed info
sb.updateMySeed();
prop.putHTML("peername", env.getConfig("peerName", "<nameless>"));
prop.putHTML("peerdomain", env.getConfig("peerName", "<nameless>").toLowerCase());
prop.putHTML("peername", sb.peers.mySeed().getName());
prop.putHTML("peerdomain", sb.peers.mySeed().getName().toLowerCase());
prop.putHTML("peeraddress", sb.peers.mySeed().getPublicAddress());
prop.put("hostname", env.myPublicIP());
prop.put("hostip", Domains.dnsResolve(env.myPublicIP()).getHostAddress());

@ -617,7 +617,7 @@ public final class HTTPDFileHandler {
// set environment variables
Map<String, String> env = pb.environment();
env.put("SERVER_SOFTWARE", getDefaultHeaders(path).get(HeaderFramework.SERVER));
env.put("SERVER_NAME", switchboard.getConfig("peerName", "<nameless>"));
env.put("SERVER_NAME", sb.peers.mySeed().getName());
env.put("GATEWAY_INTERFACE", "CGI/1.1");
if (httpVersion != null) {
env.put("SERVER_PROTOCOL", httpVersion);
@ -827,7 +827,7 @@ public final class HTTPDFileHandler {
// add the application version, the uptime and the client name to every rewrite table
templatePatterns.put(servletProperties.PEER_STAT_VERSION, yacyBuildProperties.getVersion());
templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, switchboard.getConfig("peerName", "anomic"));
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, sb.peers.mySeed().getName());
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTID, ((Switchboard) switchboard).peers.myID());
templatePatterns.put(servletProperties.PEER_STAT_MYTIME, GenericFormatter.SHORT_SECOND_FORMATTER.format(new Date()));
yacySeed myPeer = sb.peers.mySeed();

@ -2410,20 +2410,7 @@ public final class Switchboard extends serverSwitch {
return (this.searchQueriesRobinsonFromRemote) * 60d / Math.max(uptime, 1d);
}
public String makeDefaultPeerName() {
String name = myPublicIP() + "-" + yacyCore.speedKey + "dpn" + OS.infoKey() + (System.currentTimeMillis() & 99);
name = name.replace('.', '-');
name = name.replace('_', '-');
name = name.replace(':', '-');
return name;
}
public void updateMySeed() {
if (getConfig("peerName", "anomic").equals("anomic")) {
// generate new peer name
setConfig("peerName", makeDefaultPeerName());
}
peers.mySeed().put(yacySeed.NAME, getConfig("peerName", "nameless"));
peers.mySeed().put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(getConfig("port", "8080"))));
//the speed of indexing (pages/minute) of the peer
@ -2498,7 +2485,6 @@ public final class Switchboard extends serverSwitch {
yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)");
} else {
ssc++;
// final byte[] content = Client.wget(url.toString(), reqHeader, (int) getConfigLong("bootstrapLoadTimeout", 20000));
final byte[] content = client.GETbytes(url.toString());
enu = FileUtils.strings(content);
lc = 0;
@ -2508,9 +2494,6 @@ public final class Switchboard extends serverSwitch {
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());

@ -65,6 +65,7 @@ import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.Digest;
import net.yacy.kelondro.util.MapTools;
import net.yacy.kelondro.util.OS;
import de.anomic.tools.bitfield;
import de.anomic.tools.crypt;
@ -187,7 +188,7 @@ public class yacySeed implements Cloneable {
// settings that can only be computed by originating peer:
// at first startup -
this.hash = theHash; // the hash key of the peer - very important. should be static somehow, even after restart
this.dna.put(yacySeed.NAME, "&empty;");
this.dna.put(yacySeed.NAME, defaultPeerName());
this.dna.put(yacySeed.BDATE, "&empty;");
this.dna.put(yacySeed.UTC, "+0000");
// later during operation -
@ -239,6 +240,14 @@ public class yacySeed implements Cloneable {
return name;
}
/**
* generate a default peer name
* @return
*/
private static String defaultPeerName() {
return "_anon" + OS.infoKey() + "-" + (System.currentTimeMillis() % 77777777L) + "-" + yacyCore.speedKey;
}
/**
* Checks for the static fragments of a generated default peer name, such as the string 'dpn'
* @see #makeDefaultPeerName()
@ -246,11 +255,7 @@ public class yacySeed implements Cloneable {
* @return whether the given peer name may be a default generated peer name
*/
public static boolean isDefaultPeerName(final String name) {
return (name != null &&
name.length() > 10 &&
name.charAt(0) <= '9' &&
name.charAt(name.length() - 1) <= '9' &&
name.indexOf("dpn") > 0);
return name.startsWith("_anon");
}
/**
@ -340,6 +345,12 @@ public class yacySeed implements Cloneable {
return this.dna;
}
public final void setName(String name) {
synchronized (this.dna) {
this.dna.put(yacySeed.NAME, checkPeerName(name));
}
}
public final String getName() {
return checkPeerName(get(yacySeed.NAME, "&empty;"));
}
@ -431,8 +442,6 @@ public class yacySeed implements Cloneable {
public final String getPublicAddress() {
String ip = this.getIP();
if (ip == null || ip.length() < 8) ip = "localhost";
// if (ip.equals(yacyCore.seedDB.mySeed.dna.get(yacySeed.IP))) ip = "127.0.0.1";
// if (this.hash.equals("xxxxxxxxxxxx")) return "192.168.100.1:3300";
final String port = this.dna.get(yacySeed.PORT);
if ((port == null) || (port.length() < 2)) return null;
@ -708,7 +717,7 @@ public class yacySeed implements Cloneable {
final yacySeed newSeed = new yacySeed(hashs);
// now calculate other information about the host
newSeed.dna.put(yacySeed.NAME, (name) == null ? "anonymous" : name);
newSeed.dna.put(yacySeed.NAME, (name) == null ? defaultPeerName() : name);
newSeed.dna.put(yacySeed.PORT, Integer.toString((port <= 0) ? 8080 : port));
newSeed.dna.put(yacySeed.BDATE, GenericFormatter.SHORT_SECOND_FORMATTER.format(new Date(System.currentTimeMillis() /*- DateFormatter.UTCDiff()*/)) );
newSeed.dna.put(yacySeed.LASTSEEN, newSeed.dna.get(yacySeed.BDATE)); // just as initial setting

Loading…
Cancel
Save