Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

name check on new peer names

orbiter7eb3c81aada8
diff --git a/doc/News.html b/doc/News.html
index da9216136..51e8a5b2c 100644
--- a/doc/News.html
+++ b/doc/News.html
@@ -37,6 +37,18 @@ globalheader();
-->
+<br><p>v0.37
+<ul>
+<li>Check on new peer names: must not occur already and may only contain letters, numbers and '_' or '-'.</li>
+<li></li>
+<li></li>
+<li></li>
+<li></li>
+<li></li>
+</ul>
+
+
+
<br><p>v0.36_build20050326
<ul>
<li>Enhanced thread control and added performance menu: this can be used to steer scheduling tasks and for profiling.</li>
diff --git a/htroot/SettingsAck_p.html b/htroot/SettingsAck_p.html
index 319090ad2..601c9a385 100644
--- a/htroot/SettingsAck_p.html
+++ b/htroot/SettingsAck_p.html
@@ -58,7 +58,13 @@ You are now permanently <b>online</b>. After a short while you should see the ef
::
<b>The remote-proxy setting has been changed</b><br>
The new setting is effective immediately, you don't need to re-start.
-#(/info)#
+::
+<b>The submitted peer name is already used by another peer. Please choose a different name.</b><br>
+The settings have not been changed.
+::
+<b>The submitted peer name is not well-formed. Please choose a different name.</b><br>
+Peer names must not contain characters other than (a-z, A-Z, 0-9, '-', '_') and must not be longer than 80 characters.
+The settings have not been changed.#(/info)#
</p>
<p>You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.</p>
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 76013d090..3cccb1335 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -191,15 +191,35 @@ public class SettingsAck_p {
String port = (String) post.get("port");
String peerName = (String) post.get("peername");
String shutdownWaiting = (String) post.get("shutdownWaiting");
- String info = "";
- env.setConfig("port", port);
- env.setConfig("peerName", peerName);
- env.setConfig("shutdownWaiting", shutdownWaiting);
- prop.put("info", 12);//port or peername changed
- prop.put("info_port", port);
- prop.put("info_peerName", peerName);
- prop.put("info_shutdownWaiting", shutdownWaiting);
+ // check if peer name already exists
+ yacySeed oldSeed = yacyCore.seedDB.lookupByName(peerName);
+
+ if (oldSeed == null) {
+ // the name is new
+ boolean nameOK = (peerName.length() <= 80);
+ for (int i = 0; i < peerName.length(); i++) {
+ if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_".indexOf(peerName.charAt(i)) < 0) nameOK = false;
+ }
+ if (!(nameOK)) {
+ // deny change
+ prop.put("info", 17);//peer name is wrong
+ } else {
+
+ // set values
+ env.setConfig("port", port);
+ env.setConfig("peerName", peerName);
+ env.setConfig("shutdownWaiting", shutdownWaiting);
+
+ prop.put("info", 12);//port or peername changed
+ prop.put("info_port", port);
+ prop.put("info_peerName", peerName);
+ prop.put("info_shutdownWaiting", shutdownWaiting);
+ }
+ } else {
+ // deny change
+ prop.put("info", 16);//peer name is already used by another peer
+ }
return prop;
}
diff --git a/htroot/Settings_p.html b/htroot/Settings_p.html
index c686b9abc..fd5628838 100644
--- a/htroot/Settings_p.html
+++ b/htroot/Settings_p.html
@@ -47,7 +47,7 @@ delete the file 'DATA/SETTINGS/httpProxy.conf' in the YaCy application root fold
</tr>
<tr valign="top">
<td>Peer Name:</td>
- <td><input name="peername" type="text" size="32" maxlength="32" value="#[peerName]#"></td>
+ <td><input name="peername" type="text" size="32" maxlength="80" value="#[peerName]#"></td>
<td><b>Your peer name defines also a new '.yacy' - domain, which can be accessed from every peer running this proxy.
Using your 'Home Page' and 'File Share' - zones you also have a platform to provide content to your new domain.</b><br>
<i>(hint: choose a name that appears on a web page that tells something about you, vistit the page, get the 'senior' status, and you can be found..)</i></td>
diff --git a/makerelease.sh b/makerelease.sh
index 2156049d6..da93b5110 100755
--- a/makerelease.sh
+++ b/makerelease.sh
@@ -45,10 +45,10 @@
# Contributions and changes to the program code must be marked as such.
# define variables
-version='0.36'
+version='0.361'
datestr=`date +%Y%m%d`
-release='yacy_v'$version'_'$datestr
-#release='yacy_dev_v'$version'_'$datestr
+#release='yacy_v'$version'_'$datestr
+release='yacy_dev_v'$version'_'$datestr
target='RELEASE'
classes='classes'
source='source'