Minor fixes and javadocs after review

Set 90 day default for event log
Format clock skew in summary bar
Constant time for password hash check
This commit is contained in:
zzz
2017-11-06 23:45:57 +00:00
parent e281620063
commit 2b8f14f709
10 changed files with 21 additions and 19 deletions

View File

@ -2348,7 +2348,7 @@ public class I2PSnarkServlet extends BasicServlet {
try { try {
// class only in standalone builds // class only in standalone builds
Class helper = Class.forName("org.klomp.snark.standalone.ConfigUIHelper"); Class helper = Class.forName("org.klomp.snark.standalone.ConfigUIHelper");
Method getLangSettings = helper.getMethod("getLangSettings", I2PAppContext.class); Method getLangSettings = helper.getMethod("getLangSettings", new Class[] {I2PAppContext.class});
String langSettings = (String) getLangSettings.invoke(null, _context); String langSettings = (String) getLangSettings.invoke(null, _context);
// If we get to here, we have the language settings // If we get to here, we have the language settings
out.write("<tr><td>"); out.write("<tr><td>");
@ -3900,6 +3900,7 @@ public class I2PSnarkServlet extends BasicServlet {
_manager.setSavedCommentsEnabled(snark, yes); _manager.setSavedCommentsEnabled(snark, yes);
} }
/** @since 0.9.32 */
private static boolean noCollapsePanels(HttpServletRequest req) { private static boolean noCollapsePanels(HttpServletRequest req) {
// check for user agents that can't toggle the collapsible panels... // check for user agents that can't toggle the collapsible panels...
String ua = req.getHeader("user-agent"); String ua = req.getHeader("user-agent");

View File

@ -49,7 +49,7 @@ class UpdateHandler implements Updater {
return null; return null;
UpdateRunner update = new UpdateRunner(_context, _mgr, type, method, updateSources); UpdateRunner update = new UpdateRunner(_context, _mgr, type, method, updateSources);
// set status before thread to ensure UI feedback // set status before thread to ensure UI feedback
_mgr.notifyProgress(update, "<b>" + _mgr._t("Updating") + " I2P</b>"); _mgr.notifyProgress(update, "<b>" + _mgr._t("Updating I2P") + "</b>");
return update; return update;
} }
} }

View File

@ -259,7 +259,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
if (_isPartial) if (_isPartial)
return; return;
long d = currentWrite + bytesTransferred; long d = currentWrite + bytesTransferred;
String status = "<b>" + _t("Updating") + " I2P</b>"; String status = "<b>" + _t("Updating I2P") + "</b>";
_mgr.notifyProgress(this, status, d, d + bytesRemaining); _mgr.notifyProgress(this, status, d, d + bytesRemaining);
} }

View File

@ -26,6 +26,7 @@ public class CSSHelper extends HelperBase {
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh"; public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
private static final String PROP_XFRAME = "routerconsole.disableXFrame"; private static final String PROP_XFRAME = "routerconsole.disableXFrame";
public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole"; public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole";
/** @since 0.9.32 */
public static final String PROP_EMBED_APPS = "routerconsole.embedApps"; public static final String PROP_EMBED_APPS = "routerconsole.embedApps";
private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong()); private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong());

View File

@ -54,7 +54,7 @@ public class EventLogHelper extends FormHandler {
EventLog.WATCHDOG, _x("Watchdog warning") EventLog.WATCHDOG, _x("Watchdog warning")
}; };
private static final long DAY = 24*60*60*1000L; private static final long DAY = 24*60*60*1000L;
private static final long[] _times = { 0, DAY, 7*DAY, 30*DAY, 365*DAY }; private static final long[] _times = { 0, DAY, 7*DAY, 30*DAY, 90*DAY, 365*DAY };
public EventLogHelper() { public EventLogHelper() {
super(); super();

View File

@ -335,6 +335,7 @@ class SummaryBarRenderer {
.append(nbsp(_t("Debug"))) .append(nbsp(_t("Debug")))
.append("</a>\n") .append("</a>\n")
// 7 days
.append("<a href=\"/events?from=604800000\" target=\"_top\" title=\"") .append("<a href=\"/events?from=604800000\" target=\"_top\" title=\"")
.append(_t("View historical log of router events")) .append(_t("View historical log of router events"))
.append("\">") .append("\">")
@ -491,8 +492,8 @@ class SummaryBarRenderer {
.append(_t("Clock Skew")) .append(_t("Clock Skew"))
.append(":</b></td>" + .append(":</b></td>" +
"<td align=\"right\">") "<td align=\"right\">")
.append(_context.clock().getOffset()) .append(DataHelper.formatDuration2(_context.clock().getOffset()))
.append(" ms</td></tr>\n" + .append("</td></tr>\n" +
"<tr title=\"") "<tr title=\"")
.append(_t("How much RAM I2P is using / total RAM available to I2P (excludes RAM allocated to the JVM)")) .append(_t("How much RAM I2P is using / total RAM available to I2P (excludes RAM allocated to the JVM)"))
@ -509,9 +510,7 @@ class SummaryBarRenderer {
/** @since 0.9.32 */ /** @since 0.9.32 */
public String renderMemoryBarHTML() { public String renderMemoryBarHTML() {
if (_helper == null) return ""; if (_helper == null) return "";
StringBuilder buf = new StringBuilder(512); return _helper.getMemoryBar();
buf.append(_helper.getMemoryBar());
return buf.toString();
} }
public String renderNetworkReachabilityHTML() { public String renderNetworkReachabilityHTML() {
@ -656,6 +655,7 @@ class SummaryBarRenderer {
return buf.toString(); return buf.toString();
} }
/** @since 0.9.32 */
public String renderPeersAdvancedHTML() { public String renderPeersAdvancedHTML() {
if (_helper == null) return ""; if (_helper == null) return "";
StringBuilder buf = new StringBuilder(512); StringBuilder buf = new StringBuilder(512);

View File

@ -294,9 +294,8 @@ public class SummaryHelper extends HelperBase {
/** /**
* Retrieve amount of used memory. * Retrieve amount of used memory.
* * @since 0.9.32 uncommented
*/ */
public String getMemory() { public String getMemory() {
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0"); DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024/1024; long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024/1024;
@ -308,6 +307,7 @@ public class SummaryHelper extends HelperBase {
return integerFormatter.format(used) + " / " + total + "MB"; return integerFormatter.format(used) + " / " + total + "MB";
} }
/** @since 0.9.32 */
public String getMemoryBar() { public String getMemoryBar() {
DecimalFormat integerFormatter = new DecimalFormat("###,###,##0"); DecimalFormat integerFormatter = new DecimalFormat("###,###,##0");
long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024/1024; long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024/1024;
@ -384,11 +384,11 @@ public class SummaryHelper extends HelperBase {
//return _context.profileOrganizer().countWellIntegratedPeers(); //return _context.profileOrganizer().countWellIntegratedPeers();
return _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size(); return _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL).size();
} }
/** /**
* How many peers the router ranks as failing. * How many peers the router ranks as failing.
* * @since 0.9.32 uncommented
*/ */
public int getFailingPeers() { public int getFailingPeers() {
if (_context == null) if (_context == null)
return 0; return 0;
@ -397,10 +397,9 @@ public class SummaryHelper extends HelperBase {
} }
/** /**
* How many peers totally suck. * How many peers are banned.
* * @since 0.9.32 uncommented
*/ */
public int getBanlistedPeers() { public int getBanlistedPeers() {
if (_context == null) if (_context == null)
return 0; return 0;
@ -959,7 +958,7 @@ public class SummaryHelper extends HelperBase {
private static final String SS = Character.toString(S); private static final String SS = Character.toString(S);
public List<String> getSummaryBarSections(String page) { public List<String> getSummaryBarSections(String page) {
String config = ""; String config;
if ("home".equals(page)) { if ("home".equals(page)) {
config = _context.getProperty(PROP_SUMMARYBAR + page, isAdvanced() ? DEFAULT_MINIMAL_ADVANCED : DEFAULT_MINIMAL); config = _context.getProperty(PROP_SUMMARYBAR + page, isAdvanced() ? DEFAULT_MINIMAL_ADVANCED : DEFAULT_MINIMAL);
} else { } else {

View File

@ -387,6 +387,7 @@ class TunnelRenderer {
/** /**
* Copied from ConfigNetHelper. * Copied from ConfigNetHelper.
* @return in KBytes per second * @return in KBytes per second
* @since 0.9.32
*/ */
private int getShareBandwidth() { private int getShareBandwidth() {
int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond(); int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();

View File

@ -74,7 +74,7 @@
<h3 class="tabletitle"><%=intl._t("Event Logs")%></h3> <h3 class="tabletitle"><%=intl._t("Event Logs")%></h3>
<table id="eventlogs" class="logtable"><tbody> <table id="eventlogs" class="logtable"><tbody>
<tr><td> <tr><td>
<p><a href="events"><%=intl._t("View event logs")%></a></p> <!-- 90 days --><p><a href="events?from=7776000000"><%=intl._t("View event logs")%></a></p>
</td></tr> </td></tr>
</tbody></table> </tbody></table>

View File

@ -119,7 +119,7 @@ public class PasswordManager {
System.arraycopy(shashBytes, 0, salt, 0, SALT_LENGTH); System.arraycopy(shashBytes, 0, salt, 0, SALT_LENGTH);
System.arraycopy(shashBytes, SALT_LENGTH, hash, 0, SessionKey.KEYSIZE_BYTES); System.arraycopy(shashBytes, SALT_LENGTH, hash, 0, SessionKey.KEYSIZE_BYTES);
byte[] pwHash = _context.keyGenerator().generateSessionKey(salt, DataHelper.getUTF8(pw)).getData(); byte[] pwHash = _context.keyGenerator().generateSessionKey(salt, DataHelper.getUTF8(pw)).getData();
return DataHelper.eq(hash, pwHash); return DataHelper.eqCT(hash, 0, pwHash, 0, SessionKey.KEYSIZE_BYTES);
} }
/** /**