diff --git a/defaults/yacy.init b/defaults/yacy.init
index c7e736137..636c74633 100644
--- a/defaults/yacy.init
+++ b/defaults/yacy.init
@@ -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
diff --git a/htroot/ConfigBasic.html b/htroot/ConfigBasic.html
index 665de7ed3..f8066fb36 100644
--- a/htroot/ConfigBasic.html
+++ b/htroot/ConfigBasic.html
@@ -75,7 +75,7 @@
-
+
@@ -99,9 +99,8 @@
-
-
+
What you should do next:
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index c100badb9..6e5c7ec25 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -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)) {
diff --git a/htroot/Settings_p.java b/htroot/Settings_p.java
index 7c46349a2..09072dc14 100644
--- a/htroot/Settings_p.java
+++ b/htroot/Settings_p.java
@@ -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";
diff --git a/htroot/Status.java b/htroot/Status.java
index c5a1ba93f..988f02195 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -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", "");
+ 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", "").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));
diff --git a/htroot/www/welcome.java b/htroot/www/welcome.java
index 74453e680..2224033c6 100644
--- a/htroot/www/welcome.java
+++ b/htroot/www/welcome.java
@@ -50,8 +50,8 @@ public class welcome {
// update seed info
sb.updateMySeed();
- prop.putHTML("peername", env.getConfig("peerName", ""));
- prop.putHTML("peerdomain", env.getConfig("peerName", "").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());
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index c1b83c9bc..7721e7d91 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -617,7 +617,7 @@ public final class HTTPDFileHandler {
// set environment variables
Map env = pb.environment();
env.put("SERVER_SOFTWARE", getDefaultHeaders(path).get(HeaderFramework.SERVER));
- env.put("SERVER_NAME", switchboard.getConfig("peerName", ""));
+ 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();
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 3d95a9fd9..6129f2f49 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -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());
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 7bac77c44..14422d1cc 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -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, "∅");
+ this.dna.put(yacySeed.NAME, defaultPeerName());
this.dna.put(yacySeed.BDATE, "∅");
this.dna.put(yacySeed.UTC, "+0000");
// later during operation -
@@ -238,6 +239,14 @@ public class yacySeed implements Cloneable {
name = gtp.matcher(name).replaceAll("_");
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'
@@ -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, "∅"));
}
@@ -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