From 21c7a341fb2d9cdde74a8b2ad2e413e02dc3c310 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Thu, 28 Feb 2019 16:07:58 +0000 Subject: [PATCH] Console: Change fallback client names to use b32 instead of truncated b64. Anchors remain b64. --- .../web/helpers/ConfigTunnelsHelper.java | 7 +++--- .../i2p/router/web/helpers/SummaryHelper.java | 2 +- .../router/web/helpers/TunnelRenderer.java | 23 ++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigTunnelsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigTunnelsHelper.java index 1611490da9..8ccf2aa4ef 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigTunnelsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigTunnelsHelper.java @@ -46,10 +46,11 @@ public class ConfigTunnelsHelper extends HelperBase { } String name = in.getDestinationNickname(); - if (name == null) + if (name == null) { name = out.getDestinationNickname(); - if (name == null) - name = dest.calculateHash().toBase64().substring(0,6); + if (name == null) + name = dest.calculateHash().toBase32(); + } String prefix = dest.calculateHash().toBase64().substring(0,4); renderForm(buf, cur, prefix, _t("Client tunnels for {0}", DataHelper.escapeHTML(_t(name))), in, out); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java index a9f6e2e4f8..e2dec5cd7a 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java @@ -642,7 +642,7 @@ public class SummaryHelper extends HelperBase { TunnelPoolSettings out = _context.tunnelManager().getOutboundSettings(d.calculateHash()); name = (out != null ? out.getDestinationNickname() : null); if (name == null) - name = d.calculateHash().toBase64().substring(0,6); + name = d.toBase32(); else name = _t(name); } else { diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/TunnelRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/TunnelRenderer.java index 77f3f365a0..9ec947c3c0 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/TunnelRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/TunnelRenderer.java @@ -67,13 +67,19 @@ class TunnelRenderer { String name = (in != null) ? in.getSettings().getDestinationNickname() : null; if ( (name == null) && (outPool != null) ) name = outPool.getSettings().getDestinationNickname(); - if (name == null) - name = client.toBase64().substring(0,4); - out.write("<h3 class=\"tabletitle\" id=\"" + client.toBase64().substring(0,4) - + "\" >" + _t("Client tunnels for") + ' ' + DataHelper.escapeHTML(_t(name))); + String b64 = client.toBase64().substring(0, 4); + String dname; + if (name == null) { + name = b64; + dname = client.toBase32(); + } else { + dname = DataHelper.escapeHTML(_t(name)); + } + out.write("<h3 class=\"tabletitle\" id=\"" + b64 + + "\" >" + _t("Client tunnels for") + ' ' + dname); if (isLocal) { // links are set to float:right in CSS so they will be displayed in reverse order - out.write(" <a href=\"/configtunnels#" + client.toBase64().substring(0,4) +"\" title=\"" + _t("Configure tunnels for session") + "\">[" + _t("configure") + "]</a>"); + out.write(" <a href=\"/configtunnels#" + b64 + "\" title=\"" + _t("Configure tunnels for session") + "\">[" + _t("configure") + "]</a>"); writeGraphLinks(out, in, outPool); out.write("</h3>\n"); } else { @@ -87,12 +93,13 @@ class TunnelRenderer { TunnelPool ain = clientInboundPools.get(a); if (ain != null) { String aname = ain.getSettings().getDestinationNickname(); + String ab64 = a.toBase64().substring(0, 4); if (aname == null) - aname = a.toBase64().substring(0,4); - out.write("<h3 class=\"tabletitle\" id=\"" + a.toBase64().substring(0,4) + aname = ab64; + out.write("<h3 class=\"tabletitle\" id=\"" + ab64 + "\" >" + _t("Client tunnels for") + ' ' + DataHelper.escapeHTML(_t(aname))); if (isLocal) - out.write(" <a href=\"/configtunnels#" + client.toBase64().substring(0,4) +"\" title=\"" + _t("Configure tunnels for session") + "\">[" + _t("configure") + "]</a></h3>\n"); + out.write(" <a href=\"/configtunnels#" + b64 + "\" title=\"" + _t("Configure tunnels for session") + "\">[" + _t("configure") + "]</a></h3>\n"); else out.write(" (" + _t("dead") + ")</h3>\n"); } -- GitLab