Author: nextgens
Date: 2006-05-18 12:22:47 +0000 (Thu, 18 May 2006)
New Revision: 8762
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/PeerNode.java
Log:
resolves 0000231: Can add self as Darknet reference
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-05-18 11:45:17 UTC (rev 8761)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-05-18 12:22:47 UTC (rev 8762)
@@ -358,7 +358,7 @@
this.sendErrorPage(ctx, 200, "Failed to add
node", "Unable to parse the given text: <pre>"+ref+"</pre> as a node reference:
"+e1+". Please <a href=\".\">Try again</a>.");
return;
}
- if(!this.node.addDarknetConnection(pn)) {
+ if(pn.getIdentity()==node.getIndentity() ||
!this.node.addDarknetConnection(pn)) {
this.sendErrorPage(ctx, 200, "Failed to add
node", "We already have the given reference. Return to the connections page <a
href=\".\">here</a>.");
return;
}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-05-18 11:45:17 UTC (rev
8761)
+++ trunk/freenet/src/freenet/node/Node.java 2006-05-18 12:22:47 UTC (rev
8762)
@@ -18,7 +18,6 @@
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
-import java.net.SocketException;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -2602,6 +2601,10 @@
return this.bindto;
}
+ public int getIndentity(){
+ return Fields.hashCode(identityHash);
+ }
+
public boolean setNewestPeerLastGoodVersion( int version ) {
if( version > buildOldAgeUserAlert.lastGoodVersion ) {
if( buildOldAgeUserAlert.lastGoodVersion == 0 ) {
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-05-18 11:45:17 UTC
(rev 8761)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-05-18 12:22:47 UTC
(rev 8762)
@@ -471,6 +471,13 @@
}
/**
+ * Returns a unique node identifier (usefull to compare 2 pn)
+ */
+ public int getIdentity(){
+ return hashCode;
+ }
+
+ /**
* Is this node too new for us? (i.e. our version if older than it's
lastGoodVersion)
*
*/