Author: ljn1981
Date: 2006-04-24 20:07:01 +0000 (Mon, 24 Apr 2006)
New Revision: 8574

Added:
   trunk/freenet/src/freenet/node/IPUndetectedUserAlert.java
Modified:
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/Version.java
Log:
Fixing bug #196. Thanks to railk on #freenet for the code.

Added: trunk/freenet/src/freenet/node/IPUndetectedUserAlert.java
===================================================================
--- trunk/freenet/src/freenet/node/IPUndetectedUserAlert.java   2006-04-24 
17:41:12 UTC (rev 8573)
+++ trunk/freenet/src/freenet/node/IPUndetectedUserAlert.java   2006-04-24 
20:07:01 UTC (rev 8574)
@@ -0,0 +1,28 @@
+package freenet.node;
+
+public class IPUndetectedUserAlert implements UserAlert {
+
+       public boolean userCanDismiss() {
+               return true;
+       }
+
+       public String getTitle() {
+               return "Unknown external address";
+       }
+
+       public String getText() {
+               return "Freenet was unable to determine your external IP 
address " +
+                       "(or the IP address of your NAT or Firewall). You can 
still exchange " +
+                       "references with other people, however this will only 
work if the other " +
+                       "user is not behind a NAT or Firewall. As soon as you 
have connected to " +
+                       "one other user in this way, Freenet will be able to 
determine your external IP address.";
+       }
+
+       public short getPriorityClass() {
+               return UserAlert.ERROR;
+       }
+       
+       public boolean isValid() {
+               return true;
+       }
+}

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-04-24 17:41:12 UTC (rev 
8573)
+++ trunk/freenet/src/freenet/node/Node.java    2006-04-24 20:07:01 UTC (rev 
8574)
@@ -103,6 +103,8 @@
  */
 public class Node {

+       private static IPUndetectedUserAlert primaryIPUndetectedAlert;
+       
        public class MyRequestThrottle implements BaseRequestThrottle {

                private final BootstrappingDecayingRunningAverage 
roundTripTime; 
@@ -1602,10 +1604,17 @@
                                }
                        }
                        lastIPAddress = best;
-               return best;
                }
-               lastIPAddress = oldIPAddress;
-               return oldIPAddress;
+               else {
+                       lastIPAddress = oldIPAddress;
+               }
+               if (lastIPAddress == null) {
+                       this.alerts.register(primaryIPUndetectedAlert);
+               }
+               else     {
+                       this.alerts.unregister(primaryIPUndetectedAlert);
+               }
+               return lastIPAddress;
     }

     InetAddress getPrimaryIPAddress() {

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-04-24 17:41:12 UTC (rev 
8573)
+++ trunk/freenet/src/freenet/node/Version.java 2006-04-24 20:07:01 UTC (rev 
8574)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 653;
+       private static final int buildNumber = 654;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 591;


Reply via email to