* Console:
- Fix status to show a disconnected network error rather than clock skew or UDP error when disconnected - Use peer clock skew rather than clock offset for determining whether to display clock skew error, i.e. display what matters * Transport: Rework peer clock skew method to always return a value by falling back to router clock offset; Fix possible AIOOBE and divide by zero; remove logging; reduce min number of peers
This commit is contained in:
@ -62,6 +62,9 @@ public class SummaryHelper extends HelperBase {
|
||||
return DataHelper.formatDuration(router.getUptime());
|
||||
}
|
||||
|
||||
/**
|
||||
this displayed offset, not skew - now handled in reachability()
|
||||
|
||||
private String timeSkew() {
|
||||
if (_context == null) return "";
|
||||
//if (!_context.clock().getUpdatedSuccessfully())
|
||||
@ -72,6 +75,7 @@ public class SummaryHelper extends HelperBase {
|
||||
return "";
|
||||
return " (" + DataHelper.formatDuration(diff) + " " + _("skew") + ")";
|
||||
}
|
||||
**/
|
||||
|
||||
public boolean allowReseed() {
|
||||
return _context.netDb().isInitialized() &&
|
||||
@ -83,15 +87,20 @@ public class SummaryHelper extends HelperBase {
|
||||
public int getAllPeers() { return Math.max(_context.netDb().getKnownRouters() - 1, 0); }
|
||||
|
||||
public String getReachability() {
|
||||
return reachability() + timeSkew();
|
||||
return reachability(); // + timeSkew();
|
||||
}
|
||||
|
||||
private String reachability() {
|
||||
if (_context.router().getUptime() > 60*1000 && (!_context.router().gracefulShutdownInProgress()) &&
|
||||
!_context.clientManager().isAlive())
|
||||
return _("ERR-Client Manager I2CP Error - check logs"); // not a router problem but the user should know
|
||||
if (!_context.clock().getUpdatedSuccessfully())
|
||||
return _("ERR-ClockSkew");
|
||||
// Warn based on actual skew from peers, not update status, so if we successfully offset
|
||||
// the clock, we don't complain.
|
||||
//if (!_context.clock().getUpdatedSuccessfully())
|
||||
Long skew = _context.commSystem().getFramedAveragePeerClockSkew(33);
|
||||
// Display the actual skew, not the offset
|
||||
if (skew != null && Math.abs(skew.longValue()) > 45)
|
||||
return _("ERR-Clock Skew of {0}", DataHelper.formatDuration(Math.abs(skew.longValue()) * 1000));
|
||||
if (_context.router().isHidden())
|
||||
return _("Hidden");
|
||||
|
||||
@ -118,7 +127,9 @@ public class SummaryHelper extends HelperBase {
|
||||
default:
|
||||
ra = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (ra == null && _context.router().getUptime() > 5*60*1000) {
|
||||
if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null ||
|
||||
if (getActivePeers() <= 0)
|
||||
return _("ERR-No Active Peers, Check Network Connection and Firewall");
|
||||
else if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null ||
|
||||
_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT) == null)
|
||||
return _("ERR-UDP Disabled and Inbound TCP host/port not set");
|
||||
else
|
||||
|
@ -77,31 +77,26 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
public boolean haveHighOutboundCapacity() { return (_manager == null ? false : _manager.haveHighOutboundCapacity()); }
|
||||
|
||||
/**
|
||||
* Framed average clock skew of connected peers in seconds, or null if we cannot answer.
|
||||
* Framed average clock skew of connected peers in seconds, or the clock offset if we cannot answer.
|
||||
* Average is calculated over the middle "percentToInclude" peers.
|
||||
*/
|
||||
@Override
|
||||
public Long getFramedAveragePeerClockSkew(int percentToInclude) {
|
||||
if (_manager == null) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Returning null for framed averege peer clock skew (no transport manager)!");
|
||||
return null;
|
||||
// round toward zero
|
||||
return Long.valueOf(_context.clock().getOffset() / 1000);
|
||||
}
|
||||
Vector skews = _manager.getClockSkews();
|
||||
if (skews == null) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Returning null for framed average peer clock skew (no data)!");
|
||||
return null;
|
||||
return Long.valueOf(_context.clock().getOffset() / 1000);
|
||||
}
|
||||
if (skews.size() < 20) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Returning null for framed average peer clock skew (only " + skews.size() + " peers)!");
|
||||
return null;
|
||||
if (skews.size() < 5) {
|
||||
return Long.valueOf(_context.clock().getOffset() / 1000);
|
||||
}
|
||||
// Going to calculate, sort them
|
||||
Collections.sort(skews);
|
||||
// Calculate frame size
|
||||
int frameSize = (skews.size() * percentToInclude / 100);
|
||||
int frameSize = Math.min((skews.size() * percentToInclude / 100), 2);
|
||||
int first = (skews.size() / 2) - (frameSize / 2);
|
||||
int last = (skews.size() / 2) + (frameSize / 2);
|
||||
// Sum skew values
|
||||
@ -112,11 +107,8 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
_log.debug("Adding clock skew " + i + " valued " + value + " s.");
|
||||
sum = sum + value;
|
||||
}
|
||||
// Calculate average
|
||||
Long framedAverageClockSkew = new Long(sum / frameSize);
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Our framed average peer clock skew is " + framedAverageClockSkew + " s.");
|
||||
return framedAverageClockSkew;
|
||||
// Calculate average (round toward zero)
|
||||
return Long.valueOf(sum / frameSize);
|
||||
}
|
||||
|
||||
public List getBids(OutNetMessage msg) {
|
||||
|
Reference in New Issue
Block a user