forked from I2P_Developers/i2p.i2p
Migrate webapp detection calls to PortMapper.isRegistered()
This commit is contained in:
@ -175,7 +175,7 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
int proxyPort = proxyPort(_context);
|
||||
if (shouldProxy && proxyPort == ConfigUpdateHandler.DEFAULT_PROXY_PORT_INT &&
|
||||
proxyHost.equals(ConfigUpdateHandler.DEFAULT_PROXY_HOST) &&
|
||||
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) < 0) {
|
||||
!_context.portMapper().isRegistered(PortMapper.SVC_HTTP_PROXY)) {
|
||||
addFormError(_t("HTTP client proxy tunnel must be running"));
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public class PluginStarter implements Runnable {
|
||||
int proxyPort = ConfigUpdateHandler.proxyPort(ctx);
|
||||
if (proxyPort == ConfigUpdateHandler.DEFAULT_PROXY_PORT_INT &&
|
||||
proxyHost.equals(ConfigUpdateHandler.DEFAULT_PROXY_HOST) &&
|
||||
ctx.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) < 0) {
|
||||
!ctx.portMapper().isRegistered(PortMapper.SVC_HTTP_PROXY)) {
|
||||
mgr.notifyComplete(null, Messages.getString("Plugin update check failed", ctx) +
|
||||
" - " +
|
||||
Messages.getString("HTTP client proxy tunnel must be running", ctx));
|
||||
|
@ -53,6 +53,8 @@ public class WebAppStarter {
|
||||
* Prior to 0.9.28, was not guaranteed to throw on failure.
|
||||
* Not for routerconsole.war, it's started in RouterConsoleRunner.
|
||||
*
|
||||
* As of 0.9.34, the appName will be registered with the PortMapper.
|
||||
*
|
||||
* @throws Exception just about anything, caller would be wise to catch Throwable
|
||||
* @since public since 0.9.33, was package private
|
||||
*/
|
||||
@ -165,7 +167,12 @@ public class WebAppStarter {
|
||||
} catch (IllegalStateException ise) {}
|
||||
}
|
||||
|
||||
/** @since public since 0.9.33; was package private */
|
||||
/**
|
||||
* As of 0.9.34, the appName will be registered with the PortMapper,
|
||||
* and PortMapper.isRegistered() will be more efficient than this.
|
||||
*
|
||||
* @since public since 0.9.33; was package private
|
||||
*/
|
||||
public static boolean isWebAppRunning(String appName) {
|
||||
ContextHandler wac = getWebApp(appName);
|
||||
if (wac == null)
|
||||
|
@ -577,7 +577,7 @@ public class ConfigClientsHandler extends FormHandler {
|
||||
boolean rv = !
|
||||
(proxyPort == ConfigUpdateHandler.DEFAULT_PROXY_PORT_INT &&
|
||||
proxyHost.equals(ConfigUpdateHandler.DEFAULT_PROXY_HOST) &&
|
||||
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) < 0);
|
||||
!_context.portMapper().isRegistered(PortMapper.SVC_HTTP_PROXY));
|
||||
if (!rv)
|
||||
addFormError(_t("HTTP client proxy tunnel must be running"));
|
||||
return rv;
|
||||
|
@ -208,13 +208,13 @@ public class HomeHelper extends HelperBase {
|
||||
url = app.url;
|
||||
// check for disabled webapps and other things
|
||||
if (url.equals("/dns")) {
|
||||
if (pm.getPort("susidns") <= 0)
|
||||
if (!pm.isRegistered("susidns"))
|
||||
continue;
|
||||
} else if (url.equals("/webmail")) {
|
||||
if (pm.getPort("susimail") <= 0)
|
||||
if (!pm.isRegistered("susimail"))
|
||||
continue;
|
||||
} else if (url.equals("/torrents")) {
|
||||
if (pm.getPort("i2psnark") <= 0)
|
||||
if (!pm.isRegistered("i2psnark"))
|
||||
continue;
|
||||
} else if (url.equals("/configplugins")) {
|
||||
if (!PluginStarter.pluginsEnabled(_context))
|
||||
|
@ -290,7 +290,7 @@ class NetDbRenderer {
|
||||
medianCount = rapCount / 2;
|
||||
}
|
||||
|
||||
boolean linkSusi = WebAppStarter.isWebAppRunning("susidns");
|
||||
boolean linkSusi = _context.portMapper().isRegistered("susidns");
|
||||
long now = _context.clock().now();
|
||||
buf.append("<div class=\"leasesets_container\">");
|
||||
for (LeaseSet ls : leases) {
|
||||
|
@ -214,7 +214,7 @@ class SummaryBarRenderer {
|
||||
"<hr class=\"b\"><table id=\"sb_services\"><tr><td>");
|
||||
|
||||
PortMapper pm = _context.portMapper();
|
||||
if (pm.getPort(PortMapper.SVC_SUSIMAIL) > 0) {
|
||||
if (pm.isRegistered(PortMapper.SVC_SUSIMAIL)) {
|
||||
buf.append("<a href=\"/webmail\" target=\"_top\" title=\"")
|
||||
.append(_t("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
@ -222,7 +222,7 @@ class SummaryBarRenderer {
|
||||
.append("</a>\n");
|
||||
}
|
||||
|
||||
if (pm.getPort(PortMapper.SVC_I2PSNARK) > 0) {
|
||||
if (pm.isRegistered(PortMapper.SVC_I2PSNARK)) {
|
||||
buf.append("<a href=\"/torrents\" target=\"_top\" title=\"")
|
||||
.append(_t("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
@ -269,7 +269,7 @@ class SummaryBarRenderer {
|
||||
"<table id=\"sb_internals\"><tr><td>\n");
|
||||
|
||||
PortMapper pm = _context.portMapper();
|
||||
if (pm.getPort(PortMapper.SVC_SUSIDNS) > 0) {
|
||||
if (pm.isRegistered(PortMapper.SVC_SUSIDNS)) {
|
||||
buf.append("<a href=\"/dns\" target=\"_top\" title=\"")
|
||||
.append(_t("Manage your I2P hosts file here (I2P domain name resolution)"))
|
||||
.append("\">")
|
||||
@ -291,7 +291,7 @@ class SummaryBarRenderer {
|
||||
.append(nbsp(_t("Help")))
|
||||
.append("</a>\n");
|
||||
|
||||
if (pm.getPort(PortMapper.SVC_I2PTUNNEL) > 0) {
|
||||
if (pm.isRegistered(PortMapper.SVC_I2PTUNNEL)) {
|
||||
buf.append("<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"")
|
||||
.append(_t("Local Tunnels"))
|
||||
.append("\">")
|
||||
|
@ -558,7 +558,7 @@ public class SummaryHelper extends HelperBase {
|
||||
List<Destination> clients = new ArrayList<Destination>(_context.clientManager().listClients());
|
||||
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
boolean link = WebAppStarter.isWebAppRunning("i2ptunnel");
|
||||
boolean link = _context.portMapper().isRegistered("i2ptunnel");
|
||||
buf.append("<h3>");
|
||||
if (link) {
|
||||
buf.append("<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"")
|
||||
@ -898,7 +898,7 @@ public class SummaryHelper extends HelperBase {
|
||||
if ((avail || unsignedAvail || devSU3Avail) &&
|
||||
!NewsHelper.isUpdateInProgress() &&
|
||||
!_context.router().gracefulShutdownInProgress() &&
|
||||
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) > 0 && // assume using proxy for now
|
||||
_context.portMapper().isRegistered(PortMapper.SVC_HTTP_PROXY) && // assume using proxy for now
|
||||
getAction() == null &&
|
||||
getUpdateNonce() == null) {
|
||||
if (needSpace)
|
||||
|
@ -814,7 +814,7 @@ class SybilRenderer {
|
||||
buf.append("<a title=\"View extended router info\" class=\"viewfullentry\" href=\"netdb?r=")
|
||||
.append(hash.substring(0, 6)).append("\" >[").append(_t("Full entry")).append("]</a></th><th>");
|
||||
}
|
||||
if (_context.portMapper().getPort("imagegen") > 0)
|
||||
if (_context.portMapper().isRegistered("imagegen"))
|
||||
buf.append("<img src=\"/imagegen/id?s=32&c=" + hash.replace("=", "%3d") + "\" height=\"32\" width=\"32\"> ");
|
||||
buf.append("</th></tr>\n<tr><td class=\"sybilinfo_params\" colspan=\"3\"><div class=\"sybilinfo_container\">");
|
||||
if (us != null) {
|
||||
|
Reference in New Issue
Block a user