I2CP: Add PROP_GZIP

i2ptunnel: Disable I2CP gzip for HTTP server tunnels
i2psnark: Disable I2CP gzip
This commit is contained in:
zzz
2020-05-02 22:16:39 +00:00
parent 47f09479ad
commit 0528e4109d
5 changed files with 19 additions and 2 deletions

View File

@ -295,6 +295,9 @@ public class I2PSnarkUtil {
opts.setProperty("i2p.streaming.answerPings", "false");
if (opts.getProperty(I2PClient.PROP_SIGTYPE) == null)
opts.setProperty(I2PClient.PROP_SIGTYPE, "EdDSA_SHA512_Ed25519");
// assume compressed content
if (opts.getProperty(I2PClient.PROP_GZIP) == null)
opts.setProperty(I2PClient.PROP_GZIP, "false");
_manager = I2PSocketManagerFactory.createManager(_i2cpHost, _i2cpPort, opts);
if (_manager != null)
_startedTime = _context.clock().now();

View File

@ -547,7 +547,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
// server, reads the response headers, rewriting to include Content-Encoding: x-i2p-gzip
// if it was one of the Accept-Encoding: values, and gzip the payload
boolean allowGZIP = true;
String val = opts.getProperty("i2ptunnel.gzip");
String val = opts.getProperty(TunnelController.PROP_TUN_GZIP);
if ( (val != null) && (!Boolean.parseBoolean(val)) )
allowGZIP = false;
if (_log.shouldLog(Log.INFO))

View File

@ -89,6 +89,8 @@ public class TunnelController implements Logging {
public static final String PROP_FILTER = "filterDefinition";
/** @since 0.9.42 */
public static final String PROP_CONFIG_FILE = "configFile";
/** @since 0.9.46 */
public static final String PROP_TUN_GZIP = "i2ptunnel.gzip";
/**
* all of these are @since 0.9.33 (moved from TunnelConfig)
@ -139,6 +141,7 @@ public class TunnelController implements Logging {
/** @since 0.9.34 */
private static final String OPT_LIMIT_ACTION = PFX_OPTION + PROP_LIMIT_ACTION;
private static final String OPT_I2CP_GZIP = PFX_OPTION + I2PClient.PROP_GZIP;
/** all of these @since 0.9.14 */
public static final String TYPE_CONNECT = "connectclient";
@ -834,6 +837,15 @@ public class TunnelController implements Logging {
if (type.equals(TYPE_HTTP_SERVER)) {
if (!_config.containsKey(OPT_LIMIT_ACTION))
_config.setProperty(OPT_LIMIT_ACTION, "http");
String tgzip = _config.getProperty(PROP_TUN_GZIP);
if (tgzip == null || Boolean.valueOf(tgzip)) {
// Web server will gzip
// If web server doesn't gzip, I2PTunnelHTTPServer will.
// Streaming will force gzip on first packet for header compression,
// regardless of this setting
if (!_config.containsKey(OPT_I2CP_GZIP))
_config.setProperty(OPT_I2CP_GZIP, "false");
}
}
if (type.equals(TYPE_HTTP_SERVER) || type.equals(TYPE_STREAMR_SERVER)) {
if (!_config.containsKey(OPT_BUNDLE_REPLY))

View File

@ -70,6 +70,8 @@ public interface I2PClient {
public static final String PROP_USER = "i2cp.username";
/** @since 0.9.44, was protected in I2PSessionImpl */
public static final String PROP_PW = "i2cp.password";
/** @since 0.9.46 */
public static final String PROP_GZIP = "i2cp.gzip";
/**
* 7654

View File

@ -188,7 +188,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
protected boolean shouldCompress(int size) {
if (size <= DONT_COMPRESS_SIZE)
return false;
String p = getOptions().getProperty("i2cp.gzip");
String p = getOptions().getProperty(I2PClient.PROP_GZIP);
if (p != null)
return Boolean.parseBoolean(p);
return SHOULD_COMPRESS;