*) setting threadnames for kelondroMap:writequeue and publishSeed

so that a thread dump is more verbose

*) Moving code for transparent proxy support to a separate function

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@98 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent dae6f46812
commit a5fec449c8

@ -45,9 +45,12 @@ delete the file 'DATA/SETTINGS/httpProxy.conf' in the YaCy application root fold
<i>(hint: choose a name that appears on a web page that tells something about you, vistit the page, get the 'senior' status, and you can be found..)</i></td>
</tr>
<tr valign="top">
<td>Use as Transparent Proxy:</td>
<td>Transparent Proxy:</td>
<td><input type="checkbox" name="isTransparentProxy" align="top" #(isTransparentProxy)#::checked#(/isTransparentProxy)#></td>
<td>With this you can specify if YaCy can be used as transparent proxy.</td>
<td>With this you can specify if YaCy can be used as transparent proxy.<br>
<i>Hint: On linux you can configure your firewall to transparently redirect all http traffic through yacy using this iptables rule:</i><br>
<small><code>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.0/16 --dport 80 -j DNAT --to 192.168.0.1:#[port]#</code></small>
</td>
</tr>
<tr>
<td><input type="submit" name="generalsettings" value="submit"></td>

@ -201,6 +201,22 @@ public final class httpd implements serverHandler {
return header;
}
private void transparentProxyHandling(httpHeader header) {
if (!(httpdProxyHandler.isTransparentProxy && header.containsKey("HOST"))) return;
String dstHost, dstHostSocket = (String) header.get("HOST");
int idx = dstHostSocket.indexOf(":");
dstHost = (idx != -1) ? dstHostSocket.substring(0,idx).trim() : dstHostSocket.trim();
try {
InetAddress dstHostAddress = InetAddress.getByName(dstHost);
if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) {
this.prop.setProperty("HOST",dstHostSocket);
}
} catch (Exception e) { }
}
public Boolean GET(String arg) throws IOException {
parseQuery(prop, arg);
prop.setProperty("METHOD", "GET");
@ -213,25 +229,7 @@ public final class httpd implements serverHandler {
header = new httpHeader(reverseMappingCache);
} else {
header = readHeader();
if ((httpdProxyHandler.isTransparentProxy) && header.containsKey("HOST")){
Integer dstPort;
String dstHost = (String) header.get("HOST");
int idx = dstHost.indexOf(":");
if (idx != -1) {
dstPort = Integer.valueOf(dstHost.substring(idx+1));
dstHost = dstHost.substring(0,idx);
} else {
dstPort = new Integer(80);
}
if (dstPort.intValue() == 80) {
InetAddress dstHostAddress = InetAddress.getByName(dstHost);
if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) {
this.prop.setProperty("HOST",dstHost);
}
}
}
this.transparentProxyHandling(header);
}
// managing keep-alive: in HTTP/0.9 and HTTP/1.0 every connection is closed
@ -314,28 +312,9 @@ public final class httpd implements serverHandler {
String httpVersion = prop.getProperty("HTTP", "HTTP/0.9");
if (httpVersion.equals("HTTP/0.9")) {
header = new httpHeader(reverseMappingCache);
}
else {
header = readHeader();
if ((httpdProxyHandler.isTransparentProxy) && header.containsKey("HOST")){
Integer dstPort;
String dstHost = (String) header.get("HOST");
int idx = dstHost.indexOf(":");
if (idx != -1) {
dstPort = Integer.valueOf(dstHost.substring(idx+1));
dstHost = dstHost.substring(0,idx);
} else {
dstPort = new Integer(80);
}
if (dstPort.intValue() == 80) {
InetAddress dstHostAddress = InetAddress.getByName(dstHost);
if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) {
this.prop.setProperty("HOST",dstHost);
}
}
}
header = readHeader();
this.transparentProxyHandling(header);
}
// return multi-line message
@ -411,25 +390,7 @@ public final class httpd implements serverHandler {
header = new httpHeader(reverseMappingCache);
} else {
header = readHeader();
if ((httpdProxyHandler.isTransparentProxy) && header.containsKey("HOST")){
Integer dstPort;
String dstHost = (String) header.get("HOST");
int idx = dstHost.indexOf(":");
if (idx != -1) {
dstPort = Integer.valueOf(dstHost.substring(idx+1));
dstHost = dstHost.substring(0,idx);
} else {
dstPort = new Integer(80);
}
if (dstPort.intValue() == 80) {
InetAddress dstHostAddress = InetAddress.getByName(dstHost);
if (!(dstHostAddress.isAnyLocalAddress() || dstHostAddress.isLoopbackAddress())) {
this.prop.setProperty("HOST",dstHost);
}
}
}
this.transparentProxyHandling(header);
}
boolean persistent = (!((httpVersion.equals("HTTP/0.9")) || (httpVersion.equals("HTTP/1.0"))));

@ -136,6 +136,7 @@ public class kelondroMap {
boolean run;
public writeQueue() {
super("kelondroMap:WriteQueue");
run = true;
}

@ -270,6 +270,7 @@ public class yacyCore {
public Exception error;
public publishThread(yacySeed seed) {
super("PublishSeed_" + seed.getName());
this.seed = seed;
this.added = 0;
this.error = null;

@ -247,6 +247,7 @@ public final class yacy {
sb,
30000 /*command max length incl. GET args*/,
httpdLoglevel /*loglevel*/);
server.setName("httpd:"+port);
if (server == null) {
serverLog.logFailure("STARTUP", "Failed to start server. Probably port " + port + " already in use.");
} else {

Loading…
Cancel
Save