forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 5d56a7eb371dddb9336e596bda69f99c91294b05)
to branch 'i2p.i2p.str4d.ui' (head 3aeafcdb5c0ffbc9c77f574558f8438d3e81133e)
This commit is contained in:
@ -70,11 +70,15 @@
|
||||
<pathelement location="../../jetty/jettylib/jetty-util.jar" />
|
||||
<pathelement location="../../jetty/jettylib/jetty-webapp.jar" />
|
||||
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
|
||||
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
|
||||
<pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
|
||||
<pathelement location="../../systray/java/build/systray.jar" />
|
||||
<pathelement location="../../desktopgui/dist/desktopgui.jar" />
|
||||
<pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
|
||||
<pathelement location="../../jrobin/java/build/jrobin.jar" />
|
||||
|
||||
<!-- following jars only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/tomcat-api.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
@ -362,17 +366,22 @@
|
||||
** -trimSpaces Trim spaces in template text between actions, directives
|
||||
-->
|
||||
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
|
||||
<!-- this prevents tomcat from complaining in debian builds -->
|
||||
<jvmarg value="-Dtomcat.util.scan.StandardJarScanFilter.jarsToSkip=commons-collections.jar,junit.jar,junit4.jar" />
|
||||
<classpath>
|
||||
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
|
||||
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
|
||||
<!-- jsp-api.jar only present for debian builds -->
|
||||
|
||||
<!-- following jars only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/jsp-api.jar" />
|
||||
<!-- tomcat-api.jar only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/tomcat-api.jar" />
|
||||
<!-- jasper-el.jar only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/jasper-el.jar" />
|
||||
<pathelement location="../../jetty/jettylib/tomcat-util.jar" />
|
||||
<pathelement location="../../jetty/jettylib/tomcat-util-scan.jar" />
|
||||
|
||||
<pathelement location="../../jetty/jettylib/commons-logging.jar" />
|
||||
<pathelement location="../../jetty/jettylib/commons-el.jar" />
|
||||
<pathelement location="../../jetty/jettylib/jetty-util.jar" />
|
||||
<pathelement location="${ant.home}/lib/ant.jar" />
|
||||
<pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
|
||||
<pathelement location="../../systray/java/build/obj" />
|
||||
@ -403,10 +412,13 @@
|
||||
<classpath>
|
||||
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
|
||||
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
|
||||
<!-- jsp-api.jar only present for debian builds -->
|
||||
|
||||
<!-- following jars only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/jsp-api.jar" />
|
||||
<!-- tomcat-api.jar only present for debian builds -->
|
||||
<pathelement location="../../jetty/jettylib/tomcat-api.jar" />
|
||||
<pathelement location="../../jetty/jettylib/tomcat-util.jar" />
|
||||
<pathelement location="../../jetty/jettylib/tomcat-util-scan.jar" />
|
||||
|
||||
<pathelement location="../../jetty/jettylib/commons-logging.jar" />
|
||||
<pathelement location="../../jetty/jettylib/commons-el.jar" />
|
||||
<pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
|
||||
|
@ -457,6 +457,13 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
statusDone("<b>" + _t("Plugin requires Jetty version {0} or higher", minVersion) + "</b>");
|
||||
return;
|
||||
}
|
||||
String blacklistVersion = PluginStarter.jetty9Blacklist.get(appName);
|
||||
if (blacklistVersion != null &&
|
||||
VersionComparator.comp(version, blacklistVersion) <= 0) {
|
||||
to.delete();
|
||||
statusDone("<b>" + _t("Plugin requires Jetty version {0} or lower", "8.9999") + "</b>");
|
||||
return;
|
||||
}
|
||||
maxVersion = ConfigClientsHelper.stripHTML(props, "max-jetty-version");
|
||||
if (maxVersion != null &&
|
||||
VersionComparator.comp(maxVersion, oldVersion) < 0) {
|
||||
@ -480,7 +487,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
}
|
||||
// we don't need the original file anymore.
|
||||
to.delete();
|
||||
statusDone("<b>" + _t("Plugin will be installed on next restart.") + "</b>");
|
||||
statusDone("<b>" + _t("Plugin will be installed on next restart.") + ' ' + appName + ' ' + version + "</b>");
|
||||
return;
|
||||
}
|
||||
if (PluginStarter.isPluginRunning(appName, _context)) {
|
||||
@ -498,7 +505,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
} else {
|
||||
if (Boolean.valueOf(props.getProperty("update-only")).booleanValue()) {
|
||||
to.delete();
|
||||
statusDone("<b>" + _t("Plugin is for upgrades only, but the plugin is not installed") + "</b>");
|
||||
statusDone("<b>" + _t("Plugin is for upgrades only, but the plugin is not installed") + ". " + appName + ' ' + version + "</b>");
|
||||
return;
|
||||
}
|
||||
if (!destDir.mkdir()) {
|
||||
@ -518,7 +525,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
to.delete();
|
||||
// install != update. Changing the user's settings like this is probabbly a bad idea.
|
||||
if (Boolean.valueOf( props.getProperty("dont-start-at-install")).booleanValue()) {
|
||||
statusDone("<b>" + _t("Plugin {0} installed", appName) + "</b>");
|
||||
statusDone("<b>" + _t("Plugin {0} installed", appName + ' ' + version) + "</b>");
|
||||
if(!update) {
|
||||
Properties pluginProps = PluginStarter.pluginProperties();
|
||||
pluginProps.setProperty(PluginStarter.PREFIX + appName + PluginStarter.ENABLED, "false");
|
||||
@ -534,19 +541,19 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
String linkURL = ConfigClientsHelper.stripHTML(props, "consoleLinkURL");
|
||||
String link;
|
||||
if (linkName != null && linkURL != null)
|
||||
link = "<a target=\"_blank\" href=\"" + linkURL + "\"/>" + linkName + "</a>";
|
||||
link = "<a target=\"_blank\" href=\"" + linkURL + "\"/>" + linkName + ' ' + version + "</a>";
|
||||
else
|
||||
link = appName;
|
||||
link = appName + ' ' + version;
|
||||
statusDone("<b>" + _t("Plugin {0} installed and started", link) + "</b>");
|
||||
}
|
||||
else
|
||||
statusDone("<b>" + _t("Plugin {0} installed but failed to start, check logs", appName) + "</b>");
|
||||
statusDone("<b>" + _t("Plugin {0} installed but failed to start, check logs", appName + ' ' + version) + "</b>");
|
||||
} catch (Throwable e) {
|
||||
statusDone("<b>" + _t("Plugin {0} installed but failed to start", appName) + ": " + e + "</b>");
|
||||
_log.error("Error starting plugin " + appName, e);
|
||||
statusDone("<b>" + _t("Plugin {0} installed but failed to start", appName + ' ' + version) + ": " + e + "</b>");
|
||||
_log.error("Error starting plugin " + appName + ' ' + version, e);
|
||||
}
|
||||
} else {
|
||||
statusDone("<b>" + _t("Plugin {0} installed", appName) + "</b>");
|
||||
statusDone("<b>" + _t("Plugin {0} installed", appName + ' ' + version) + "</b>");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class CodedIconRendererServlet extends HttpServlet {
|
||||
|
||||
|
||||
@Override
|
||||
protected void service(HttpServletRequest srq, HttpServletResponse srs) throws ServletException, IOException {
|
||||
protected void doGet(HttpServletRequest srq, HttpServletResponse srs) throws ServletException, IOException {
|
||||
byte[] data;
|
||||
String name = srq.getParameter("plugin");
|
||||
data = NavHelper.getBinary(name);
|
||||
|
@ -573,7 +573,18 @@ public class ConfigClientsHandler extends FormHandler {
|
||||
private void startPlugin(String app) {
|
||||
try {
|
||||
PluginStarter.startPlugin(_context, app);
|
||||
addFormNotice(_t("Started plugin {0}", app));
|
||||
// linkify the app name for the message if available
|
||||
Properties props = PluginStarter.pluginProperties(_context, app);
|
||||
String name = ConfigClientsHelper.stripHTML(props, "consoleLinkName_" + Messages.getLanguage(_context));
|
||||
if (name == null)
|
||||
name = ConfigClientsHelper.stripHTML(props, "consoleLinkName");
|
||||
String url = ConfigClientsHelper.stripHTML(props, "consoleLinkURL");
|
||||
if (name != null && url != null && name.length() > 0 && url.length() > 0) {
|
||||
app = "<a href=\"" + url + "\">" + name + "</a>";
|
||||
addFormNoticeNoEscape(_t("Started plugin {0}", app));
|
||||
} else {
|
||||
addFormNotice(_t("Started plugin {0}", app));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
addFormError(_t("Error starting plugin {0}", app) + ": " + e);
|
||||
_log.error("Error starting plugin " + app, e);
|
||||
|
@ -67,6 +67,22 @@ public class PluginStarter implements Runnable {
|
||||
private static Map<String, ClassLoader> _clCache = new ConcurrentHashMap<String, ClassLoader>();
|
||||
private static Map<String, Collection<String>> pluginWars = new ConcurrentHashMap<String, Collection<String>>();
|
||||
|
||||
/**
|
||||
* Plugin name to plugin version of plugins that do not work
|
||||
* with Jetty 9, but do not have a max-jetty-version=8.9999 set.
|
||||
* Unmodifiable.
|
||||
*
|
||||
* @since 0.9.30
|
||||
*/
|
||||
public static final Map<String, String> jetty9Blacklist;
|
||||
|
||||
static {
|
||||
Map<String, String> map = new HashMap<String, String>(4);
|
||||
map.put("i2pbote", "0.4.5");
|
||||
map.put("BwSchedule", "0.0.36");
|
||||
jetty9Blacklist = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public PluginStarter(RouterContext ctx) {
|
||||
_context = ctx;
|
||||
}
|
||||
@ -297,8 +313,8 @@ public class PluginStarter implements Runnable {
|
||||
|
||||
Properties props = pluginProperties(ctx, appName);
|
||||
|
||||
|
||||
|
||||
// For the following, we use the exact same translated strings as in PluginUpdateRunner
|
||||
// to avoid duplication
|
||||
|
||||
String minVersion = ConfigClientsHelper.stripHTML(props, "min-i2p-version");
|
||||
if (minVersion != null &&
|
||||
@ -306,6 +322,7 @@ public class PluginStarter implements Runnable {
|
||||
String foo = "Plugin " + appName + " requires I2P version " + minVersion + " or higher";
|
||||
log.error(foo);
|
||||
disablePlugin(appName);
|
||||
foo = gettext("This plugin requires I2P version {0} or higher", minVersion, ctx);
|
||||
throw new Exception(foo);
|
||||
}
|
||||
|
||||
@ -315,6 +332,7 @@ public class PluginStarter implements Runnable {
|
||||
String foo = "Plugin " + appName + " requires Java version " + minVersion + " or higher";
|
||||
log.error(foo);
|
||||
disablePlugin(appName);
|
||||
foo = gettext("This plugin requires Java version {0} or higher", minVersion, ctx);
|
||||
throw new Exception(foo);
|
||||
}
|
||||
|
||||
@ -325,6 +343,18 @@ public class PluginStarter implements Runnable {
|
||||
String foo = "Plugin " + appName + " requires Jetty version " + minVersion + " or higher";
|
||||
log.error(foo);
|
||||
disablePlugin(appName);
|
||||
foo = gettext("Plugin requires Jetty version {0} or higher", minVersion, ctx);
|
||||
throw new Exception(foo);
|
||||
}
|
||||
|
||||
String blacklistVersion = jetty9Blacklist.get(appName);
|
||||
String curVersion = ConfigClientsHelper.stripHTML(props, "version");
|
||||
if (blacklistVersion != null &&
|
||||
VersionComparator.comp(curVersion, blacklistVersion) <= 0) {
|
||||
String foo = "Plugin " + appName + " requires Jetty version 8.9999 or lower";
|
||||
log.error(foo);
|
||||
disablePlugin(appName);
|
||||
foo = gettext("Plugin requires Jetty version {0} or lower", "8.9999", ctx);
|
||||
throw new Exception(foo);
|
||||
}
|
||||
|
||||
@ -334,6 +364,7 @@ public class PluginStarter implements Runnable {
|
||||
String foo = "Plugin " + appName + " requires Jetty version " + maxVersion + " or lower";
|
||||
log.error(foo);
|
||||
disablePlugin(appName);
|
||||
foo = gettext("Plugin requires Jetty version {0} or lower", maxVersion, ctx);
|
||||
throw new Exception(foo);
|
||||
}
|
||||
|
||||
@ -1002,6 +1033,14 @@ public class PluginStarter implements Runnable {
|
||||
method.invoke(urlClassLoader, new Object[]{u});
|
||||
}
|
||||
|
||||
/**
|
||||
* translate a string
|
||||
* @since 0.9.30
|
||||
*/
|
||||
private static String gettext(String s, Object o, I2PAppContext ctx) {
|
||||
return Messages.getString(s, o, ctx);
|
||||
}
|
||||
|
||||
/** translate a string */
|
||||
private static String ngettext(String s, String p, int n, I2PAppContext ctx) {
|
||||
return Messages.getString(n, s, p, ctx);
|
||||
|
@ -17,9 +17,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@ -46,19 +46,21 @@ import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.authentication.DigestAuthenticator;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.NCSARequestLog;
|
||||
import org.eclipse.jetty.server.SecureRequestCustomizer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.server.ssl.SslSocketConnector;
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -70,6 +72,7 @@ import org.eclipse.jetty.util.security.Credential.MD5;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.ExecutorThreadPool;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
import org.tanukisoftware.wrapper.WrapperManager;
|
||||
@ -96,7 +99,7 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
private final ClientAppManager _mgr;
|
||||
private volatile ClientAppState _state = UNINITIALIZED;
|
||||
private static Server _server;
|
||||
private static Timer _jettyTimer;
|
||||
private static ScheduledExecutorScheduler _jettyTimer;
|
||||
private String _listenPort;
|
||||
private String _listenHost;
|
||||
private String _sslListenPort;
|
||||
@ -231,6 +234,7 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
changeState(STOPPING);
|
||||
if (PluginStarter.pluginsEnabled(_context))
|
||||
(new I2PAppThread(new PluginStopper(_context), "PluginStopper")).start();
|
||||
stopAllWebApps();
|
||||
try {
|
||||
_server.stop();
|
||||
} catch (Exception ie) {}
|
||||
@ -239,7 +243,9 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE);
|
||||
synchronized(RouterConsoleRunner.class) {
|
||||
if (_jettyTimer != null) {
|
||||
_jettyTimer.cancel();
|
||||
try {
|
||||
_jettyTimer.stop();
|
||||
} catch (Exception e) {}
|
||||
_jettyTimer = null;
|
||||
}
|
||||
}
|
||||
@ -363,6 +369,22 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
* DefaultHandler
|
||||
* RequestLogHandler (opt)
|
||||
*</pre>
|
||||
*
|
||||
* Porting to Jetty 9:
|
||||
*
|
||||
* http://dev.eclipse.org/mhonarc/lists/jetty-dev/msg01952.html
|
||||
* You are missing a few facts about Jetty 9.1 ...
|
||||
* First, there are no longer any blocking connectors.
|
||||
* Its all async / nio connectors now. (mainly because that's the direction that the servlet api 3.1 is taking)
|
||||
*
|
||||
* Next, there is only 1 connector. The ServerConnector.
|
||||
* However, it takes 1 or more ConnectionFactory implementations to know how to handle the incoming connection.
|
||||
* We have factories for HTTP (0.9 thru 1.1), SPDY, SSL-http, and SSL-npn so far.
|
||||
* This list of factories will expand as the future of connectivity to web servers is ever growing (think HTTP/2)
|
||||
*
|
||||
* Use the embedded examples for help understanding this.
|
||||
* http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java?id=jetty-9.1.0.RC0
|
||||
*
|
||||
*/
|
||||
public void startConsole() {
|
||||
File workDir = new SecureDirectory(_context.getTempDir(), "jetty-work");
|
||||
@ -375,8 +397,9 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
|
||||
// so Jetty can find WebAppConfiguration
|
||||
System.setProperty("jetty.class.path", _context.getBaseDir() + "/lib/routerconsole.jar");
|
||||
_server = new Server();
|
||||
_server.setGracefulShutdown(1000);
|
||||
// FIXME
|
||||
// http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03487.html
|
||||
//_server.setGracefulShutdown(1000);
|
||||
|
||||
// In Jetty 6, QTP was not concurrent, so we switched to
|
||||
// ThreadPoolExecutor with a fixed-size queue, a set maxThreads,
|
||||
@ -408,14 +431,11 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
// class not found...
|
||||
//System.out.println("INFO: Jetty concurrent ThreadPool unavailable, using QueuedThreadPool");
|
||||
LinkedBlockingQueue<Runnable> lbq = new LinkedBlockingQueue<Runnable>(4*MAX_THREADS);
|
||||
QueuedThreadPool qtp = new QueuedThreadPool(lbq);
|
||||
// min and max threads will be set below
|
||||
//qtp.setMinThreads(MIN_THREADS);
|
||||
//qtp.setMaxThreads(MAX_THREADS);
|
||||
qtp.setMaxIdleTimeMs(MAX_IDLE_TIME);
|
||||
// min and max threads will be reset below
|
||||
QueuedThreadPool qtp = new QueuedThreadPool(MAX_THREADS, MIN_THREADS, MAX_IDLE_TIME, lbq);
|
||||
qtp.setName(THREAD_NAME);
|
||||
qtp.setDaemon(true);
|
||||
_server.setThreadPool(qtp);
|
||||
_server = new Server(qtp);
|
||||
//}
|
||||
|
||||
HandlerCollection hColl = new HandlerCollection();
|
||||
@ -502,27 +522,15 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
} finally {
|
||||
if (testSock != null) try { testSock.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
//if (host.indexOf(":") >= 0) // IPV6 - requires patched Jetty 5
|
||||
// _server.addListener('[' + host + "]:" + _listenPort);
|
||||
//else
|
||||
// _server.addListener(host + ':' + _listenPort);
|
||||
AbstractConnector lsnr;
|
||||
if (SystemVersion.isJava6() && !SystemVersion.isGNU()) {
|
||||
SelectChannelConnector slsnr = new SelectChannelConnector();
|
||||
slsnr.setUseDirectBuffers(false); // default true seems to be leaky
|
||||
lsnr = slsnr;
|
||||
} else {
|
||||
// Jetty 6 and NIO on Java 5 don't get along that well
|
||||
// Also: http://jira.codehaus.org/browse/JETTY-1238
|
||||
// "Do not use GCJ with Jetty, it will not work."
|
||||
// Actually it does if you don't use NIO
|
||||
lsnr = new SocketConnector();
|
||||
}
|
||||
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||
// number of acceptors, (default) number of selectors
|
||||
ServerConnector lsnr = new ServerConnector(_server, 1, 0,
|
||||
new HttpConnectionFactory(httpConfig));
|
||||
//lsnr.setUseDirectBuffers(false); // default true seems to be leaky
|
||||
lsnr.setHost(host);
|
||||
lsnr.setPort(lport);
|
||||
lsnr.setMaxIdleTime(90*1000); // default 10 sec
|
||||
lsnr.setIdleTimeout(90*1000); // default 10 sec
|
||||
lsnr.setName("ConsoleSocket"); // all with same name will use the same thread pool
|
||||
lsnr.setAcceptors(1); // default changed to 2 somewhere in Jetty 7?
|
||||
//_server.addConnector(lsnr);
|
||||
connectors.add(lsnr);
|
||||
boundAddresses++;
|
||||
@ -586,22 +594,19 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
} finally {
|
||||
if (testSock != null) try { testSock.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
// TODO if class not found use SslChannelConnector
|
||||
AbstractConnector ssll;
|
||||
if (SystemVersion.isJava6() && !SystemVersion.isGNU()) {
|
||||
SslSelectChannelConnector sssll = new SslSelectChannelConnector(sslFactory);
|
||||
sssll.setUseDirectBuffers(false); // default true seems to be leaky
|
||||
ssll = sssll;
|
||||
} else {
|
||||
// Jetty 6 and NIO on Java 5 don't get along that well
|
||||
SslSocketConnector sssll = new SslSocketConnector(sslFactory);
|
||||
ssll = sssll;
|
||||
}
|
||||
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||
httpConfig.setSecureScheme("https");
|
||||
httpConfig.setSecurePort(sslPort);
|
||||
httpConfig.addCustomizer(new SecureRequestCustomizer());
|
||||
// number of acceptors, (default) number of selectors
|
||||
ServerConnector ssll = new ServerConnector(_server, 1, 0,
|
||||
new SslConnectionFactory(sslFactory, "http/1.1"),
|
||||
new HttpConnectionFactory(httpConfig));
|
||||
//sssll.setUseDirectBuffers(false); // default true seems to be leaky
|
||||
ssll.setHost(host);
|
||||
ssll.setPort(sslPort);
|
||||
ssll.setMaxIdleTime(90*1000); // default 10 sec
|
||||
ssll.setIdleTimeout(90*1000); // default 10 sec
|
||||
ssll.setName("ConsoleSocket"); // all with same name will use the same thread pool
|
||||
ssll.setAcceptors(1); // default changed to 2 somewhere in Jetty 7?
|
||||
//_server.addConnector(ssll);
|
||||
connectors.add(ssll);
|
||||
boundAddresses++;
|
||||
@ -638,17 +643,25 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
File tmpdir = new SecureDirectory(workDir, ROUTERCONSOLE + "-" +
|
||||
(_listenPort != null ? _listenPort : _sslListenPort));
|
||||
tmpdir.mkdir();
|
||||
if (!SystemVersion.isWindows() && !SystemVersion.isMac() &&
|
||||
_context.getBaseDir().getAbsolutePath().equals("/usr/share/i2p")) {
|
||||
// We are using Tomcat 6, so the Debian patch doesn't apply.
|
||||
// Remove when we switch to Tomcat 8
|
||||
_context.logManager().getLog(Server.class).logAlways(net.i2p.util.Log.INFO, "Please ignore any InstanceManager warnings");
|
||||
}
|
||||
rootServletHandler = new ServletHandler();
|
||||
rootWebApp = new LocaleWebAppHandler(_context,
|
||||
"/", _webAppsDir + ROUTERCONSOLE + ".war",
|
||||
tmpdir, rootServletHandler);
|
||||
initialize(_context, (WebAppContext)(rootWebApp.getHandler()));
|
||||
try {
|
||||
// Not sure who is supposed to call this, but unless we do,
|
||||
// all the jsps die NPE, because JspFactory.getDefaultContext() returns null.
|
||||
// We probably have to do this because we don't bundle the Jetty annotations jar and scanner.
|
||||
// This is only with Tomcat 8, not with the Jetty (Eclipse) jsp impl.
|
||||
// Got a clue from this ancient post for Tomcat 6:
|
||||
// https://bz.apache.org/bugzilla/show_bug.cgi?id=39804
|
||||
// see also apps/jetty/build.xml
|
||||
Class.forName("org.eclipse.jetty.apache.jsp.JettyJasperInitializer");
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
System.err.println("Warning: JettyJasperInitializer not found");
|
||||
}
|
||||
WebAppContext wac = (WebAppContext)(rootWebApp.getHandler());
|
||||
initialize(_context, wac);
|
||||
WebAppStarter.setWebAppConfiguration(wac);
|
||||
chColl.addHandler(rootWebApp);
|
||||
|
||||
} catch (Exception ioe) {
|
||||
@ -709,7 +722,13 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
for (int i = 0; i < fileNames.length; i++) {
|
||||
String appName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war"));
|
||||
String enabled = props.getProperty(PREFIX + appName + ENABLED);
|
||||
if (! "false".equals(enabled)) {
|
||||
if (appName.equals("addressbook")) {
|
||||
// addressbook.war is now empty, thread is started by SusiDNS
|
||||
if (enabled != null) {
|
||||
props.remove(PREFIX + "addressbook" + ENABLED);
|
||||
rewrite = true;
|
||||
}
|
||||
} else if (! "false".equals(enabled)) {
|
||||
try {
|
||||
String path = new File(dir, fileNames[i]).getCanonicalPath();
|
||||
WebAppStarter.startWebApp(_context, chColl, appName, path);
|
||||
@ -945,7 +964,12 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
// see HashSessionManager javadoc
|
||||
synchronized(RouterConsoleRunner.class) {
|
||||
if (_jettyTimer == null) {
|
||||
_jettyTimer = new Timer("Console HashSessionScavenger", true);
|
||||
_jettyTimer = new ScheduledExecutorScheduler("Console HashSessionScavenger", true);
|
||||
try {
|
||||
_jettyTimer.start();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Warning: ScheduledExecutorScheduler start failed: " + e);
|
||||
}
|
||||
}
|
||||
context.getServletContext().setAttribute("org.eclipse.jetty.server.session.timer", _jettyTimer);
|
||||
}
|
||||
@ -1018,6 +1042,32 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops all but the root webapp (routerconsole.war)
|
||||
* In Jetty 9, stopping the server doesn't stop the non-root webapps,
|
||||
* so we must do it here.
|
||||
* There should be a better way to do this, possibly by
|
||||
* making the webapps "managed".
|
||||
* @since 0.9.30
|
||||
*/
|
||||
private void stopAllWebApps() {
|
||||
Properties props = webAppProperties(_context);
|
||||
Set<String> keys = props.stringPropertyNames();
|
||||
for (String name : keys) {
|
||||
if (name.startsWith(PREFIX) && name.endsWith(ENABLED)) {
|
||||
String app = name.substring(PREFIX.length(), name.lastIndexOf(ENABLED));
|
||||
if (ROUTERCONSOLE.equals(app))
|
||||
continue;
|
||||
if (WebAppStarter.isWebAppRunning(app)) {
|
||||
try {
|
||||
WebAppStarter.stopWebApp(app);
|
||||
} catch (Throwable t) { t.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class WarFilenameFilter implements FilenameFilter {
|
||||
private static final WarFilenameFilter _filter = new WarFilenameFilter();
|
||||
public static WarFilenameFilter instance() { return _filter; }
|
||||
|
@ -15,6 +15,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
|
||||
import org.apache.tomcat.SimpleInstanceManager;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
@ -97,7 +98,11 @@ public class WebAppConfiguration implements Configuration {
|
||||
// Ticket #957... don't know why...
|
||||
// Only really required if started manually, but we don't know that from here
|
||||
cp = "jetty-util.jar";
|
||||
} else ****/ if (pluginDir.exists()) {
|
||||
****/
|
||||
if (ctxPath.equals("/susidns")) {
|
||||
// Old installs don't have this in their wrapper.config classpath
|
||||
cp = "addressbook.jar";
|
||||
} else if (pluginDir.exists()) {
|
||||
File consoleDir = new File(pluginDir, "console");
|
||||
Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath());
|
||||
cp = props.getProperty(RouterConsoleRunner.PREFIX + appName + CLASSPATH);
|
||||
@ -173,11 +178,13 @@ public class WebAppConfiguration implements Configuration {
|
||||
}
|
||||
} else {
|
||||
// Java 9 - assume everything in lib/ is in the classpath
|
||||
// except addressbook.jar
|
||||
File libDir = new File(ctx.getBaseDir(), "lib");
|
||||
File[] files = libDir.listFiles();
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].getName().endsWith(".jar"))
|
||||
String name = files[i].getName();
|
||||
if (name.endsWith(".jar") && !name.equals("addressbook.jar"))
|
||||
rv.add(files[i].toURI());
|
||||
}
|
||||
}
|
||||
@ -191,6 +198,10 @@ public class WebAppConfiguration implements Configuration {
|
||||
/** @since Jetty 7 */
|
||||
public void configure(WebAppContext context) throws Exception {
|
||||
configureClassPath(context);
|
||||
// do we just need one, in the ContextHandlerCollection, or one for each?
|
||||
// http://stackoverflow.com/questions/17529936/issues-while-using-jetty-embedded-to-handle-jsp-jasperexception-unable-to-com
|
||||
// https://github.com/jetty-project/embedded-jetty-jsp/blob/master/src/main/java/org/eclipse/jetty/demo/Main.java
|
||||
context.getServletContext().setAttribute("org.apache.tomcat.InstanceManager", new SimpleInstanceManager());
|
||||
}
|
||||
|
||||
/** @since Jetty 7 */
|
||||
|
@ -109,17 +109,30 @@ public class WebAppStarter {
|
||||
|
||||
// this does the passwords...
|
||||
RouterConsoleRunner.initialize(ctx, wac);
|
||||
setWebAppConfiguration(wac);
|
||||
server.addHandler(wac);
|
||||
server.mapContexts();
|
||||
return wac;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Jetty 9
|
||||
*/
|
||||
static void setWebAppConfiguration(WebAppContext wac) {
|
||||
// see WebAppConfiguration for info
|
||||
String[] classNames = wac.getConfigurationClasses();
|
||||
// In Jetty 9, it doesn't set the defaults if we've already added one, but the
|
||||
// defaults aren't set yet when we call the above. So we have to get the defaults.
|
||||
// Without the default configuration, the web.xml isn't read, and the webapp
|
||||
// won't respond to any requests, even though it appears to be running.
|
||||
// See WebAppContext.loadConfigurations() in source
|
||||
if (classNames.length == 0)
|
||||
classNames = wac.getDefaultConfigurationClasses();
|
||||
String[] newClassNames = new String[classNames.length + 1];
|
||||
for (int j = 0; j < classNames.length; j++)
|
||||
newClassNames[j] = classNames[j];
|
||||
newClassNames[classNames.length] = WebAppConfiguration.class.getName();
|
||||
wac.setConfigurationClasses(newClassNames);
|
||||
server.addHandler(wac);
|
||||
server.mapContexts();
|
||||
return wac;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user