From c35d0568b6ceb0a65e712bca4fe9d075b6d7ae57 Mon Sep 17 00:00:00 2001 From: luccioman Date: Tue, 24 Apr 2018 08:08:24 +0200 Subject: [PATCH] Support for preferred https in peers communication on more operations --- htroot/sharedBlacklist_p.java | 43 ++++++++++++++------------ source/net/yacy/search/AutoSearch.java | 17 ++++++++-- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java index fb49ac9de..8e1a73455 100644 --- a/htroot/sharedBlacklist_p.java +++ b/htroot/sharedBlacklist_p.java @@ -56,6 +56,7 @@ import net.yacy.repository.Blacklist; import net.yacy.repository.BlacklistHostAndPath; import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.search.Switchboard; +import net.yacy.search.SwitchboardConstants; import net.yacy.search.query.SearchEventCache; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; @@ -140,11 +141,29 @@ public class sharedBlacklist_p { if( sb.peers != null ){ //no nullpointer error.. final Seed seed = sb.peers.getConnected(hash); if (seed != null) { - final String IP = seed.getIP(); - final String Port = seed.get(Seed.PORT, "8090"); - final String peerName = seed.get(Seed.NAME, "<" + IP + ":" + Port + ">"); - prop.putHTML("page_source", peerName); - downloadURLOld = "http://" + IP + ":" + Port + "/yacy/list.html?col=black"; + final Set ips = seed.getIPs(); + if(!ips.isEmpty()) { + final String IP = ips.iterator().next(); + final String Port = seed.get(Seed.PORT, "8090"); + final String peerName = seed.get(Seed.NAME, "<" + IP + ":" + Port + ">"); + prop.putHTML("page_source", peerName); + + downloadURLOld = seed.getPublicURL(IP, + sb.getConfigBool(SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED, + SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED_DEFAULT)) + "/yacy/list.html?col=black"; + + // download the blacklist + try { + // get List + final DigestURL u = new DigestURL(downloadURLOld); + + otherBlacklist = FileUtils.strings(u.get(agent, null, null)); + } catch (final Exception e) { + prop.put("status", STATUS_PEER_UNKNOWN); + prop.putHTML("status_name", hash); + prop.put("page", "1"); + } + } } else { prop.put("status", STATUS_PEER_UNKNOWN);//YaCy-Peer not found prop.putHTML("status_name", hash); @@ -155,20 +174,6 @@ public class sharedBlacklist_p { prop.putHTML("status_name", hash); prop.put("page", "1"); } - - if (downloadURLOld != null) { - // download the blacklist - try { - // get List - final DigestURL u = new DigestURL(downloadURLOld); - - otherBlacklist = FileUtils.strings(u.get(agent, null, null)); - } catch (final Exception e) { - prop.put("status", STATUS_PEER_UNKNOWN); - prop.putHTML("status_name", hash); - prop.put("page", "1"); - } - } } else if (post.containsKey("url")) { /* ====================================================== * Download the blacklist from URL diff --git a/source/net/yacy/search/AutoSearch.java b/source/net/yacy/search/AutoSearch.java index c8791d48e..9e214b394 100644 --- a/source/net/yacy/search/AutoSearch.java +++ b/source/net/yacy/search/AutoSearch.java @@ -244,7 +244,18 @@ public class AutoSearch extends AbstractBusyThread { * @param seed the peer to ask */ private void processSingleTarget(Seed seed) { - ConcurrentLog.fine(AutoSearch.class.getName(), "ask " + seed.getIP() + " " + seed.getName() + " for query=" + currentQuery); + final Set ips = seed.getIPs(); + if(ips.isEmpty()) { + ConcurrentLog.warn(AutoSearch.class.getName(), "no known IP address for peer " + seed.getName()); + return; + } + final String ip = ips.iterator().next(); + ConcurrentLog.fine(AutoSearch.class.getName(), "ask " + ip + " " + seed.getName() + " for query=" + currentQuery); + + final boolean preferHttps = this.sb.getConfigBool(SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED, + SwitchboardConstants.REMOTESEARCH_HTTPS_PREFERRED_DEFAULT); + + final String targetBaseURL = seed.getPublicURL(ip, preferHttps); if (seed.getFlagSolrAvailable()) { // do a solr query SolrDocumentList docList = null; @@ -259,7 +270,7 @@ public class AutoSearch extends AbstractBusyThread { SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED, SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED_DEFAULT); - RemoteInstance instance = new RemoteInstance("http://" + seed.getPublicAddress(seed.getIP()) + "/solr/", null, null, 10000, trustSelfSignedOnAuthenticatedServer); // this is a 'patch configuration' which considers 'solr' as default collection + RemoteInstance instance = new RemoteInstance(targetBaseURL + "/solr/", null, null, 10000, trustSelfSignedOnAuthenticatedServer); // this is a 'patch configuration' which considers 'solr' as default collection try { SolrConnector solrConnector = new RemoteSolrConnector(instance, sb.getConfigBool(SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED, @@ -288,7 +299,7 @@ public class AutoSearch extends AbstractBusyThread { } catch (Throwable eee) { } } else { // do a yacysearch.rss query - final String rssSearchServiceURL = "http://" + seed.getPublicAddress(seed.getIP()) + "/yacysearch.rss"; + final String rssSearchServiceURL = targetBaseURL + "/yacysearch.rss"; try { RSSFeed feed = loadSRURSS( rssSearchServiceURL,