Author: toad
Date: 2006-06-20 21:27:15 +0000 (Tue, 20 Jun 2006)
New Revision: 9322

Modified:
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/Version.java
Log:
829: #204: add a config option to tell the node "this is the current ip 
address, but it may change, so delete it from the config file when it's written 
to the node file, and ignore it if you get any new information"

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-06-20 21:15:43 UTC (rev 
9321)
+++ trunk/freenet/src/freenet/node/Node.java    2006-06-20 21:27:15 UTC (rev 
9322)
@@ -42,7 +42,6 @@
 import freenet.client.async.ClientGetter;
 import freenet.client.async.ClientPutter;
 import freenet.client.async.ClientRequestScheduler;
-import freenet.client.async.RequestScheduler;
 import freenet.client.async.USKManager;
 import freenet.clients.http.BookmarkManager;
 import freenet.clients.http.FProxyToadlet;
@@ -1003,6 +1002,46 @@
                        }
                }

+               // Temporary IP address hint
+               
+               nodeConfig.register("tempIPAddressHint", "", 0, true, 
"Temporary IP address hint", "Temporary hint to what our IP might be; deleted 
after use", new StringCallback() {
+
+                       public String get() {
+                               return null;
+                       }
+                       
+                       public void set(String val) throws 
InvalidConfigValueException {
+                               if(val.length() == 0) {
+                                       return;
+                               }
+                               if(overrideIPAddress != null) return;
+                               try {
+                                       ipAddressHint = new 
FreenetInetAddress(val, false);
+                               } catch (UnknownHostException e) {
+                                       throw new 
InvalidConfigValueException("Unknown host: "+e.getMessage());
+                               }
+                               redetectAddress();
+                               shouldInsertARK();
+                       }
+                       
+               });
+               
+               String ipHintString = nodeConfig.getString("tempIPAddressHint");
+               if(ipOverrideString.length() == 0)
+                       overrideIPAddress = null;
+               else {
+                       try {
+                               ipAddressHint = new 
FreenetInetAddress(ipOverrideString, false);
+                       } catch (UnknownHostException e) {
+                               String msg = "Unknown host: 
"+ipOverrideString+" in config: "+e.getMessage();
+                               Logger.error(this, msg);
+                               System.err.println(msg+"");
+                               overrideIPAddress = null;
+                       }
+               }
+               
+               
+               
                // Determine where to bind to


@@ -2109,7 +2148,10 @@
                return fs;
        }

+       /** Explicit forced IP address */
        FreenetInetAddress overrideIPAddress;
+       /** Temporary hint at IP address if all else fails */
+       FreenetInetAddress ipAddressHint;
        /** IP address from last time */
        InetAddress oldIPAddress;
        /** Last detected IP address */
@@ -2173,10 +2215,13 @@
                                }
                        }
                        lastIPAddress = best == null ? null : new 
FreenetInetAddress(best);
-               }
-               else {
+               } else {
                        lastIPAddress = oldIPAddress == null ? null : new 
FreenetInetAddress(oldIPAddress);
                }
+               if(lastIPAddress == null) {
+                       lastIPAddress = ipAddressHint;
+                       ipAddressHint = null;
+               }
                if (lastIPAddress == null) {
                        this.alerts.register(primaryIPUndetectedAlert);
                } else {

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-06-20 21:15:43 UTC (rev 
9321)
+++ trunk/freenet/src/freenet/node/Version.java 2006-06-20 21:27:15 UTC (rev 
9322)
@@ -18,7 +18,7 @@
        public static final String protocolVersion = "1.0";

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

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


Reply via email to