forked from I2P_Developers/i2p.i2p
log tweaks
This commit is contained in:
@@ -269,9 +269,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
@Override
|
@Override
|
||||||
protected void blockingHandle(I2PSocket socket) {
|
protected void blockingHandle(I2PSocket socket) {
|
||||||
Hash peerHash = socket.getPeerDestination().calculateHash();
|
Hash peerHash = socket.getPeerDestination().calculateHash();
|
||||||
|
String peerB32 = socket.getPeerDestination().toBase32();
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Incoming connection to '" + toString() + "' port " + socket.getLocalPort() +
|
_log.info("Incoming connection to '" + toString() + "' port " + socket.getLocalPort() +
|
||||||
" from: " + peerHash + " port " + socket.getPort());
|
" from: " + peerB32 + " port " + socket.getPort());
|
||||||
//local is fast, so synchronously. Does not need that many
|
//local is fast, so synchronously. Does not need that many
|
||||||
//threads.
|
//threads.
|
||||||
try {
|
try {
|
||||||
@@ -314,7 +315,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
try { socket.close(); } catch (IOException ioe) {}
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request", ste);
|
_log.warn("Error in the HTTP request from " + peerB32, ste);
|
||||||
return;
|
return;
|
||||||
} catch (EOFException eofe) {
|
} catch (EOFException eofe) {
|
||||||
try {
|
try {
|
||||||
@@ -324,7 +325,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
try { socket.close(); } catch (IOException ioe) {}
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request", eofe);
|
_log.warn("Error in the HTTP request from " + peerB32, eofe);
|
||||||
return;
|
return;
|
||||||
} catch (LineTooLongException ltle) {
|
} catch (LineTooLongException ltle) {
|
||||||
try {
|
try {
|
||||||
@@ -334,7 +335,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
try { socket.close(); } catch (IOException ioe) {}
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request", ltle);
|
_log.warn("Error in the HTTP request from " + peerB32, ltle);
|
||||||
return;
|
return;
|
||||||
} catch (RequestTooLongException rtle) {
|
} catch (RequestTooLongException rtle) {
|
||||||
try {
|
try {
|
||||||
@@ -344,7 +345,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
try { socket.close(); } catch (IOException ioe) {}
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request", rtle);
|
_log.warn("Error in the HTTP request from " + peerB32, rtle);
|
||||||
return;
|
return;
|
||||||
} catch (BadRequestException bre) {
|
} catch (BadRequestException bre) {
|
||||||
try {
|
try {
|
||||||
@@ -354,7 +355,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
try { socket.close(); } catch (IOException ioe) {}
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request", bre);
|
_log.warn("Error in the HTTP request from " + peerB32, bre);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long afterHeaders = getTunnel().getContext().clock().now();
|
long afterHeaders = getTunnel().getContext().clock().now();
|
||||||
@@ -367,7 +368,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
headers.containsKey("X-Forwarded-Host"))) {
|
headers.containsKey("X-Forwarded-Host"))) {
|
||||||
if (_log.shouldLog(Log.WARN)) {
|
if (_log.shouldLog(Log.WARN)) {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("Refusing inproxy access: ").append(Base32.encode(peerHash.getData())).append(".b32.i2p");
|
buf.append("Refusing inproxy access: ").append(peerB32);
|
||||||
List<String> h = headers.get("X-Forwarded-For");
|
List<String> h = headers.get("X-Forwarded-For");
|
||||||
if (h != null)
|
if (h != null)
|
||||||
buf.append(" from: ").append(h.get(0));
|
buf.append(" from: ").append(h.get(0));
|
||||||
@@ -403,8 +404,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
referer = referer.substring(9);
|
referer = referer.substring(9);
|
||||||
if (referer.startsWith("http://") || referer.startsWith("https://")) {
|
if (referer.startsWith("http://") || referer.startsWith("https://")) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Refusing access from: " +
|
_log.warn("Refusing access from: " + peerB32 +
|
||||||
Base32.encode(peerHash.getData()) + ".b32.i2p" +
|
|
||||||
" with Referer: " + referer);
|
" with Referer: " + referer);
|
||||||
try {
|
try {
|
||||||
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
||||||
@@ -431,8 +431,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
continue;
|
continue;
|
||||||
if (ag.length() > 0 && ua.contains(ag)) {
|
if (ag.length() > 0 && ua.contains(ag)) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Refusing access from: " +
|
_log.warn("Refusing access from: " + peerB32 +
|
||||||
Base32.encode(peerHash.getData()) + ".b32.i2p" +
|
|
||||||
" with User-Agent: " + ua);
|
" with User-Agent: " + ua);
|
||||||
try {
|
try {
|
||||||
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
||||||
@@ -454,8 +453,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
String ag = agents[i].trim();
|
String ag = agents[i].trim();
|
||||||
if (ag.equals("none")) {
|
if (ag.equals("none")) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Refusing access from: " +
|
_log.warn("Refusing access from: " + peerB32 +
|
||||||
Base32.encode(peerHash.getData()) + ".b32.i2p" +
|
|
||||||
" with empty User-Agent");
|
" with empty User-Agent");
|
||||||
try {
|
try {
|
||||||
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
socket.getOutputStream().write(ERR_INPROXY.getBytes("UTF-8"));
|
||||||
@@ -475,8 +473,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
command.substring(0, 5).toUpperCase(Locale.US).equals("POST ")) {
|
command.substring(0, 5).toUpperCase(Locale.US).equals("POST ")) {
|
||||||
if (_postThrottler.shouldThrottle(peerHash)) {
|
if (_postThrottler.shouldThrottle(peerHash)) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Refusing POST since peer is throttled: " +
|
_log.warn("Refusing POST since peer is throttled: " + peerB32);
|
||||||
Base32.encode(peerHash.getData()) + ".b32.i2p");
|
|
||||||
try {
|
try {
|
||||||
// Send a 403, so the user doesn't get an HTTP Proxy error message
|
// Send a 403, so the user doesn't get an HTTP Proxy error message
|
||||||
// and blame his router or the network.
|
// and blame his router or the network.
|
||||||
@@ -490,7 +487,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addEntry(headers, HASH_HEADER, peerHash.toBase64());
|
addEntry(headers, HASH_HEADER, peerHash.toBase64());
|
||||||
addEntry(headers, DEST32_HEADER, socket.getPeerDestination().toBase32());
|
addEntry(headers, DEST32_HEADER, peerB32);
|
||||||
addEntry(headers, DEST64_HEADER, socket.getPeerDestination().toBase64());
|
addEntry(headers, DEST64_HEADER, socket.getPeerDestination().toBase64());
|
||||||
|
|
||||||
// Port-specific spoofhost
|
// Port-specific spoofhost
|
||||||
@@ -581,7 +578,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
|||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException ioe) {}
|
} catch (IOException ioe) {}
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error while receiving the new HTTP request from: " + Base32.encode(peerHash.getData()) + ".b32.i2p", ex);
|
_log.warn("Error in the HTTP request from: " + peerB32, ex);
|
||||||
} catch (OutOfMemoryError oom) {
|
} catch (OutOfMemoryError oom) {
|
||||||
// Often actually a file handle limit problem so we can safely send a response
|
// Often actually a file handle limit problem so we can safely send a response
|
||||||
// java.lang.OutOfMemoryError: unable to create new native thread
|
// java.lang.OutOfMemoryError: unable to create new native thread
|
||||||
|
Reference in New Issue
Block a user