forked from I2P_Developers/i2p.i2p
Console: Hide Hidden Services Manager link until TCG is running
Use PortMapper constants to check registration Reported by lbt
This commit is contained in:
@ -315,17 +315,22 @@ public class HomeHelper extends HelperBase {
|
||||
url = app.url;
|
||||
// check for disabled webapps and other things
|
||||
if (url.equals("/dns")) {
|
||||
if (!pm.isRegistered("susidns"))
|
||||
if (!pm.isRegistered(PortMapper.SVC_SUSIDNS))
|
||||
continue;
|
||||
} else if (url.equals("/webmail")) {
|
||||
if (!pm.isRegistered("susimail"))
|
||||
if (!pm.isRegistered(PortMapper.SVC_SUSIMAIL))
|
||||
continue;
|
||||
} else if (url.equals("/torrents")) {
|
||||
if (!pm.isRegistered("i2psnark"))
|
||||
if (!pm.isRegistered(PortMapper.SVC_I2PSNARK))
|
||||
continue;
|
||||
} else if (url.equals("/i2ptunnelmgr")) {
|
||||
if (!pm.isRegistered("i2ptunnel"))
|
||||
if (!pm.isRegistered(PortMapper.SVC_I2PTUNNEL))
|
||||
continue;
|
||||
// need both webapp and TCG, but we aren't refreshing
|
||||
// the icons, so let's not do this
|
||||
//ClientAppManager cmgr = _context.clientAppManager();
|
||||
//if (cmgr != null && cmgr.getRegisteredApp("i2ptunnel") == null)
|
||||
// continue;
|
||||
} else if (url.equals("/configplugins")) {
|
||||
if (!PluginStarter.pluginsEnabled(_context))
|
||||
continue;
|
||||
|
@ -354,7 +354,7 @@ class SummaryBarRenderer {
|
||||
svcs.put(tx, rbuf.toString());
|
||||
}
|
||||
|
||||
if (pm.isRegistered(PortMapper.SVC_I2PTUNNEL)) {
|
||||
if (_helper.isI2PTunnelRunning()) {
|
||||
String tx = _t("Hidden Services Manager");
|
||||
rbuf.setLength(0);
|
||||
rbuf.append("<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"")
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.i2p.app.ClientAppManager;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.Hash;
|
||||
@ -565,6 +566,18 @@ public class SummaryHelper extends HelperBase {
|
||||
return DataHelper.formatSize2Decimal(sent) + 'B';
|
||||
}
|
||||
|
||||
/**
|
||||
* Are both the webapp and TCG running?
|
||||
*
|
||||
* @since 0.9.58
|
||||
*/
|
||||
public boolean isI2PTunnelRunning() {
|
||||
if (!_context.portMapper().isRegistered(PortMapper.SVC_I2PTUNNEL))
|
||||
return false;
|
||||
ClientAppManager cmgr = _context.clientAppManager();
|
||||
return cmgr != null && cmgr.getRegisteredApp("i2ptunnel") != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client destinations connected locally.
|
||||
*
|
||||
@ -575,7 +588,7 @@ public class SummaryHelper extends HelperBase {
|
||||
List<Destination> clients = new ArrayList<Destination>(_context.clientManager().listClients());
|
||||
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
boolean link = _context.portMapper().isRegistered("i2ptunnel");
|
||||
boolean link = isI2PTunnelRunning();
|
||||
buf.append("<h3>");
|
||||
if (link) {
|
||||
buf.append("<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"")
|
||||
|
@ -60,6 +60,10 @@ public class PortMapper {
|
||||
/**
|
||||
* To indicate presence, alternative to WebAppStarter.isWebappRunning().
|
||||
* For actual base URL, use getConsoleURL()
|
||||
*
|
||||
* Note: This is only the webapp. Also requires TCG running to be useful.
|
||||
* The webapp does not start TCG.
|
||||
*
|
||||
* @since 0.9.34
|
||||
*/
|
||||
public static final String SVC_I2PTUNNEL = "i2ptunnel";
|
||||
|
Reference in New Issue
Block a user