added virtual host support:

all yacy-to-yacy communication now send the <peer-hexhash>.yacyh
virtual domain inside the http 'Host' property field.
This shall enable running a yacy peer on a virtual host.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2074 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 461548698c
commit fd7c17e624

@ -96,7 +96,8 @@ public class ConfigLanguage_p {
String url = (String)post.get("url"); String url = (String)post.get("url");
ArrayList langVector; ArrayList langVector;
try{ try{
langVector = httpc.wget(new URL(url), 6000, null, null, switchboard.remoteProxyConfig); URL u = new URL(url);
langVector = httpc.wget(u, u.getHost(), 6000, null, null, switchboard.remoteProxyConfig);
}catch(IOException e){ }catch(IOException e){
prop.put("status", 1);//unable to get url prop.put("status", 1);//unable to get url
prop.put("status_url", url); prop.put("status_url", url);

@ -125,7 +125,8 @@ public class ConfigSkins_p {
String url = (String)post.get("url"); String url = (String)post.get("url");
ArrayList skinVector; ArrayList skinVector;
try{ try{
skinVector = httpc.wget(new URL(url), 6000, null, null, switchboard.remoteProxyConfig); URL u = new URL(url);
skinVector = httpc.wget(u, u.getHost(), 6000, null, null, switchboard.remoteProxyConfig);
}catch(IOException e){ }catch(IOException e){
prop.put("status", 1);//unable to get URL prop.put("status", 1);//unable to get URL
prop.put("status_url", url); prop.put("status_url", url);

@ -147,7 +147,8 @@ public class sharedBlacklist_p {
reqHeader.put(httpHeader.CACHE_CONTROL,"no-cache"); reqHeader.put(httpHeader.CACHE_CONTROL,"no-cache");
// get List // get List
otherBlacklist = httpc.wget(new URL(address), 12000, null, null, switchboard.remoteProxyConfig,reqHeader); URL u = new URL(address);
otherBlacklist = httpc.wget(u, u.getHost(), 12000, null, null, switchboard.remoteProxyConfig,reqHeader);
} catch (Exception e) {} } catch (Exception e) {}
//Make HTML-Optionlist with retrieved items //Make HTML-Optionlist with retrieved items
@ -178,7 +179,8 @@ public class sharedBlacklist_p {
Name = address; Name = address;
try { try {
otherBlacklist = httpc.wget(new URL(address), 6000, null, null, switchboard.remoteProxyConfig); //get List URL u = new URL(address);
otherBlacklist = httpc.wget(u, u.getHost(), 6000, null, null, switchboard.remoteProxyConfig); //get List
} catch (Exception e) {} } catch (Exception e) {}
prop.put("status", 0); //TODO: check if the wget failed... prop.put("status", 0); //TODO: check if the wget failed...

@ -1152,6 +1152,7 @@ do upload
public static byte[] singlePOST( public static byte[] singlePOST(
URL u, URL u,
String host,
int timeout, int timeout,
String user, String user,
String password, String password,
@ -1186,8 +1187,10 @@ do upload
serverObjects props serverObjects props
) throws IOException { ) throws IOException {
try { try {
URL u = new URL(url);
return singlePOST( return singlePOST(
new URL(url), u,
u.getHost(),
timeout, timeout,
null, null,
null, null,
@ -1201,20 +1204,23 @@ do upload
} }
public static ArrayList wget( public static ArrayList wget(
URL url, URL url,
String host,
int timeout, int timeout,
String user, String user,
String password, String password,
httpRemoteProxyConfig theRemoteProxyConfig httpRemoteProxyConfig theRemoteProxyConfig
) throws IOException { ) throws IOException {
return wget(url,timeout,user,password,theRemoteProxyConfig,null); return wget(url, host,timeout,user,password,theRemoteProxyConfig,null);
} }
public static ArrayList wget(URL url) throws IOException{ public static ArrayList wget(URL url) throws IOException{
return wget(url, 6000, null, null, plasmaSwitchboard.getSwitchboard().remoteProxyConfig); return wget(url, url.getHost(), 6000, null, null, plasmaSwitchboard.getSwitchboard().remoteProxyConfig, null);
} }
public static ArrayList wget( public static ArrayList wget(
URL url, URL url,
String host,
int timeout, int timeout,
String user, String user,
String password, String password,
@ -1231,7 +1237,7 @@ do upload
// splitting of the byte array into lines // splitting of the byte array into lines
byte[] a = singleGET( byte[] a = singleGET(
url.getHost(), host,
port, port,
path, path,
timeout, timeout,
@ -1346,7 +1352,8 @@ do upload
*/ */
public static ArrayList wput( public static ArrayList wput(
URL url, URL url,
String host,
int timeout, int timeout,
String user, String user,
String password, String password,
@ -1356,7 +1363,8 @@ do upload
) throws IOException { ) throws IOException {
// splitting of the byte array into lines // splitting of the byte array into lines
byte[] a = singlePOST( byte[] a = singlePOST(
url, url,
host,
timeout, timeout,
user, user,
password, password,
@ -1402,7 +1410,8 @@ do upload
httpRemoteProxyConfig theRemoteProxyConfig = httpRemoteProxyConfig.init(proxyHost,proxyPort); httpRemoteProxyConfig theRemoteProxyConfig = httpRemoteProxyConfig.init(proxyHost,proxyPort);
try { try {
text = wget(new URL(url), timeout, null, null, theRemoteProxyConfig); URL u = new URL(url);
text = wget(u, u.getHost(), timeout, null, null, theRemoteProxyConfig);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
System.out.println("The url '" + url + "' is wrong."); System.out.println("The url '" + url + "' is wrong.");
} catch (IOException e) { } catch (IOException e) {

@ -60,7 +60,7 @@ public class natLib {
rm status.htm rm status.htm
*/ */
try { try {
ArrayList x = httpc.wget(new URL("http://192.168.0.1:80/status.htm"), 5000, "admin", password, null); ArrayList x = httpc.wget(new URL("http://192.168.0.1:80/status.htm"), "192.168.0.1", 5000, "admin", password, null);
x = nxTools.grep(x, 1, "IP Address"); x = nxTools.grep(x, 1, "IP Address");
if ((x == null) || (x.size() == 0)) return null; if ((x == null) || (x.size() == 0)) return null;
String line = nxTools.tail1(x); String line = nxTools.tail1(x);
@ -72,7 +72,7 @@ public class natLib {
private static String getWhatIsMyIP() { private static String getWhatIsMyIP() {
try { try {
ArrayList x = httpc.wget(new URL("http://www.whatismyip.com/"), 5000, null, null, null); ArrayList x = httpc.wget(new URL("http://www.whatismyip.com/"), "whatsmyip.com", 5000, null, null, null);
x = nxTools.grep(x, 0, "Your IP is"); x = nxTools.grep(x, 0, "Your IP is");
String line = nxTools.tail1(x); String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 4); return nxTools.awk(line, " ", 4);
@ -83,7 +83,7 @@ public class natLib {
private static String getStanford() { private static String getStanford() {
try { try {
ArrayList x = httpc.wget(new URL("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl"), 5000, null, null, null); ArrayList x = httpc.wget(new URL("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl"), "stanford.edu", 5000, null, null, null);
x = nxTools.grep(x, 0, "firewall protecting your browser"); x = nxTools.grep(x, 0, "firewall protecting your browser");
String line = nxTools.tail1(x); String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 7); return nxTools.awk(line, " ", 7);
@ -94,7 +94,7 @@ public class natLib {
private static String getIPID() { private static String getIPID() {
try { try {
ArrayList x = httpc.wget(new URL("http://ipid.shat.net/"), 5000, null, null, null); ArrayList x = httpc.wget(new URL("http://ipid.shat.net/"), "shat.net", 5000, null, null, null);
x = nxTools.grep(x, 2, "Your IP address"); x = nxTools.grep(x, 2, "Your IP address");
String line = nxTools.tail1(x); String line = nxTools.tail1(x);
return nxTools.awk(nxTools.awk(nxTools.awk(line, " ", 5), ">", 2), "<", 1); return nxTools.awk(nxTools.awk(nxTools.awk(line, " ", 5), ">", 2), "<", 1);

@ -146,7 +146,7 @@ public class loaderThreads {
public void run() { public void run() {
try { try {
page = httpc.wget(url, timeout, user, password, remoteProxyConfig); page = httpc.wget(url, url.getHost(), timeout, user, password, remoteProxyConfig);
loaded = true; loaded = true;
process.feed(page); process.feed(page);
if (process.status() == loaderCore.STATUS_FAILED) { if (process.status() == loaderCore.STATUS_FAILED) {

@ -124,7 +124,8 @@ public final class yacyClient {
// sending request // sending request
result = nxTools.table( result = nxTools.table(
httpc.wput(url, httpc.wput(url,
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
105000, 105000,
null, null,
null, null,
@ -257,10 +258,12 @@ public final class yacyClient {
"&object=seed" + "&object=seed" +
"&env=" + seedHash "&env=" + seedHash
), ),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
10000, 10000,
null, null,
null, null,
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null (useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
null
) )
); );
@ -292,6 +295,7 @@ public final class yacyClient {
"&env=" + wordHash + "&env=" + wordHash +
"&ttl=0" "&ttl=0"
), ),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
10000, 10000,
null, null,
null, null,
@ -331,7 +335,8 @@ public final class yacyClient {
try { try {
final HashMap result = nxTools.table( final HashMap result = nxTools.table(
httpc.wget( httpc.wget(
new URL(querystr), new URL(querystr),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
6000, 6000,
null, null,
null, null,
@ -422,6 +427,7 @@ public final class yacyClient {
final HashMap result = nxTools.table( final HashMap result = nxTools.table(
httpc.wput( httpc.wput(
new URL(url), new URL(url),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
300000, 300000,
null, null,
null, null,
@ -556,6 +562,7 @@ public final class yacyClient {
return nxTools.table( return nxTools.table(
httpc.wput( httpc.wput(
new URL("http://" + address + "/yacy/message.html"), new URL("http://" + address + "/yacy/message.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
8000, 8000,
null, null,
null, null,
@ -599,7 +606,8 @@ public final class yacyClient {
// sending request // sending request
try { try {
final ArrayList v = httpc.wput( final ArrayList v = httpc.wput(
new URL("http://" + address + "/yacy/message.html"), new URL("http://" + address + "/yacy/message.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
20000, 20000,
null, null,
null, null,
@ -653,6 +661,7 @@ public final class yacyClient {
return nxTools.table( return nxTools.table(
httpc.wput( httpc.wput(
new URL("http://" + targetAddress + "/yacy/transfer.html"), new URL("http://" + targetAddress + "/yacy/transfer.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
8000, 8000,
null, null,
null, null,
@ -692,7 +701,8 @@ public final class yacyClient {
// sending request // sending request
try { try {
final ArrayList v = httpc.wput( final ArrayList v = httpc.wput(
new URL("http://" + targetAddress + "/yacy/transfer.html"), new URL("http://" + targetAddress + "/yacy/transfer.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
20000, 20000,
null, null,
null, null,
@ -777,6 +787,7 @@ public final class yacyClient {
return nxTools.table( return nxTools.table(
httpc.wput( httpc.wput(
new URL("http://" + address + "/yacy/crawlOrder.html"), new URL("http://" + address + "/yacy/crawlOrder.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
timeout, timeout,
null, null,
null, null,
@ -851,6 +862,7 @@ public final class yacyClient {
"&wordh=" + wordhashes + "&wordh=" + wordhashes +
"&lurlEntry=" + ((entry == null) ? "" : crypt.simpleEncode(entry.toString(), key)) "&lurlEntry=" + ((entry == null) ? "" : crypt.simpleEncode(entry.toString(), key))
), ),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
60000, 60000,
null, null,
null, null,
@ -965,6 +977,7 @@ public final class yacyClient {
try { try {
final ArrayList v = httpc.wput( final ArrayList v = httpc.wput(
new URL("http://" + address + "/yacy/transferRWI.html"), new URL("http://" + address + "/yacy/transferRWI.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
timeout, timeout,
null, null,
null, null,
@ -1021,7 +1034,8 @@ public final class yacyClient {
post.put("urlc", Integer.toString(urlc)); post.put("urlc", Integer.toString(urlc));
try { try {
final ArrayList v = httpc.wput( final ArrayList v = httpc.wput(
new URL("http://" + address + "/yacy/transferURL.html"), new URL("http://" + address + "/yacy/transferURL.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
timeout, timeout,
null, null,
null, null,
@ -1056,6 +1070,7 @@ public final class yacyClient {
try { try {
final ArrayList v = httpc.wput( final ArrayList v = httpc.wput(
new URL("http://" + address + "/yacy/profile.html"), new URL("http://" + address + "/yacy/profile.html"),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
20000, 20000,
null, null,
null, null,
@ -1095,6 +1110,7 @@ public final class yacyClient {
"&count=10" + "&count=10" +
"&resource=global" + "&resource=global" +
"&query=" + wordhashe), "&query=" + wordhashe),
yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
5000, 5000,
null, null,
null, null,

@ -190,7 +190,7 @@ public class yacyPeerActions {
yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)"); yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)");
} else { } else {
ssc++; ssc++;
seedList = httpc.wget(url, this.bootstrapLoadTimeout, null, null, this.sb.remoteProxyConfig,reqHeader); seedList = httpc.wget(url, url.getHost(), this.bootstrapLoadTimeout, null, null, this.sb.remoteProxyConfig,reqHeader);
enu = seedList.iterator(); enu = seedList.iterator();
lc = 0; lc = 0;
while (enu.hasNext()) { while (enu.hasNext()) {
@ -243,7 +243,8 @@ public class yacyPeerActions {
// read in remote file from url // read in remote file from url
try { try {
ArrayList remote = httpc.wget(new URL(url), 5000, null, null, this.sb.remoteProxyConfig); URL u = new URL(url);
ArrayList remote = httpc.wget(u, u.getHost(), 5000, null, null, this.sb.remoteProxyConfig);
if ((remote != null) && (remote.size() > 0)) { if ((remote != null) && (remote.size() > 0)) {
Iterator e = remote.iterator(); Iterator e = remote.iterator();
while (e.hasNext()) { while (e.hasNext()) {

@ -703,7 +703,8 @@ public final class yacySeedDB {
reqHeader.put(httpHeader.PRAGMA, "no-cache"); reqHeader.put(httpHeader.PRAGMA, "no-cache");
reqHeader.put(httpHeader.CACHE_CONTROL, "no-cache"); // httpc uses HTTP/1.0 is this necessary? reqHeader.put(httpHeader.CACHE_CONTROL, "no-cache"); // httpc uses HTTP/1.0 is this necessary?
ArrayList check = httpc.wget( ArrayList check = httpc.wget(
seedURL, seedURL,
seedURL.getHost(),
10000, 10000,
null, null,
null, null,

@ -459,7 +459,8 @@ public final class yacy {
server.terminate(false); server.terminate(false);
server.interrupt(); server.interrupt();
if (server.isAlive()) try { if (server.isAlive()) try {
httpc.wget(new URL("http://localhost:" + serverCore.getPortNr(port)), 1000, null, null, null); // kick server URL u = new URL("http://localhost:" + serverCore.getPortNr(port));
httpc.wget(u, u.getHost(), 1000, null, null, null); // kick server
serverLog.logConfig("SHUTDOWN", "sent termination signal to server socket"); serverLog.logConfig("SHUTDOWN", "sent termination signal to server socket");
} catch (IOException ee) { } catch (IOException ee) {
serverLog.logConfig("SHUTDOWN", "termination signal to server socket missed (server shutdown, ok)"); serverLog.logConfig("SHUTDOWN", "termination signal to server socket missed (server shutdown, ok)");

Loading…
Cancel
Save