Author: toad
Date: 2008-11-29 14:40:28 +0000 (Sat, 29 Nov 2008)
New Revision: 23970

Modified:
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Bug #2688:
Do not clear the nominalPeers on connect! We were clearing it on connecting, 
including rekeys! And of course, a differential noderef will only be sent if 
it's NOT a rekey... (note a related bug fixed in 1186 - we could end up not 
sending one because we thought it was a rekey when it actually wasn't)
Do not clear it on getting an ARK or diff noderef with an empty physical.udp 
either.
Logging.


Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-11-29 14:37:18 UTC 
(rev 23969)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-11-29 14:40:28 UTC 
(rev 23970)
@@ -2345,20 +2345,17 @@
                                        Logger.minor(this, "Invalid or null 
location, waiting for FNPLocChangeNotification: " + e);
                        }
                }
-               Vector<Peer> oldNominalPeer = nominalPeer;
-
-               if(nominalPeer == null)
-                       nominalPeer = new Vector<Peer>();
-               nominalPeer.removeAllElements();
-
-               Peer[] oldPeers = nominalPeer.toArray(new 
Peer[nominalPeer.size()]);
-
-               boolean refHadPhysicalUDP = false;
-
                try {
                        String physical[] = fs.getAll("physical.udp");
                        if(physical != null) {
-                               refHadPhysicalUDP = true;
+                               Vector<Peer> oldNominalPeer = nominalPeer;
+
+                               if(nominalPeer == null)
+                                       nominalPeer = new Vector<Peer>();
+                               nominalPeer.removeAllElements();
+
+                               Peer[] oldPeers = nominalPeer.toArray(new 
Peer[nominalPeer.size()]);
+
                                for(int i = 0; i < physical.length; i++) {
                                        Peer p;
                                        try {
@@ -2376,32 +2373,25 @@
                                                nominalPeer.addElement(p);
                                        }
                                }
+                               if(!Arrays.equals(oldPeers, 
nominalPeer.toArray(new Peer[nominalPeer.size()]))) {
+                                       changedAnything = true;
+                                       if(logMINOR) Logger.minor(this, "Got 
new physical.udp for "+this+" : "+Arrays.toString(nominalPeer.toArray()));
+                                       lastAttemptedHandshakeIPUpdateTime = 0;
+                                       // Clear nonces to prevent leak. Will 
kill any in-progress connect attempts, but that is okay because
+                                       // either we got an ARK which changed 
our peers list, or we just connected.
+                                       jfkNoncesSent.clear();
+                               }
+
+                       } else if(forDiffNodeRef || forARK) {
+                               // Connection setup doesn't count, it doesn't 
send a physical.udp.
+                               // Keep the old version anyway...
+                               Logger.error(this, "Noderef has no physical.udp 
for "+this+" : forDiffNodeRef="+forDiffNodeRef+" forARK="+forARK);
                        }
                } catch(Exception e1) {
                        Logger.error(this, "Caught "+e1, e1);
                        throw new FSParseException(e1);
                }
 
-               // Don't act as if we got an empty physical.udp if we didn't
-               // even have that field in our ref for builds 1102 and later,
-               // making the physical.udp field itself clearly optional in all
-               // new-ref-for-existing-peer contexts
-               if(refHadPhysicalUDP || (!forDiffNodeRef && 1102 > 
simpleVersion)) {
-                       if(!Arrays.equals(oldPeers, nominalPeer.toArray(new 
Peer[nominalPeer.size()]))) {
-                               changedAnything = true;
-                               lastAttemptedHandshakeIPUpdateTime = 0;
-                               // Clear nonces to prevent leak. Will kill any 
in-progress connect attempts, but that is okay because
-                               // either we got an ARK which changed our peers 
list, or we just connected.
-                               jfkNoncesSent.clear();
-                       }
-
-                       // DO NOT change detectedPeer !!!
-                       // The given physical.udp may be WRONG!!!
-
-                       // In future, ARKs may support automatic transition 
when the ARK key is changed.
-                       // So parse it anyway. If it fails, no big loss; it 
won't even log an error.
-               }
-
                if(logMINOR)
                        Logger.minor(this, "Parsed successfully; 
changedAnything = " + changedAnything);
 

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to