PortMapper: Fix URL generation for IPv6 hosts

Console: Remove i2pwiki.i2p (ticket #2626)
This commit is contained in:
zzz
2019-10-01 16:09:17 +00:00
parent 830e08065b
commit 18ed1a6bb3
5 changed files with 67 additions and 35 deletions

View File

@ -63,7 +63,7 @@ public class HomeHelper extends HelperBase {
_x("I2P Forum") + S + _x("Community forum") + S + "http://i2pforum.i2p/" + S + I + "group.png" + S +
//"git.repo.i2p" + S + _x("A public anonymous Git hosting site - supports pulling via Git and HTTP and pushing via SSH") + S + "http://git.repo.i2p/" + S + I + "git-logo.png" + S +
//"hiddengate [ru]" + S + _x("Russian I2P-related wiki") + S + "http://hiddengate.i2p/" + S + I + "hglogo32.png" + S +
_x("I2P Wiki") + S + _x("Anonymous wiki - share the knowledge") + S + "http://i2pwiki.i2p/" + S + I + "i2pwiki_logo.png" + S +
//_x("I2P Wiki") + S + _x("Anonymous wiki - share the knowledge") + S + "http://i2pwiki.i2p/" + S + I + "i2pwiki_logo.png" + S +
//"Ident " + _x("Microblog") + S + _x("Your premier microblogging service on I2P") + S + "http://id3nt.i2p/" + S + I + "ident_icon_blue.png" + S +
//_x("Javadocs") + S + _x("Technical documentation") + S + "http://i2p-javadocs.i2p/" + S + I + "education.png" + S +
//"jisko.i2p" + S + _x("Simple and fast microblogging website") + S + "http://jisko.i2p/" + S + I + "jisko_console_icon.png" + S +
@ -196,18 +196,10 @@ public class HomeHelper extends HelperBase {
for (App app : apps) {
String url;
if (app.name.equals(website) && app.url.equals("http://127.0.0.1:7658/")) {
int port = pm.getPort(PortMapper.SVC_EEPSITE);
int sslPort = pm.getPort(PortMapper.SVC_HTTPS_EEPSITE);
if (port <= 0 && sslPort <= 0)
continue;
// fixup eepsite link
if (sslPort > 0) {
url = "https://" + pm.getActualHost(PortMapper.SVC_HTTPS_EEPSITE, "127.0.0.1") +
':' + sslPort + '/';
} else {
url = "http://" + pm.getActualHost(PortMapper.SVC_EEPSITE, "127.0.0.1") +
':' + port + '/';
}
url = SummaryBarRenderer.getEepsiteURL(pm);
if (url == null)
continue;
} else {
url = app.url;
// check for disabled webapps and other things

View File

@ -231,26 +231,15 @@ class SummaryBarRenderer {
.append("</a>\n");
}
int port = pm.getPort(PortMapper.SVC_EEPSITE);
int sslPort = pm.getPort(PortMapper.SVC_HTTPS_EEPSITE);
if (sslPort > 0 || port > 0) {
String svc;
if (sslPort > 0) {
buf.append("<a href=\"https://");
svc = PortMapper.SVC_HTTPS_EEPSITE;
port = sslPort;
} else {
buf.append("<a href=\"http://");
svc = PortMapper.SVC_EEPSITE;
}
buf.append(pm.getActualHost(svc, "127.0.0.1"))
.append(':')
.append(port)
.append("/\" target=\"_blank\" title=\"")
.append(_t("Local web server"))
.append("\">")
.append(nbsp(_t("Web Server")))
.append("</a>\n");
String url = getEepsiteURL(pm);
if (url != null) {
buf.append("<a href=\"")
.append(url)
.append("\" target=\"_blank\" title=\"")
.append(_t("Local web server"))
.append("\">")
.append(nbsp(_t("Web Server")))
.append("</a>\n");
}
buf.append(NavHelper.getClientAppLinks(_context))
@ -259,6 +248,37 @@ class SummaryBarRenderer {
return buf.toString();
}
/**
* @return null if none
* @since 0.9.43 split out from above, used by HomeHelper, fixed for IPv6
*/
static String getEepsiteURL(PortMapper pm) {
int port = pm.getPort(PortMapper.SVC_EEPSITE);
int sslPort = pm.getPort(PortMapper.SVC_HTTPS_EEPSITE);
if (port <= 0 && sslPort <= 0)
return null;
String svc;
StringBuilder buf = new StringBuilder(32);
if (sslPort > 0) {
buf.append("https://");
svc = PortMapper.SVC_HTTPS_EEPSITE;
port = sslPort;
} else {
buf.append("http://");
svc = PortMapper.SVC_EEPSITE;
}
String host = pm.getActualHost(svc, "127.0.0.1");
if (host.contains(":"))
buf.append('[');
buf.append(host);
if (host.contains(":"))
buf.append(']');
buf.append(':')
.append(port)
.append('/');
return buf.toString();
}
public String renderI2PInternalsHTML() {
StringBuilder buf = new StringBuilder(512);
buf.append("<h3><a href=\"/config\" target=\"_top\" title=\"")