From 80a2d2c1f509166a2208eef80f0fd802e52af7c2 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 18 Mar 2015 14:40:17 +0000 Subject: [PATCH] Router: Allow disabling the setting of some System properties, for embedded applications --- router/java/src/net/i2p/router/Router.java | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 7de8080694..2ca23969d2 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -116,20 +116,32 @@ public class Router implements RouterClock.ClockShiftListener { private static final String originalTimeZoneID; static { - // grumble about sun's java caching DNS entries *forever* by default - // so lets just keep 'em for a short time - System.setProperty("sun.net.inetaddr.ttl", DNS_CACHE_TIME); - System.setProperty("sun.net.inetaddr.negative.ttl", DNS_CACHE_TIME); - System.setProperty("networkaddress.cache.ttl", DNS_CACHE_TIME); - System.setProperty("networkaddress.cache.negative.ttl", DNS_CACHE_TIME); - System.setProperty("http.agent", "I2P"); - // (no need for keepalive) - System.setProperty("http.keepAlive", "false"); + // + // If embedding I2P you may wish to disable one or more of the following + // via the associated System property. Since 0.9.19. + // + if (System.getProperty("I2P_DISABLE_DNS_CACHE_OVERRIDE") == null) { + // grumble about sun's java caching DNS entries *forever* by default + // so lets just keep 'em for a short time + System.setProperty("sun.net.inetaddr.ttl", DNS_CACHE_TIME); + System.setProperty("sun.net.inetaddr.negative.ttl", DNS_CACHE_TIME); + System.setProperty("networkaddress.cache.ttl", DNS_CACHE_TIME); + System.setProperty("networkaddress.cache.negative.ttl", DNS_CACHE_TIME); + } + if (System.getProperty("I2P_DISABLE_HTTP_AGENT_OVERRIDE") == null) { + System.setProperty("http.agent", "I2P"); + } + if (System.getProperty("I2P_DISABLE_HTTP_KEEPALIVE_OVERRIDE") == null) { + // (no need for keepalive) + System.setProperty("http.keepAlive", "false"); + } // Save it for LogManager originalTimeZoneID = TimeZone.getDefault().getID(); - System.setProperty("user.timezone", "GMT"); - // just in case, lets make it explicit... - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + if (System.getProperty("I2P_DISABLE_TIMEZONE_OVERRIDE") == null) { + System.setProperty("user.timezone", "GMT"); + // just in case, lets make it explicit... + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + } // https://www.kb.cert.org/vuls/id/402580 // http://docs.codehaus.org/display/JETTY/SystemProperties // Fixed in Jetty 5.1.15 but we are running 5.1.12 -- GitLab