Console: Change fallback client names to use b32

instead of truncated b64. Anchors remain b64.
This commit is contained in:
zzz
2019-02-28 16:07:58 +00:00
parent 302adc2d16
commit 21c7a341fb
3 changed files with 20 additions and 12 deletions

View File

@ -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);
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);

View File

@ -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 {

View File

@ -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");
}