Remove broken spam/referrer handling
This commit is contained in:
parent
3a4d743eb5
commit
06f0315cf4
2 changed files with 0 additions and 28 deletions
|
@ -81,7 +81,6 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
String agent = null;
|
String agent = null;
|
||||||
String encodings = null;
|
String encodings = null;
|
||||||
String xff = null; // X-Forwarded-For
|
String xff = null; // X-Forwarded-For
|
||||||
String referer = null;
|
|
||||||
|
|
||||||
// more headers until first empty line
|
// more headers until first empty line
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
|
@ -108,12 +107,6 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
if (line.startsWith("x-forwarded-for: ")) {
|
if (line.startsWith("x-forwarded-for: ")) {
|
||||||
xff = line.substring("x-forwarded-for: ".length());
|
xff = line.substring("x-forwarded-for: ".length());
|
||||||
}
|
}
|
||||||
if (line.startsWith("Referer: ")) {
|
|
||||||
referer = line.substring("Referer: ".length());
|
|
||||||
}
|
|
||||||
if (line.startsWith("Referrer: ")) {
|
|
||||||
referer = line.substring("Referrer: ".length());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InetAddress ip = clientSocket.getInetAddress();
|
InetAddress ip = clientSocket.getInetAddress();
|
||||||
|
@ -139,15 +132,6 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (referer != null && referer.indexOf("brouter.de/brouter-web") >= 0) {
|
|
||||||
if (getline.indexOf("%7C") >= 0 && getline.indexOf("%2C") >= 0) {
|
|
||||||
writeHttpHeader(bw, HTTP_STATUS_FORBIDDEN);
|
|
||||||
bw.write("Spam? please stop");
|
|
||||||
bw.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getline.startsWith("GET /favicon.ico")) {
|
if (getline.startsWith("GET /favicon.ico")) {
|
||||||
writeHttpHeader(bw, HTTP_STATUS_NOT_FOUND);
|
writeHttpHeader(bw, HTTP_STATUS_NOT_FOUND);
|
||||||
bw.flush();
|
bw.flush();
|
||||||
|
|
|
@ -4,7 +4,6 @@ package btools.server;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -102,15 +101,4 @@ public class RouteServerTest {
|
||||||
|
|
||||||
Assert.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, httpConnection.getResponseCode());
|
Assert.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, httpConnection.getResponseCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore("Broken implementation (uppercase / lowercase issue)")
|
|
||||||
public void invalidReferrer() throws IOException {
|
|
||||||
URL requestUrl = new URL(baseUrl + "brouter/%7C/%2C");
|
|
||||||
HttpURLConnection httpConnection = (HttpURLConnection) requestUrl.openConnection();
|
|
||||||
httpConnection.setRequestProperty("Referer", "http://brouter.de/brouter-web/");
|
|
||||||
httpConnection.connect();
|
|
||||||
|
|
||||||
Assert.assertEquals(HttpURLConnection.HTTP_FORBIDDEN, httpConnection.getResponseCode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue