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.pull/1/head
parent
de7641023c
commit
5247d01cd4
@ -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>
|
@ -0,0 +1,74 @@
|
||||
// goto_p.java
|
||||
// -----------------------
|
||||
// part of YaCy
|
||||
// (C) by Michael Peter Christen; mc@yacy.net
|
||||
// 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;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue