diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java index d4a7553f4..83437d446 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java @@ -541,7 +541,7 @@ public class PluginStarter implements Runnable { Iterator wars = pluginWars.get(appName).iterator(); while (wars.hasNext()) { String warName = wars.next(); - WebAppStarter.stopWebApp(warName); + WebAppStarter.stopWebApp(ctx, warName); } pluginWars.get(appName).clear(); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java index 37f80e9f4..75d91103b 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java @@ -1115,7 +1115,7 @@ public class RouterConsoleRunner implements RouterApp { continue; if (WebAppStarter.isWebAppRunning(app)) { try { - WebAppStarter.stopWebApp(app); + WebAppStarter.stopWebApp(_context, app); } catch (Throwable t) { t.printStackTrace(); } } } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java index f4042b253..cb7305206 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java @@ -8,6 +8,7 @@ import java.util.concurrent.ConcurrentHashMap; import net.i2p.router.RouterContext; import net.i2p.util.FileUtil; +import net.i2p.util.PortMapper; import net.i2p.util.SecureDirectory; import org.eclipse.jetty.server.Handler; @@ -50,6 +51,7 @@ public class WebAppStarter { /** * Adds and starts. * Prior to 0.9.28, was not guaranteed to throw on failure. + * Not for routerconsole.war, it's started in RouterConsoleRunner. * * @throws Exception just about anything, caller would be wise to catch Throwable * @since public since 0.9.33, was package private @@ -64,6 +66,10 @@ public class WebAppStarter { // and the caller will know it failed wac.setThrowUnavailableOnStartupException(true); wac.start(); + // Doesn't have to be right, just for presence indication + int port = ctx.portMapper().getPort(PortMapper.SVC_CONSOLE, PortMapper.DEFAULT_CONSOLE_PORT); + String host = ctx.portMapper().getActualHost(PortMapper.SVC_CONSOLE, "127.0.0.1"); + ctx.portMapper().register(appName, host, port); } /** @@ -77,7 +83,7 @@ public class WebAppStarter { // Jetty will happily load one context on top of another without stopping // the first one, so we remove any previous one here try { - stopWebApp(appName); + stopWebApp(ctx, appName); } catch (Throwable t) {} // To avoid ZipErrors from JarURLConnetion caching, @@ -141,10 +147,11 @@ public class WebAppStarter { * Throws just about anything, caller would be wise to catch Throwable * @since public since 0.9.33, was package private */ - public static void stopWebApp(String appName) { + public static void stopWebApp(RouterContext ctx, String appName) { ContextHandler wac = getWebApp(appName); if (wac == null) return; + ctx.portMapper().unregister(appName); try { // not graceful is default in Jetty 6? wac.stop(); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHandler.java index da84318d9..f469b247b 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHandler.java @@ -185,7 +185,7 @@ public class ConfigClientsHandler extends FormHandler { _log.error("Error stopping plugin " + app, e); } } else { - WebAppStarter.stopWebApp(app); + WebAppStarter.stopWebApp(_context, app); addFormNotice(_t("Stopped webapp {0}", app)); } } diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index 99249dfa3..193318826 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -45,6 +45,36 @@ public class PortMapper { public static final String SVC_HTTP_I2PCONTROL = "http_i2pcontrol"; /** @since 0.9.34 */ public static final String SVC_HTTPS_I2PCONTROL = "https_i2pcontrol"; + /** + * To indicate presence, alternative to WebAppStarter.isWebappRunning(). + * For actual base URL, use getConsoleURL() + * @since 0.9.34 + */ + public static final String SVC_I2PSNARK = "i2psnark"; + /** + * To indicate presence, alternative to WebAppStarter.isWebappRunning(). + * For actual base URL, use getConsoleURL() + * @since 0.9.34 + */ + public static final String SVC_I2PTUNNEL = "i2ptunnel"; + /** + * To indicate presence, alternative to WebAppStarter.isWebappRunning(). + * For actual base URL, use getConsoleURL() + * @since 0.9.34 + */ + public static final String SVC_IMAGEGEN = "imagegen"; + /** + * To indicate presence, alternative to WebAppStarter.isWebappRunning(). + * For actual base URL, use getConsoleURL() + * @since 0.9.34 + */ + public static final String SVC_SUSIDNS = "susidns"; + /** + * To indicate presence, alternative to WebAppStarter.isWebappRunning(). + * For actual base URL, use getConsoleURL() + * @since 0.9.34 + */ + public static final String SVC_SUSIMAIL = "susimail"; /** @since 0.9.34 */ public static final int DEFAULT_CONSOLE_PORT = 7657;