@@ -62,6 +62,8 @@ public void shouldUpdate(){
6262 String overrideIPAddressString ;
6363 /** IP address from last time */
6464 FreenetInetAddress oldIPAddress ;
65+ /** Whether the oldIPAddress comes from an address hint */
66+ boolean hasIPAddressHint = false ;
6567 /** Detected IP's and their NAT status from plugins */
6668 DetectedIP [] pluginDetectedIPs ;
6769 /** Last detected IP address */
@@ -341,7 +343,11 @@ private boolean innerDetect(List<FreenetInetAddress> addresses) {
341343 }
342344
343345 // Add the old address only if we have no choice, or if we only have the word of two peers to go on.
344- if ((!(hadAddedValidIP || confidence > 2 )) && (oldIPAddress != null ) && !oldIPAddress .equals (overrideIPAddress )) {
346+ // except if it is the ip address hint
347+ if (((!hadAddedValidIP || confidence <= 2 || hasIPAddressHint )
348+ && (oldIPAddress != null )
349+ && !oldIPAddress .equals (overrideIPAddress )
350+ && !addresses .contains (oldIPAddress )) {
345351 addresses .add (oldIPAddress );
346352 // Don't set addedValidIP.
347353 // There is an excellent chance that this is out of date.
@@ -508,7 +514,9 @@ public void set(String val) throws InvalidConfigValueException {
508514 if (overrideIPAddress != null ) return ;
509515 try {
510516 oldIPAddress = new FreenetInetAddress (val , false );
517+ hasIPAddressHint = true ;
511518 } catch (UnknownHostException e ) {
519+ hasIPAddressHint = false ;
512520 throw new InvalidConfigValueException ("Unknown host: " +e .getMessage ());
513521 }
514522 redetectAddress ();
@@ -519,11 +527,13 @@ public void set(String val) throws InvalidConfigValueException {
519527 if (ipHintString .length () > 0 ) {
520528 try {
521529 oldIPAddress = new FreenetInetAddress (ipHintString , false );
530+ hasIPAddressHint = true ;
522531 } catch (UnknownHostException e ) {
523532 String msg = "Unknown host: " +ipHintString +" in config: " +e .getMessage ();
524533 Logger .error (this , msg );
525534 System .err .println (msg );
526535 oldIPAddress = null ;
536+ hasIPAddressHint = false ;
527537 }
528538 }
529539
0 commit comments