Skip to content
Permalink
Browse files

Removed some remaining uses of deprecated Seed.getIP()

  • Loading branch information...
luccioman committed Apr 26, 2018
1 parent c35d056 commit addd18c9935bd3ab5e52aa158ae4173df9d0d51c
@@ -85,11 +85,11 @@ <h3>Inserting a Search Window to MediaWiki</h3>
<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 @@ <h3>Inserting a Search Window to MediaWiki</h3>
});
&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;
@@ -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 @@

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")) {
@@ -77,11 +77,11 @@ <h3>Inserting a Search Window to phpBB3</h3>
<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 @@ <h3>Inserting a Search Window to phpBB3</h3>
});
&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;
@@ -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 @@

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")) {
@@ -374,11 +374,15 @@ public static serverObjects respond(final RequestHeader requestHeader, final ser
}
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 static serverObjects respond(final RequestHeader requestHeader, final ser
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 static serverObjects respond(final RequestHeader requestHeader, final ser
}
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);
@@ -226,12 +226,13 @@ public static serverObjects respond(
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());
}
}
@@ -29,6 +29,7 @@
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,29 +279,35 @@ private static void accumulateSurftips(
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());
}
}
}

if (record.category().equals(NewsPool.CATEGORY_BLOG_ADD)) {
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());
}
}
}

@@ -8,6 +8,7 @@
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 static serverObjects respond(final RequestHeader header, final serverObje
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");
@@ -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 static serverObjects respond(@SuppressWarnings("unused") final RequestHea
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");
@@ -918,7 +918,13 @@ public URIMetadataNode makeResultEntry(
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(
@@ -372,18 +372,24 @@ private boolean publishMySeed() {
}
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);
}
}
}

0 comments on commit addd18c

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