Console: Use registered host/port for eepsite link (ticket #1604)

Jetty starter: Register host/port when started
PortMapper: Add hostname support
This commit is contained in:
zzz
2015-06-25 17:00:52 +00:00
parent 25268e7cb2
commit dd47389ad1
6 changed files with 89 additions and 16 deletions

View File

@ -167,13 +167,22 @@ public class HomeHelper extends HelperBase {
ctx.router().saveConfig(prop, buf.toString());
}
private static String renderApps(Collection<App> apps) {
private String renderApps(Collection<App> apps) {
String website = _("Website");
StringBuilder buf = new StringBuilder(1024);
buf.append("<div class=\"appgroup\">");
for (App app : apps) {
String url;
if (app.name.equals(website) && app.url.equals("http://127.0.0.1:7658/")) {
// fixup eepsite link
url = "http://" + _context.portMapper().getHost(PortMapper.SVC_EEPSITE, "127.0.0.1") +
':' + _context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658) + '/';
} else {
url = app.url;
}
buf.append("<div class=\"app\">" +
"<div class=\"appimg\">" +
"<a href=\"").append(app.url).append("\">" +
"<a href=\"").append(url).append("\">" +
"<img class=\"");
// toopie is 54x68, not 16x16, needs special alignment and sizing
if (app.icon.endsWith("/itoopie_sm.png"))
@ -184,7 +193,7 @@ public class HomeHelper extends HelperBase {
"</div>" +
"<table class=\"app\"><tr class=\"app\"><td class=\"app\">" +
"<div class=\"applabel\">" +
"<a href=\"").append(app.url).append("\" title=\"").append(app.desc).append("\">").append(app.name).append("</a>" +
"<a href=\"").append(url).append("\" title=\"").append(app.desc).append("\">").append(app.name).append("</a>" +
"</div>" +
"</td></tr></table>" +
"</div>\n");

View File

@ -11,6 +11,7 @@ import java.util.Map;
import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext;
import net.i2p.util.PortMapper;
/**
* Refactored from summarynoframe.jsp to save ~100KB
@ -146,7 +147,11 @@ public class SummaryBarRenderer {
.append(nbsp(_("Torrents")))
.append("</a>\n" +
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"")
"<a href=\"http://")
.append(_context.portMapper().getHost(PortMapper.SVC_EEPSITE, "127.0.0.1"))
.append(':')
.append(_context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658))
.append("/\" target=\"_blank\" title=\"")
.append(_("Local web server"))
.append("\">")
.append(nbsp(_("Website")))