i2ptunnel: Handle PUT like POST

This commit is contained in:
zzz
2019-02-01 13:49:13 +00:00
parent 4f8455040e
commit 30015c1933
5 changed files with 22 additions and 7 deletions

View File

@ -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);

View File

@ -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

View File

@ -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();
}
//}

View File

@ -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

View File

@ -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 = "";