add basic no-webapp handler
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.router.web;
|
package net.i2p.router.web;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -20,6 +21,7 @@ import org.mortbay.http.SecurityConstraint;
|
|||||||
import org.mortbay.http.handler.SecurityHandler;
|
import org.mortbay.http.handler.SecurityHandler;
|
||||||
import org.mortbay.jetty.Server;
|
import org.mortbay.jetty.Server;
|
||||||
import org.mortbay.jetty.servlet.WebApplicationContext;
|
import org.mortbay.jetty.servlet.WebApplicationContext;
|
||||||
|
import org.mortbay.jetty.servlet.WebApplicationHandler;
|
||||||
|
|
||||||
public class RouterConsoleRunner {
|
public class RouterConsoleRunner {
|
||||||
private Server _server;
|
private Server _server;
|
||||||
@ -87,6 +89,8 @@ public class RouterConsoleRunner {
|
|||||||
if (!_webAppsDir.endsWith("/"))
|
if (!_webAppsDir.endsWith("/"))
|
||||||
_webAppsDir += '/';
|
_webAppsDir += '/';
|
||||||
|
|
||||||
|
List<String> notStarted = new ArrayList();
|
||||||
|
WebApplicationHandler baseHandler = null;
|
||||||
try {
|
try {
|
||||||
StringTokenizer tok = new StringTokenizer(_listenHost, " ,");
|
StringTokenizer tok = new StringTokenizer(_listenHost, " ,");
|
||||||
int boundAddresses = 0;
|
int boundAddresses = 0;
|
||||||
@ -111,7 +115,8 @@ public class RouterConsoleRunner {
|
|||||||
File tmpdir = new File(workDir, ROUTERCONSOLE + "-" + _listenPort);
|
File tmpdir = new File(workDir, ROUTERCONSOLE + "-" + _listenPort);
|
||||||
tmpdir.mkdir();
|
tmpdir.mkdir();
|
||||||
wac.setTempDirectory(tmpdir);
|
wac.setTempDirectory(tmpdir);
|
||||||
wac.addHandler(0, new LocaleWebAppHandler(I2PAppContext.getGlobalContext()));
|
baseHandler = new LocaleWebAppHandler(I2PAppContext.getGlobalContext());
|
||||||
|
wac.addHandler(0, baseHandler);
|
||||||
initialize(wac);
|
initialize(wac);
|
||||||
File dir = new File(_webAppsDir);
|
File dir = new File(_webAppsDir);
|
||||||
String fileNames[] = dir.list(WarFilenameFilter.instance());
|
String fileNames[] = dir.list(WarFilenameFilter.instance());
|
||||||
@ -132,6 +137,8 @@ public class RouterConsoleRunner {
|
|||||||
props.setProperty(PREFIX + appName + ENABLED, "true");
|
props.setProperty(PREFIX + appName + ENABLED, "true");
|
||||||
rewrite = true;
|
rewrite = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
notStarted.add(appName);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
System.err.println("Error resolving '" + fileNames[i] + "' in '" + dir);
|
System.err.println("Error resolving '" + fileNames[i] + "' in '" + dir);
|
||||||
@ -154,6 +161,19 @@ public class RouterConsoleRunner {
|
|||||||
"\"::1,\" in the \"clientApp.0.args\" line of the clients.config file.\n" +
|
"\"::1,\" in the \"clientApp.0.args\" line of the clients.config file.\n" +
|
||||||
"Exception: " + me);
|
"Exception: " + me);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (baseHandler != null) {
|
||||||
|
// map each not-started webapp to the error page
|
||||||
|
for (int i = 0; i < notStarted.size(); i++) {
|
||||||
|
try {
|
||||||
|
baseHandler.mapPathToServlet('/' + notStarted.get(i) + "/*",
|
||||||
|
"net.i2p.router.web.jsp.nowebapp_jsp");
|
||||||
|
} catch (Throwable me) {
|
||||||
|
System.err.println(me);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SysTray tray = SysTray.getInstance();
|
SysTray tray = SysTray.getInstance();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
16
apps/routerconsole/jsp/nowebapp.jsp
Normal file
16
apps/routerconsole/jsp/nowebapp.jsp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<%@page contentType="text/html"%>
|
||||||
|
<%@page pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<%
|
||||||
|
response.setStatus(404, "Not Found");
|
||||||
|
%>
|
||||||
|
<html><head>
|
||||||
|
<%@include file="css.jsi" %>
|
||||||
|
<%=intl.title("WebApp Not Found")%>
|
||||||
|
</head><body>
|
||||||
|
<%@include file="summary.jsi" %>
|
||||||
|
<h1><%=intl._("Web Application Not Running")%></h1>
|
||||||
|
<div class="sorry" id="warning">
|
||||||
|
<%=intl._("The requested web application is not running.")%>
|
||||||
|
<%=intl._("Please visit the <a href=\"/configclients.jsp#webapp\">config clients page</a> to start it.")%>
|
||||||
|
</div></body></html>
|
Reference in New Issue
Block a user