|
|
@ -5,8 +5,9 @@
|
|
|
|
// first published on http://www.anomic.de
|
|
|
|
// first published on http://www.anomic.de
|
|
|
|
// Frankfurt, Germany, 2004
|
|
|
|
// Frankfurt, Germany, 2004
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// last major change: $LastChangedDate$ by $LastChangedBy$
|
|
|
|
// $LastChangedDate$
|
|
|
|
// Revision: $LastChangedRevision$
|
|
|
|
// $LastChangedRevision$
|
|
|
|
|
|
|
|
// $LastChangedBy$
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// 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
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
@ -337,7 +338,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2);
|
|
|
|
respond = new httpdByteCountOutputStream(respond,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE).length() + 2);
|
|
|
|
|
|
|
|
|
|
|
|
String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
|
|
|
|
String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
|
|
|
|
final String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH); // always starts with leading '/'
|
|
|
|
String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH); // always starts with leading '/'
|
|
|
|
final String args = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS); // may be null if no args were given
|
|
|
|
final String args = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS); // may be null if no args were given
|
|
|
|
final String ip = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP); // the ip from the connecting peer
|
|
|
|
final String ip = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP); // the ip from the connecting peer
|
|
|
|
int pos=0;
|
|
|
|
int pos=0;
|
|
|
@ -346,6 +347,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
URL url = null;
|
|
|
|
URL url = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
url = httpHeader.getRequestURL(conProp);
|
|
|
|
url = httpHeader.getRequestURL(conProp);
|
|
|
|
|
|
|
|
|
|
|
|
//redirector
|
|
|
|
//redirector
|
|
|
|
if (redirectorEnabled){
|
|
|
|
if (redirectorEnabled){
|
|
|
|
synchronized(redirectorProcess){
|
|
|
|
synchronized(redirectorProcess){
|
|
|
@ -389,6 +391,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
// blacklist idea inspired by [AS]:
|
|
|
|
// blacklist idea inspired by [AS]:
|
|
|
|
// respond a 404 for all AGIS ("all you get is shit") servers
|
|
|
|
// respond a 404 for all AGIS ("all you get is shit") servers
|
|
|
|
String hostlow = host.toLowerCase();
|
|
|
|
String hostlow = host.toLowerCase();
|
|
|
|
|
|
|
|
if (args != null) { path = path + "?" + args; }
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, path)) {
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, path)) {
|
|
|
|
httpd.sendRespondError(conProp,respond,4,403,null,
|
|
|
|
httpd.sendRespondError(conProp,respond,4,403,null,
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
@ -908,7 +911,11 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
|
|
|
|
|
|
|
|
// check the blacklist, inspired by [AS]: respond a 404 for all AGIS (all you get is shit) servers
|
|
|
|
// check the blacklist, inspired by [AS]: respond a 404 for all AGIS (all you get is shit) servers
|
|
|
|
String hostlow = host.toLowerCase();
|
|
|
|
String hostlow = host.toLowerCase();
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, path)) {
|
|
|
|
|
|
|
|
|
|
|
|
// re-calc the url path
|
|
|
|
|
|
|
|
String remotePath = (args == null) ? path : (path + "?" + args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, remotePath)) {
|
|
|
|
httpd.sendRespondError(conProp,respond,4,403,null,
|
|
|
|
httpd.sendRespondError(conProp,respond,4,403,null,
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
|
this.theLogger.logInfo("AGIS blocking of host '" + hostlow + "'");
|
|
|
|
this.theLogger.logInfo("AGIS blocking of host '" + hostlow + "'");
|
|
|
@ -927,9 +934,6 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
// resolve yacy and yacyh domains
|
|
|
|
// resolve yacy and yacyh domains
|
|
|
|
String yAddress = yacyCore.seedDB.resolveYacyAddress(host);
|
|
|
|
String yAddress = yacyCore.seedDB.resolveYacyAddress(host);
|
|
|
|
|
|
|
|
|
|
|
|
// re-calc the url path
|
|
|
|
|
|
|
|
String remotePath = (args == null) ? path : (path + "?" + args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// attach possible yacy-sublevel-domain
|
|
|
|
// attach possible yacy-sublevel-domain
|
|
|
|
if ((yAddress != null) && ((pos = yAddress.indexOf("/")) >= 0)) remotePath = yAddress.substring(pos) + remotePath;
|
|
|
|
if ((yAddress != null) && ((pos = yAddress.indexOf("/")) >= 0)) remotePath = yAddress.substring(pos) + remotePath;
|
|
|
|
|
|
|
|
|
|
|
@ -1104,6 +1108,9 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
|
|
|
|
|
|
|
|
String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
|
|
|
|
String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
|
|
|
|
String httpVersion = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
|
|
|
|
String httpVersion = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
|
|
|
|
|
|
|
|
String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);
|
|
|
|
|
|
|
|
final String args = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS);
|
|
|
|
|
|
|
|
if (args != null) { path = path + "?" + args; }
|
|
|
|
|
|
|
|
|
|
|
|
int port, pos;
|
|
|
|
int port, pos;
|
|
|
|
if ((pos = host.indexOf(":")) < 0) {
|
|
|
|
if ((pos = host.indexOf(":")) < 0) {
|
|
|
@ -1116,8 +1123,8 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
|
|
|
|
// check the blacklist
|
|
|
|
// check the blacklist
|
|
|
|
// blacklist idea inspired by [AS]:
|
|
|
|
// blacklist idea inspired by [AS]:
|
|
|
|
// respond a 404 for all AGIS ("all you get is shit") servers
|
|
|
|
// respond a 404 for all AGIS ("all you get is shit") servers
|
|
|
|
String hostlow = host.toLowerCase();
|
|
|
|
final String hostlow = host.toLowerCase();
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, "/")) {
|
|
|
|
if (plasmaSwitchboard.urlBlacklist.isListed(hostlow, path)) {
|
|
|
|
httpd.sendRespondError(conProp,clientOut,4,403,null,
|
|
|
|
httpd.sendRespondError(conProp,clientOut,4,403,null,
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
|
"URL '" + hostlow + "' blocked by yacy proxy (blacklisted)",null);
|
|
|
|
this.theLogger.logInfo("AGIS blocking of host '" + hostlow + "'");
|
|
|
|
this.theLogger.logInfo("AGIS blocking of host '" + hostlow + "'");
|
|
|
|