From 30015c1933355f140843faefc47b3e258fac83db Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 1 Feb 2019 13:49:13 +0000 Subject: [PATCH] i2ptunnel: Handle PUT like POST --- .../src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java | 2 +- .../src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java | 10 ++++++---- .../java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java | 4 +++- history.txt | 11 +++++++++++ router/java/src/net/i2p/router/RouterVersion.java | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index a2603c24f..07fddab13 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -1279,7 +1279,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn // and not pass the parameter to the eepsite. // This also prevents the not-found error page from looking bad // Syndie can't handle a redirect of a POST - if(ahelperPresent && !"POST".equals(method)) { + if (ahelperPresent && !"POST".equals(method) && !"PUT".equals(method)) { String uri = targetRequest; if(_log.shouldLog(Log.DEBUG)) { _log.debug("Auto redirecting to " + uri); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index a27201c30..914c39aa7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -230,7 +230,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { long pb = 1000L * getIntOption(OPT_POST_BAN_TIME, DEFAULT_POST_BAN_TIME); long px = 1000L * getIntOption(OPT_POST_TOTAL_BAN_TIME, DEFAULT_POST_TOTAL_BAN_TIME); if (_postThrottler == null) - _postThrottler = new ConnThrottler(pp, pt, pw, pb, px, "POST", _log); + _postThrottler = new ConnThrottler(pp, pt, pw, pb, px, "POST/PUT", _log); else _postThrottler.updateLimits(pp, pt, pw, pb, px); } @@ -481,10 +481,11 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { if (_postThrottler != null && command.length() >= 5 && - command.substring(0, 5).toUpperCase(Locale.US).equals("POST ")) { + (command.substring(0, 5).toUpperCase(Locale.US).equals("POST ") || + command.substring(0, 4).toUpperCase(Locale.US).equals("PUT "))) { if (_postThrottler.shouldThrottle(peerHash)) { if (_log.shouldLog(Log.WARN)) - _log.warn("Refusing POST since peer is throttled: " + peerB32); + _log.warn("Refusing POST/PUT since peer is throttled: " + peerB32); try { // Send a 429, so the user doesn't get an HTTP Proxy error message // and blame his router or the network. @@ -641,7 +642,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { _log.info("request headers: " + _headers); serverout.write(DataHelper.getUTF8(_headers)); browserin = _browser.getInputStream(); - // Don't spin off a thread for this except for POSTs + // Don't spin off a thread for this except for POSTs and PUTs + // TODO Upgrade: // beware interference with Shoutcast, etc.? if ((!(_headers.startsWith("GET ") || _headers.startsWith("HEAD "))) || browserin.available() > 0) { // just in case diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java index a6f81bf0d..800251e0a 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java @@ -254,6 +254,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr protected OutputStream getSocketOut() throws IOException { return s.getOutputStream(); } private static final byte[] POST = { 'P', 'O', 'S', 'T', ' ' }; + private static final byte[] PUT = { 'P', 'U', 'T', ' ' }; @Override public void run() { @@ -289,7 +290,8 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr if (initialI2PData.length <= 1730) { // ConnectionOptions.DEFAULT_MAX_MESSAGE_SIZE // Don't flush if POST, so we can get POST data into the initial packet if (initialI2PData.length < 5 || - !DataHelper.eq(POST, 0, initialI2PData, 0, 5)) + !(DataHelper.eq(POST, 0, initialI2PData, 0, 5) || + DataHelper.eq(PUT, 0, initialI2PData, 0, 4))) i2pout.flush(); } //} diff --git a/history.txt b/history.txt index 02acea006..31b88952d 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,14 @@ +2019-02-01 zzz + * Debian: AppArmor fix for Oracle JVM (ticket #2319) + * i2ptunnel: + - Caching of outproxy selection, avoid last-failed outproxy + - More localhost checks + - Handle PUT like POST + +2019-01-31 zzz + * Debian: Fix version detection of Tomcat 9 required + for reproducible builds (ticket #2279) + 2019-01-30 zzz * Build: Fix javac.classpath in junit.compileTest targets (ticket #2333) * I2CP: Fixes for CreateLeaseset2 message with multiple keys diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 0725033fa..f6e6df3a5 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 3; + public final static long BUILD = 4; /** for example "-test" */ public final static String EXTRA = "";