@@ -62,6 +62,8 @@ public void shouldUpdate(){
62
62
String overrideIPAddressString ;
63
63
/** IP address from last time */
64
64
FreenetInetAddress oldIPAddress ;
65
+ /** Whether the oldIPAddress comes from an address hint */
66
+ boolean hasIPAddressHint = false ;
65
67
/** Detected IP's and their NAT status from plugins */
66
68
DetectedIP [] pluginDetectedIPs ;
67
69
/** Last detected IP address */
@@ -341,7 +343,11 @@ private boolean innerDetect(List<FreenetInetAddress> addresses) {
341
343
}
342
344
343
345
// 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 )) {
345
351
addresses .add (oldIPAddress );
346
352
// Don't set addedValidIP.
347
353
// There is an excellent chance that this is out of date.
@@ -508,7 +514,9 @@ public void set(String val) throws InvalidConfigValueException {
508
514
if (overrideIPAddress != null ) return ;
509
515
try {
510
516
oldIPAddress = new FreenetInetAddress (val , false );
517
+ hasIPAddressHint = true ;
511
518
} catch (UnknownHostException e ) {
519
+ hasIPAddressHint = false ;
512
520
throw new InvalidConfigValueException ("Unknown host: " +e .getMessage ());
513
521
}
514
522
redetectAddress ();
@@ -519,11 +527,13 @@ public void set(String val) throws InvalidConfigValueException {
519
527
if (ipHintString .length () > 0 ) {
520
528
try {
521
529
oldIPAddress = new FreenetInetAddress (ipHintString , false );
530
+ hasIPAddressHint = true ;
522
531
} catch (UnknownHostException e ) {
523
532
String msg = "Unknown host: " +ipHintString +" in config: " +e .getMessage ();
524
533
Logger .error (this , msg );
525
534
System .err .println (msg );
526
535
oldIPAddress = null ;
536
+ hasIPAddressHint = false ;
527
537
}
528
538
}
529
539
0 commit comments