Author: toad
Date: 2008-09-02 18:12:25 +0000 (Tue, 02 Sep 2008)
New Revision: 22358

Modified:
   trunk/freenet/src/freenet/node/NodeIPDetector.java
Log:
Trust isRealConnection()'s *and* SeedServerPeerNode's when determining our IP 
address.
Thus as soon as we have a seed connection, we can announce with what is 
hopefully our real IP address.
This means that we don't need to specify our local IP when testing 
bootstrapping, and may help some nodes too if UPnP and STUN fail.


Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java  2008-09-02 17:47:07 UTC 
(rev 22357)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java  2008-09-02 18:12:25 UTC 
(rev 22358)
@@ -195,10 +195,16 @@

                // Try to pick it up from our connections
                if(node.peers != null) {
-                       PeerNode[] peerList = node.peers.connectedPeers;
+                       PeerNode[] peerList = node.peers.myPeers;
                        HashMap countsByPeer = new HashMap();
                        // FIXME use a standard mutable int object, we have one 
somewhere
                        for(int i=0;i<peerList.length;i++) {
+                               if(!peerList[i].isConnected()) continue;
+                               if(!peerList[i].isRealConnection()) {
+                                       // Only let seed server connections 
through.
+                                       // We have to trust them anyway.
+                                       if(!(peerList[i] instanceof 
SeedServerPeerNode)) continue;
+                               }
                                Peer p = peerList[i].getRemoteDetectedPeer();
                                if(p == null || p.isNull()) continue;
                                FreenetInetAddress addr = p.getFreenetAddress();


Reply via email to