Console: Add built-by to /logs (ticket #2204)

This commit is contained in:
zzz
2018-04-14 13:12:40 +00:00
parent 98aafee53a
commit 941db3aeeb
3 changed files with 30 additions and 3 deletions

View File

@ -193,7 +193,11 @@ public class FileDumpHelper extends HelperBase {
}
}
private static Attributes attributes(File f) {
/**
* @return null if not found
* @since pkg private since 0.9.35 for LogsHelper
*/
static Attributes attributes(File f) {
InputStream in = null;
try {
in = (new URL("jar:file:" + f.getAbsolutePath() + "!/META-INF/MANIFEST.MF")).openStream();
@ -207,7 +211,12 @@ public class FileDumpHelper extends HelperBase {
}
}
private static String getAtt(Attributes atts, String s) {
/**
* @param atts non-null
* @return HTML stripped, or null if not found
* @since pkg private since 0.9.35 for LogsHelper
*/
static String getAtt(Attributes atts, String s) {
String rv = atts.getValue(s);
if (rv != null)
rv = DataHelper.stripHTML(rv);

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Attributes;
import net.i2p.I2PAppContext;
import net.i2p.crypto.SigType;
@ -96,6 +97,22 @@ public class LogsHelper extends HelperBase {
return "<p>" + _t("File location") + ": <a href=\"/wrapper.log\" target=\"_blank\">" + f.getAbsolutePath() + "</a></p></td></tr>\n<tr><td><pre id=\"servicelogs\">" + str + "</pre>";
}
}
/**
* @since 0.9.35
*/
public String getBuiltBy() {
File baseDir = _context.getBaseDir();
File f = new File(new File(baseDir, "lib"), "i2p.jar");
Attributes att = FileDumpHelper.attributes(f);
if (att != null) {
String s = FileDumpHelper.getAtt(att, "Built-By");
if (s != null) {
return s;
}
}
return "Undefined";
}
/***** unused
public String getConnectionLogs() {

View File

@ -52,7 +52,8 @@
<tr><td><b>Jbigi version:</b></td><td><%=net.i2p.util.NativeBigInteger.getJbigiVersion()%></td></tr>
<tr><td><b>GMP version:</b></td><td><%=net.i2p.util.NativeBigInteger.getLibGMPVersion()%></td></tr>
<tr><td><b>Encoding:</b></td><td><%=System.getProperty("file.encoding")%></td></tr>
<tr><td><b>Charset:</b></td><td><%=java.nio.charset.Charset.defaultCharset().name()%></td></tr></tbody></table>
<tr><td><b>Charset:</b></td><td><%=java.nio.charset.Charset.defaultCharset().name()%></td></tr>
<tr><td><b>Built By:</b></td><td><jsp:getProperty name="logsHelper" property="builtBy" /></tbody></table>
<h3 class="tabletitle"><%=intl._t("Critical Logs")%></h3>
<table id="criticallogs" class="logtable"><tbody>