Author: toad
Date: 2006-06-21 20:38:50 +0000 (Wed, 21 Jun 2006)
New Revision: 9341
Modified:
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/Version.java
Log:
833: Fix bug in code related to IP address detection.
We weren't using the oldIPAddress (hence #204 fix wasn't working), and we
weren't showing the useralert for no IP address.
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-06-21 20:22:09 UTC (rev
9340)
+++ trunk/freenet/src/freenet/node/Node.java 2006-06-21 20:38:50 UTC (rev
9341)
@@ -2191,29 +2191,31 @@
countsByPeer.put(ip, new Integer(1));
}
}
- if(countsByPeer.size() == 0) return null;
- Iterator it = countsByPeer.keySet().iterator();
if(countsByPeer.size() == 1) {
- FreenetInetAddress a = new
FreenetInetAddress((InetAddress)it.next());
+ Iterator it = countsByPeer.keySet().iterator();
+ FreenetInetAddress a = new
FreenetInetAddress((InetAddress)(it.next()));
lastIPAddress = a;
return a;
+ } else if(countsByPeer.size() > 1) {
+ Iterator it = countsByPeer.keySet().iterator();
+ // Pick most popular address
+ // FIXME use multi-homing here
+ InetAddress best = null;
+ int bestPopularity = 0;
+ while(it.hasNext()) {
+ InetAddress cur = (InetAddress)
it.next();
+ int curPop = ((Integer)
(countsByPeer.get(cur))).intValue();
+ if(curPop > bestPopularity) {
+ bestPopularity = curPop;
+ best = cur;
+ }
+ }
+ lastIPAddress = best == null ? null : new
FreenetInetAddress(best);
}
- // Pick most popular address
- // FIXME use multi-homing here
- InetAddress best = null;
- int bestPopularity = 0;
- while(it.hasNext()) {
- InetAddress cur = (InetAddress) it.next();
- int curPop = ((Integer)
(countsByPeer.get(cur))).intValue();
- if(curPop > bestPopularity) {
- bestPopularity = curPop;
- best = cur;
- }
- }
- lastIPAddress = best == null ? null : new
FreenetInetAddress(best);
- } else {
- lastIPAddress = oldIPAddress == null ? null :
oldIPAddress;
}
+ if(lastIPAddress == null) {
+ if(oldIPAddress != null) lastIPAddress = oldIPAddress;
+ }
if (lastIPAddress == null) {
this.alerts.register(primaryIPUndetectedAlert);
} else {
@@ -2751,6 +2753,7 @@
FreenetInetAddress newIP = detectPrimaryIPAddress();
shouldInsertARK();
if(newIP == null || newIP.equals(lastIP)) return;
+ lastIP = newIP;
writeNodeFile();
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-06-21 20:22:09 UTC (rev
9340)
+++ trunk/freenet/src/freenet/node/Version.java 2006-06-21 20:38:50 UTC (rev
9341)
@@ -18,7 +18,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 832;
+ private static final int buildNumber = 833;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 765;