Skip to content
Permalink
Browse files

Removed more remaining uses of deprecated Seed.getIP() function.

  • Loading branch information...
luccioman committed Apr 29, 2018
1 parent b81debc commit e67df103b5ae8cc86a781164731accb99e353990
Showing with 25 additions and 9 deletions.
  1. +20 −7 htroot/CrawlStartScanner_p.java
  2. +5 −2 source/net/yacy/peers/Network.java
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -94,14 +95,26 @@ public static serverObjects respond(
} else {
ip = Domains.dnsResolve("192.168.0.1");
}
} else {
ip = Domains.myPublicLocalIP();
if ( Domains.isThisHostIP(ip) ) {
ip = Domains.dnsResolve(sb.peers.mySeed().getIP());
if ( ip != null ) {
hostSet.add(ip.getHostAddress());
}
}
if ( ip != null ) {
hostSet.add(ip.getHostAddress());
} else {
final Set<InetAddress> myPublicIPs = new HashSet<InetAddress>();
myPublicIPs.addAll(Domains.myPublicIPv4());
myPublicIPs.addAll(Domains.myPublicIPv6());
for(final InetAddress myPublicIP: myPublicIPs) {
if (Domains.isThisHostIP(myPublicIP)) {
final Set<String> myIPs = sb.peers.mySeed().getIPs();
for(final String myIP: myIPs) {
ip = Domains.dnsResolve(myIP);
if(ip != null) {
hostSet.add(ip.getHostAddress());
}
}
} else {
hostSet.add(myPublicIP.getHostAddress());
}
}
}
}
String hos = ""; for (String s: hostSet) hos += s + "\n";
@@ -588,7 +588,7 @@ public static final String saveSeedList(final Switchboard sb) {
String logt;

// be shure that we have something to say
if ( sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()) == null ) {
if (sb.peers.mySeed().getIPs().isEmpty()) {
final String errorMsg = "We have no valid IP address until now";
log.warn("SaveSeedList: " + errorMsg);
return errorMsg;
@@ -702,7 +702,10 @@ public static final String saveSeedList(final Switchboard sb) {
} finally {
sb.peers.lastSeedUpload_seedDBSize = sb.peers.sizeConnected();
sb.peers.lastSeedUpload_timeStamp = System.currentTimeMillis();
sb.peers.lastSeedUpload_myIP = sb.peers.mySeed().getIP();
final Set<String> myIPs = sb.peers.myIPs();
if(!myIPs.isEmpty()) {
sb.peers.lastSeedUpload_myIP = myIPs.iterator().next();
}
}
}

0 comments on commit e67df10

Please sign in to comment.
You can’t perform that action at this time.