Skip to content
Permalink
Browse files

Support for preferred https in peers communication on more operations

  • Loading branch information...
luccioman committed Apr 24, 2018
1 parent 0a058ba commit c35d0568b6ceb0a65e712bca4fe9d075b6d7ae57
Showing with 38 additions and 22 deletions.
  1. +24 −19 htroot/sharedBlacklist_p.java
  2. +14 −3 source/net/yacy/search/AutoSearch.java
@@ -56,6 +56,7 @@
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 static serverObjects respond(@SuppressWarnings("unused") final RequestHea
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<String> 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 static serverObjects respond(@SuppressWarnings("unused") final RequestHea
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
@@ -244,7 +244,18 @@ public boolean job() {
* @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<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
SolrDocumentList docList = null;
@@ -259,7 +270,7 @@ private void processSingleTarget(Seed seed) {
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 @@ private void processSingleTarget(Seed seed) {
} 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,

0 comments on commit c35d056

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