Util: Consolidate console URL generation in PortMapper

This commit is contained in:
zzz
2018-01-18 13:25:21 +00:00
parent 109ac5b61c
commit ae505995ac
7 changed files with 35 additions and 33 deletions

View File

@ -219,6 +219,13 @@ public class ConfigServiceHandler extends FormHandler {
(sdtg == null && (SystemVersion.isWindows() || SystemVersion.isMac()));
}
/**
* @since 0.9.33
*/
public String getConsoleURL() {
return _context.portMapper().getConsoleURL();
}
@Override
protected void processForm() {
if (_action == null) return;
@ -348,9 +355,9 @@ public class ConfigServiceHandler extends FormHandler {
}
// releases <= 0.6.5 deleted the entry completely
if (shouldLaunchBrowser && !found) {
int port = _context.portMapper().getPort(PortMapper.SVC_CONSOLE, RouterConsoleRunner.DEFAULT_LISTEN_PORT);
String url = _context.portMapper().getConsoleURL();
ClientAppConfig ca = new ClientAppConfig(UrlLauncher.class.getName(), "consoleBrowser",
"http://127.0.0.1:" + port + '/', 5, false);
url, 5, false);
clients.add(ca);
}
ClientAppConfig.writeClientAppConfig(_context, clients);

View File

@ -190,7 +190,7 @@ public class HomeHelper extends HelperBase {
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") +
url = "http://" + _context.portMapper().getActualHost(PortMapper.SVC_EEPSITE, "127.0.0.1") +
':' + _context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658) + '/';
} else {
url = app.url;

View File

@ -226,7 +226,7 @@ class SummaryBarRenderer {
.append("</a>\n" +
"<a href=\"http://")
.append(_context.portMapper().getHost(PortMapper.SVC_EEPSITE, "127.0.0.1"))
.append(_context.portMapper().getActualHost(PortMapper.SVC_EEPSITE, "127.0.0.1"))
.append(':')
.append(_context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658))
.append("/\" target=\"_blank\" title=\"")