Support for preferred https in peers communication on more operations

pull/137/head
luccioman 7 years ago
parent 0a058ba6af
commit c35d0568b6

@ -56,6 +56,7 @@ import net.yacy.repository.Blacklist;
import net.yacy.repository.BlacklistHostAndPath; import net.yacy.repository.BlacklistHostAndPath;
import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.repository.Blacklist.BlacklistType;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.SearchEventCache; import net.yacy.search.query.SearchEventCache;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch; import net.yacy.server.serverSwitch;
@ -140,11 +141,29 @@ public class sharedBlacklist_p {
if( sb.peers != null ){ //no nullpointer error.. if( sb.peers != null ){ //no nullpointer error..
final Seed seed = sb.peers.getConnected(hash); final Seed seed = sb.peers.getConnected(hash);
if (seed != null) { if (seed != null) {
final String IP = seed.getIP(); final Set<String> ips = seed.getIPs();
final String Port = seed.get(Seed.PORT, "8090"); if(!ips.isEmpty()) {
final String peerName = seed.get(Seed.NAME, "<" + IP + ":" + Port + ">"); final String IP = ips.iterator().next();
prop.putHTML("page_source", peerName); final String Port = seed.get(Seed.PORT, "8090");
downloadURLOld = "http://" + IP + ":" + Port + "/yacy/list.html?col=black"; 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 { } else {
prop.put("status", STATUS_PEER_UNKNOWN);//YaCy-Peer not found prop.put("status", STATUS_PEER_UNKNOWN);//YaCy-Peer not found
prop.putHTML("status_name", hash); prop.putHTML("status_name", hash);
@ -155,20 +174,6 @@ public class sharedBlacklist_p {
prop.putHTML("status_name", hash); prop.putHTML("status_name", hash);
prop.put("page", "1"); 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")) { } else if (post.containsKey("url")) {
/* ====================================================== /* ======================================================
* Download the blacklist from URL * Download the blacklist from URL

@ -244,7 +244,18 @@ public class AutoSearch extends AbstractBusyThread {
* @param seed the peer to ask * @param seed the peer to ask
*/ */
private void processSingleTarget(Seed seed) { private void processSingleTarget(Seed seed) {
ConcurrentLog.fine(AutoSearch.class.getName(), "ask " + seed.getIP() + " " + seed.getName() + " for query=" + currentQuery); final Set<String> 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 if (seed.getFlagSolrAvailable()) { // do a solr query
SolrDocumentList docList = null; 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,
SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_AUTHENTICATED_ALLOW_SELF_SIGNED_DEFAULT); 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 { try {
SolrConnector solrConnector = new RemoteSolrConnector(instance, SolrConnector solrConnector = new RemoteSolrConnector(instance,
sb.getConfigBool(SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED, sb.getConfigBool(SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED,
@ -288,7 +299,7 @@ public class AutoSearch extends AbstractBusyThread {
} catch (Throwable eee) { } catch (Throwable eee) {
} }
} else { // do a yacysearch.rss query } else { // do a yacysearch.rss query
final String rssSearchServiceURL = "http://" + seed.getPublicAddress(seed.getIP()) + "/yacysearch.rss"; final String rssSearchServiceURL = targetBaseURL + "/yacysearch.rss";
try { try {
RSSFeed feed = loadSRURSS( RSSFeed feed = loadSRURSS(
rssSearchServiceURL, rssSearchServiceURL,

Loading…
Cancel
Save