Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Removed some remaining uses of deprecated Seed.getIP()

lucciomanaddd18c9935b
diff --git a/htroot/Load_MediawikiWiki.html b/htroot/Load_MediawikiWiki.html
index 36442fa4d..7e1f9c6f5 100644
--- a/htroot/Load_MediawikiWiki.html
+++ b/htroot/Load_MediawikiWiki.html
@@ -85,11 +85,11 @@
<li>Insert the following code:
<pre>
&lt;p&gt;Search with YaCy in this Wiki:&lt;/p&gt;
-&lt;script src="http://#[address]#/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
+&lt;script src="#[address]#/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function() {
yconf = {
- url : 'http://#[address]#/',
+ url : '#[address]#/',
theme : 'smoothness',
title : 'YaCy Wiki Search',
urlmaskfilter : '.*',
@@ -100,7 +100,7 @@
});
&lt;/script&gt;
&lt;div id="yacylivesearch"&gt;
- &lt;form id="ysearch" method="get" accept-charset="UTF-8" action="http://#[address]#/yacysearch.html"&gt;
+ &lt;form id="ysearch" method="get" accept-charset="UTF-8" action="#[address]#/yacysearch.html"&gt;
&lt;input name="search" id="yquery" type="text" size="15" maxlength="80" value=""/&gt;
&lt;input type="hidden" name="verify" value="false" /&gt;
&lt;input type="hidden" name="maximumRecords" value="10" /&gt;
diff --git a/htroot/Load_MediawikiWiki.java b/htroot/Load_MediawikiWiki.java
index 59b8a4ed2..8af1c8fe1 100644
--- a/htroot/Load_MediawikiWiki.java
+++ b/htroot/Load_MediawikiWiki.java
@@ -24,6 +24,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import java.util.Set;
+
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@@ -32,20 +34,21 @@ import net.yacy.server.serverSwitch;
public class Load_MediawikiWiki {
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
// return variable that accumulates replacements
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
// define visible variables
- String a;
- if (sb.peers.myIPs().isEmpty()) {
- a = "localhost:" + sb.getLocalPort();
+ String myUrl;
+ final Set<String> myIps = sb.peers.mySeed().getIPs();
+ if (myIps.isEmpty()) {
+ myUrl = "http://localhost:" + sb.getLocalPort();
} else {
- a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
+ myUrl = sb.peers.mySeed().getPublicURL(myIps.iterator().next(), true);
}
prop.put("starturl", "http://");
- prop.put("address", a);
+ prop.put("address", myUrl);
// hidden form param : clean up search events cache ?
if (post != null && post.containsKey("cleanSearchCache")) {
diff --git a/htroot/Load_PHPBB3.html b/htroot/Load_PHPBB3.html
index c49583cba..572537b0e 100644
--- a/htroot/Load_PHPBB3.html
+++ b/htroot/Load_PHPBB3.html
@@ -77,11 +77,11 @@
<li>find the line where the default search window is displayed, thats right behind the <pre>&lt;div id="search-box"&gt;</pre> statement</li>
<li>Insert the following code right behind the div tag:
<pre>
-&lt;script src="http://#[address]#/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
+&lt;script src="#[address]#/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function() {
yconf = {
- url : 'http://#[address]#/',
+ url : '#[address]#/',
title : 'YaCy Forum Search',
width : 500,
height : 600,
@@ -91,7 +91,7 @@
});
&lt;/script&gt;
&lt;div id="yacylivesearch"&gt;
- &lt;form id="ysearch" method="get" accept-charset="UTF-8" action="http://#[address]#/yacysearch.html"&gt;
+ &lt;form id="ysearch" method="get" accept-charset="UTF-8" action="#[address]#/yacysearch.html"&gt;
&lt;input name="search" id="yquery" type="text" size="16" maxlength="128" title="{L_SEARCH_KEYWORDS}" class="inputbox search" value=""/&gt;
&lt;input type="hidden" name="verify" value="cacheonly" /&gt;
&lt;input type="hidden" name="maximumRecords" value="10" /&gt;
diff --git a/htroot/Load_PHPBB3.java b/htroot/Load_PHPBB3.java
index a3c8643c3..899394ae1 100644
--- a/htroot/Load_PHPBB3.java
+++ b/htroot/Load_PHPBB3.java
@@ -24,6 +24,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import java.util.Set;
+
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@@ -32,18 +34,22 @@ import net.yacy.server.serverSwitch;
public class Load_PHPBB3 {
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
// return variable that accumulates replacements
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
// define visible variables
- String a = sb.peers.mySeed().getIP() == null ? null : sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
- if (a == null) a = "localhost:" + sb.getLocalPort();
+ String myUrl;
+ final Set<String> myIps = sb.peers.mySeed().getIPs();
+ if (myIps.isEmpty()) {
+ myUrl = "http://localhost:" + sb.getLocalPort();
+ } else {
+ myUrl = sb.peers.mySeed().getPublicURL(myIps.iterator().next(), true);
+ }
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
- final String repository = "http://" + a + "/";
- prop.put("starturl", (intranet) ? repository : "http://");
- prop.put("address", a);
+ prop.put("starturl", (intranet) ? myUrl : "http://");
+ prop.put("address", myUrl);
// hidden form param : clean up search events cache ?
if (post != null && post.containsKey("cleanSearchCache")) {
diff --git a/htroot/Network.java b/htroot/Network.java
index 11416b7e9..abc29b513 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -374,11 +374,15 @@ public class Network {
}
if (abort) continue;
}
+ final Set<String> ips = seed.getIPs();
+ if(ips.isEmpty()) {
+ continue;
+ }
prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 0);
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", 0);
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
- String ip = seed.getIP();
+ final String ip = ips.iterator().next();
if (conCount >= maxCount) { break; }
if (sb.peers != null && sb.peers.mySeed() != null && seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {
prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
@@ -419,7 +423,7 @@ public class Network {
prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink"));
prop.put(STR_TABLE_LIST + conCount + "_special", (seed.getFlagRootNode() && !seed.getFlagAcceptRemoteIndex()) ? 1 : 0);
prop.put(STR_TABLE_LIST + conCount + "_ssl", (seed.getFlagSSLAvailable()) ? 1 : 0);
- prop.put(STR_TABLE_LIST + conCount + "_ssl_ip", seed.getIP());
+ prop.put(STR_TABLE_LIST + conCount + "_ssl_ip", ip);
prop.put(STR_TABLE_LIST + conCount + "_ssl_portssl", seed.get(Seed.PORTSSL,"8443"));
userAgent = null;
if (seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {
@@ -436,9 +440,8 @@ public class Network {
}
prop.putHTML(STR_TABLE_LIST + conCount + "_location", location);
String port = seed.get(Seed.PORT, "-");
- Set<String> ips = seed.getIPs();
int ipsc = 0;
- for (String s: ips) {
+ for (final String s: ips) {
prop.put(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_nodestate", seed.getFlagRootNode() ? 1 : 0);
prop.put(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c", c ? 1 : 0);
prop.putHTML(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c_hash", seed.hash);
diff --git a/htroot/Status.java b/htroot/Status.java
index 091981c60..aa409d75a 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -226,12 +226,13 @@ public class Status
prop.put("peerStatistics", "1");
prop.put("peerStatistics_uptime", PeerActions.formatInterval(uptime));
thisHash = sb.peers.mySeed().hash;
- if ( sb.peers.mySeed().getIPs().size() == 0 ) {
+ final Set<String> myIps = sb.peers.mySeed().getIPs();
+ if ( myIps.size() == 0 ) {
prop.put("peerAddress", "0"); // not assigned + instructions
prop.put("warningGoOnline", "1");
} else {
prop.put("peerAddress", "1"); // Address
- prop.put("peerAddress_address", sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()));
+ prop.put("peerAddress_address", sb.peers.mySeed().getPublicAddress(myIps.iterator().next()));
prop.putXML("peerAddress_peername", sb.peers.mySeed().getName().toLowerCase());
}
}
diff --git a/htroot/Surftips.java b/htroot/Surftips.java
index 33b59d197..893a27a5d 100644
--- a/htroot/Surftips.java
+++ b/htroot/Surftips.java
@@ -29,6 +29,7 @@ import java.net.MalformedURLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Set;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.encoding.UTF8;
@@ -278,14 +279,17 @@ public class Surftips {
Seed seed = sb.peers.getConnected(record.originator());
if (seed == null) seed = sb.peers.getDisconnected(record.originator());
if (seed != null) {
- url = "http://" + seed.getPublicAddress(seed.getIP()) + "/Wiki.html?page=" + record.attribute("page", "");
- entry = rowdef.newEntry(new byte[][]{
- UTF8.getBytes(url),
- UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
- UTF8.getBytes("Wiki Update: " + record.attribute("description", "")),
- UTF8.getBytes(record.id())
- });
- score = 4 + timeFactor(record.created());
+ final Set<String> ips = seed.getIPs();
+ if(!ips.isEmpty()) {
+ url = seed.getPublicURL(ips.iterator().next(), false) + "/Wiki.html?page=" + record.attribute("page", "");
+ entry = rowdef.newEntry(new byte[][]{
+ UTF8.getBytes(url),
+ UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
+ UTF8.getBytes("Wiki Update: " + record.attribute("description", "")),
+ UTF8.getBytes(record.id())
+ });
+ score = 4 + timeFactor(record.created());
+ }
}
}
@@ -293,14 +297,17 @@ public class Surftips {
Seed seed = sb.peers.getConnected(record.originator());
if (seed == null) seed = sb.peers.getDisconnected(record.originator());
if (seed != null) {
- url = "http://" + seed.getPublicAddress(seed.getIP()) + "/Blog.html?page=" + record.attribute("page", "");
- entry = rowdef.newEntry(new byte[][]{
- UTF8.getBytes(url),
- UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
- UTF8.getBytes("Blog Entry: " + record.attribute("subject", "")),
- UTF8.getBytes(record.id())
- });
- score = 4 + timeFactor(record.created());
+ final Set<String> ips = seed.getIPs();
+ if(!ips.isEmpty()) {
+ url = seed.getPublicURL(ips.iterator().next(), false) + "/Blog.html?page=" + record.attribute("page", "");
+ entry = rowdef.newEntry(new byte[][]{
+ UTF8.getBytes(url),
+ UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
+ UTF8.getBytes("Blog Entry: " + record.attribute("subject", "")),
+ UTF8.getBytes(record.id())
+ });
+ score = 4 + timeFactor(record.created());
+ }
}
}
diff --git a/htroot/api/ynetSearch.java b/htroot/api/ynetSearch.java
index 9081549c1..f03098c6d 100644
--- a/htroot/api/ynetSearch.java
+++ b/htroot/api/ynetSearch.java
@@ -8,6 +8,7 @@ import java.util.Map;
import java.util.Scanner;
import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.http.servlets.YaCyDefaultServlet;
import net.yacy.search.Switchboard;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -30,9 +31,9 @@ public class ynetSearch {
InputStream is = null;
try {
String searchaddress = post.get("url");
- if (!searchaddress.startsWith("http://")) {
+ if (!searchaddress.startsWith("http://") && !searchaddress.startsWith("https://")) {
// a relative path .. this addresses the local peer
- searchaddress = "http://" + sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()) + ((searchaddress.length() > 0 && searchaddress.charAt(0) == '/') ? "" : "/") + searchaddress;
+ searchaddress = YaCyDefaultServlet.getContext(header, sb) + ((searchaddress.length() > 0 && searchaddress.charAt(0) == '/') ? "" : "/") + searchaddress;
}
post.remove("url");
post.remove("login");
diff --git a/htroot/goto_p.java b/htroot/goto_p.java
index 4c0889378..24ccb1d9c 100644
--- a/htroot/goto_p.java
+++ b/htroot/goto_p.java
@@ -26,6 +26,8 @@
// javac -classpath .:../Classes goto_p.java
// if the shell's current path is HTROOT
+import java.util.Set;
+
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
@@ -56,11 +58,19 @@ public class goto_p {
Seed seed = sb.peers.getConnected(hash);
if (seed != null) {
- String peersUrl = seed.getPublicAddress(seed.getIP());
+ final Set<String> ips = seed.getIPs();
+ String peersUrl = null;
+ if(!ips.isEmpty()) {
+ peersUrl = seed.getPublicURL(ips.iterator().next(), false);
+ }
if (peersUrl != null) {
String path = post.get("path", "/");
- if (!path.startsWith("/")) path = "/" + path;
- prop.put(serverObjects.ACTION_LOCATION, "http://" + peersUrl + path); // redirect command
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ prop.put(serverObjects.ACTION_LOCATION, peersUrl + path); // redirect command
+ } else {
+ prop.put("msg", "peer not available");
}
} else {
prop.put("msg", "peer not available");
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
index 9590c5827..35d0e1c0d 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -918,7 +918,13 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
final Seed seed = peers.getConnected(hash);
final String path = this.url().getFile();
String address = null;
- if ((seed == null) || ((address = seed.getPublicAddress(seed.getIP())) == null)) {
+ if(seed != null) {
+ final Set<String> ips = seed.getIPs();
+ if(!ips.isEmpty()) {
+ address = seed.getPublicAddress(ips.iterator().next());
+ }
+ }
+ if (address == null) {
// seed is not known from here
try {
if (indexSegment.termIndex() != null) indexSegment.termIndex().remove(
diff --git a/source/net/yacy/peers/Network.java b/source/net/yacy/peers/Network.java
index 53bff58c6..be7d82b3c 100644
--- a/source/net/yacy/peers/Network.java
+++ b/source/net/yacy/peers/Network.java
@@ -372,18 +372,24 @@ public class Network
}
i++;
- String ip = seed.getIP();
- final String address = seed.getPublicAddress(ip);
- if ( log.isFine() ) log.fine("HELLO #" + i + " to peer '" + seed.get(Seed.NAME, "") + "' at " + address); // debug
- final String seederror = seed.isProper(false);
- if ( (address == null) || (seederror != null) ) {
- // we don't like that address, delete it
- this.sb.peers.peerActions.interfaceDeparture(seed, ip);
+ final Set<String> ips = seed.getIPs();
+ if(ips.isEmpty()) {
+ /* This should not happen : seeds db maintains only seeds with at least one IP */
+ log.warn("Peer " + seed.getName() + "has no known IP address");
} else {
- // starting a new publisher thread
- publishThread t = new publishThread(Network.publishThreadGroup, seed);
- t.start();
- syncList.add(t);
+ String ip = ips.iterator().next();
+ final String address = seed.getPublicAddress(ip);
+ if ( log.isFine() ) log.fine("HELLO #" + i + " to peer '" + seed.getName() + "' at " + address); // debug
+ final String seederror = seed.isProper(false);
+ if ( (address == null) || (seederror != null) ) {
+ // we don't like that address, delete it
+ this.sb.peers.peerActions.interfaceDeparture(seed, ip);
+ } else {
+ // starting a new publisher thread
+ publishThread t = new publishThread(Network.publishThreadGroup, seed);
+ t.start();
+ syncList.add(t);
+ }
}
}
diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java
index 1da89f8c2..df993e682 100644
--- a/source/net/yacy/peers/Protocol.java
+++ b/source/net/yacy/peers/Protocol.java
@@ -58,6 +58,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -1216,7 +1217,6 @@ public final class Protocol {
Map<String, LinkedHashSet<String>> snippets = new HashMap<String, LinkedHashSet<String>>(); // this will be a list of urlhash-snippet entries
final QueryResponse[] rsp = new QueryResponse[]{null};
final SolrDocumentList[] docList = new SolrDocumentList[]{null};
- String ip = target.getIP();
{// encapsulate expensive solr QueryResponse object
if (localsearch && !Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.DEBUG_SEARCH_REMOTE_SOLR_TESTLOCAL, false)) {
// search the local index
@@ -1231,12 +1231,21 @@ public final class Protocol {
return -1;
}
} else {
+ String targetBaseURL = null;
try {
final boolean myseed = target == event.peers.mySeed();
- final String targetBaseURL;
if(myseed) {
targetBaseURL = "http://localhost:" + target.getPort();
} else {
+ final Set<String> ips = target.getIPs();
+ if(ips.isEmpty()) {
+ /* This should not happen : seeds db maintains only seeds with at least one IP */
+ Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + " has no known IP address");
+ target.setFlagSolrAvailable(false);
+ return -1;
+ }
+ final String ip = ips.iterator().next();
+
targetBaseURL = target.getPublicURL(ip,
Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED,
SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED_DEFAULT));
@@ -1279,7 +1288,9 @@ public final class Protocol {
* we must not in that case mark the target as not available but rather transmit the exception to the caller (likely RemoteSearch.solrRemoteSearch) */
throw e;
} catch (final Throwable e) {
- Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + "/" + target.getPublicAddress(ip) + " (" + e.getMessage() + ")");
+ if(Network.log.isInfo()) {
+ Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + (targetBaseURL != null ? "/" + targetBaseURL : "") + " (" + e.getMessage() + ")");
+ }
target.setFlagSolrAvailable(false || localsearch);
return -1;
}
@@ -2035,7 +2046,12 @@ public final class Protocol {
final Map<String, ContentBody> parts =
basicRequestParts(Switchboard.getSwitchboard(), target.hash, salt);
parts.put("object", UTF8.StringBody("host"));
- final String remoteBaseURL = target.getPublicURL(target.getIP(),
+ final Set<String> targetIps = target.getIPs();
+ if(targetIps.isEmpty()) {
+ Network.log.warn("yacyClient.loadIDXHosts error: no known address on target peer.");
+ return null;
+ }
+ final String remoteBaseURL = target.getPublicURL(targetIps.iterator().next(),
Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.NETWORK_PROTOCOL_HTTPS_PREFERRED,
SwitchboardConstants.NETWORK_PROTOCOL_HTTPS_PREFERRED_DEFAULT));
final Post post = new Post(new MultiProtocolURL(remoteBaseURL), target.hash, "/yacy/idx.json", parts, 30000);
diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.java
index 562b0eb93..3ea735780 100644
--- a/source/net/yacy/peers/Seed.java
+++ b/source/net/yacy/peers/Seed.java
@@ -1303,8 +1303,16 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
// check IP
if ( !checkOwnIP ) {
// checking of IP is omitted if we read the own seed file
- final String ip = getIP();
- if (!isProperIP(ip)) return "not a proper IP " + ip;
+ final Set<String> ips = getIPs();
+ if(ips.isEmpty()) {
+ return "no IP at all";
+ }
+ for(final String ip: ips) {
+ if (!isProperIP(ip)) {
+ Network.log.severe("not a proper IP " + ip + " peer : " + this.getName() + "ips " + ips);
+ return "not a proper IP " + ip;
+ }
+ }
}
// seedURL
diff --git a/source/net/yacy/peers/SeedDB.java b/source/net/yacy/peers/SeedDB.java
index 8938ed0a7..645fefdfb 100644
--- a/source/net/yacy/peers/SeedDB.java
+++ b/source/net/yacy/peers/SeedDB.java
@@ -974,7 +974,11 @@ public final class SeedDB implements AlternativeDomainNames {
seed = this.mySeed;
else return null;
}
- return seed.getPublicAddress(seed.getIP()) + ((subdom == null) ? "" : ("/" + subdom));
+ final Set<String> ips = seed.getIPs();
+ if(ips.isEmpty()) {
+ return null;
+ }
+ return seed.getPublicAddress(ips.iterator().next()) + ((subdom == null) ? "" : ("/" + subdom));
} else if (host.endsWith(".yacy")) {
// identify subdomain
p = host.indexOf('.');
@@ -989,9 +993,17 @@ public final class SeedDB implements AlternativeDomainNames {
if (this.mySeed == null) initMySeed();
if (seed == this.mySeed && !(seed.isOnline())) {
// take local ip instead of external
- return Switchboard.getSwitchboard().myPublicIP() + ":" + Switchboard.getSwitchboard().getLocalPort() + ((subdom == null) ? "" : ("/" + subdom));
+ final Set<String> ips = Switchboard.getSwitchboard().myPublicIPs();
+ if(ips.isEmpty()) {
+ return null;
+ }
+ return ips.iterator().next() + ":" + Switchboard.getSwitchboard().getLocalPort() + ((subdom == null) ? "" : ("/" + subdom));
+ }
+ final Set<String> ips = seed.getIPs();
+ if(ips.isEmpty()) {
+ return null;
}
- return seed.getPublicAddress(seed.getIP()) + ((subdom == null) ? "" : ("/" + subdom));
+ return seed.getPublicAddress(ips.iterator().next()) + ((subdom == null) ? "" : ("/" + subdom));
} else {
return null;
}