Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
implement a forward to remote peer link in P2P Network list Most links in Network.html are only available with transparent proxy = on, which is switched off by default, to make the provided links useable in default setup a small forward servlet added (goto_p.java), which takes the peer hash as parameter and forwards to current public ip (optional with path= parameter). The servlet is protected ( _p ending) to assure forwarding works only for authorized YaCy users.
reger5247d01cd48e
diff --git a/htroot/Network.html b/htroot/Network.htmlindex 14ccc3fd9..2fecf9105 100644--- a/htroot/Network.html+++ b/htroot/Network.html@@ -136,14 +136,14 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.<td><nobr><a href="MessageSend_p.html?hash=#[hash]#" title="Send message to peer #[fullname]#">m</a> <a href="ViewProfile.html?hash=#[hash]#&display=1" title="View profile of peer #[fullname]#">p</a> - <a href="http://#[fullname]#.yacy/Wiki.html" title="Read and edit wiki on peer #[fullname]#">w</a> - <a href="http://#[fullname]#.yacy/Blog.html" title="Browse blog of peer #[fullname]#">b</a> + <a href="goto_p.html?hash=#[hash]#&path=/Wiki.html" title="Read and edit wiki on peer #[fullname]#">w</a> + <a href="goto_p.html?hash=#[hash]#&path=/Blog.html" title="Browse blog of peer #[fullname]#">b</a> #(updatedProfile)#::<a href="ViewProfile.html?hash=#[hash]#&display=1"><img src="env/grafics/profile.gif" width="54" height="11" alt="Profile updated" /></a>#(/updatedProfile)##(updatedWiki)#::<a href="http://#[address]#/Wiki.html?page=#[page]#" title="#[page]#"><img src="env/grafics/wiki.gif" width="54" height="11" alt="Wiki updated" /></a>#(/updatedWiki)##(updatedBlog)#::<a href="http://#[address]#/Blog.html?page=#[page]#" title="#[subject]#"><img src="env/grafics/blog.gif" width="54" height="11" alt="Blog updated" /></a>#(/updatedBlog)##(isCrawling)#::<a href="#[page]#"><img src="env/grafics/crawl.gif" width="54" height="11" alt="Crawl" /></a>#(/isCrawling)#</nobr></td>- <td #(special)#::class="TableCellActive"#(/special)#><a href="http://www.#[fullname]#.yacy">#[shortname]#</a>#(ssl)#::<img src="env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td>+ <td #(special)#::class="TableCellActive"#(/special)#><a href="goto_p.html?hash=#[hash]#&path=/www/">#[shortname]#</a>#(ssl)#::<img src="env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td><td nowrap>#(type)##(direct)#<img src="env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#">#(direct)#<img src="env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##(nodestate)#<img src="env/grafics/RootStateNo.gif" width="11" height="11" title="Not a Node Candidate" alt="no node candidate" />::<a href="http://#[ip]#:#[port]#/Network.html?page=1"><img src="env/grafics/RootStateYes.gif" width="11" height="11" title="Node Candidate" alt="node candidate" /></a>#(/nodestate)#</td><td align="right">#[version]#</td>diff --git a/htroot/goto_p.html b/htroot/goto_p.htmlnew file mode 100644index 000000000..a33639aa2--- /dev/null+++ b/htroot/goto_p.html@@ -0,0 +1,10 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">+<html xmlns="http://www.w3.org/1999/xhtml">+ <head>+ <title>forwarding</title>+ </head>+ <body>+ <h2>forward to remote peer</h2>+ <p>Error: #[msg]#</p>+ </body>+</html>diff --git a/htroot/goto_p.java b/htroot/goto_p.javanew file mode 100644index 000000000..387665ac4--- /dev/null+++ b/htroot/goto_p.java@@ -0,0 +1,74 @@+// goto_p.java+// -----------------------+// part of YaCy+// (C) by Michael Peter Christen; [email protected]+// first published on http://yacy.net+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++// You must compile this file with+// javac -classpath .:../Classes goto_p.java+// if the shell's current path is HTROOT++import net.yacy.cora.protocol.RequestHeader;+import net.yacy.peers.Seed;+import net.yacy.search.Switchboard;+import net.yacy.server.serverObjects;+import net.yacy.server.serverSwitch;++/**+ * forwards caller/browser to remote peer+ */+public class goto_p {++ /**+ * url parameter+ *+ * hash= of remote peer+ * path= path part to forward to+ */+ public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {+ final Switchboard sb = (Switchboard) env;+ final serverObjects prop = new serverObjects();++ String hash = null;+ if (post != null) {+ hash = post.get("hash", null); // get peers hash+ }++ if (hash != null) {+ Seed seed = sb.peers.getConnected(hash);++ if (seed != null) {+ String peersUrl = seed.getPublicAddress();+ if (peersUrl != null) {+ String path = post.get("path", "/");+ if (!path.startsWith("/")) path = "/" + path;+ prop.put(serverObjects.ACTION_LOCATION, "http://" + peersUrl + path); // redirect command+ }+ } else {+ prop.put("msg", "peer not available");+ }++ } else {+ prop.put("msg", "parameter missing");+ }+ return prop;+ }+}