Changeset 4089466 for router


Ignore:
Timestamp:
Feb 19, 2016 5:01:40 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
bd49b1d
Parents:
7d6fe01
Message:

Clock: Add sanity checks to detect invalid system clock

Location:
router/java/src/net/i2p/router
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterClock.java

    r7d6fe01 r4089466  
    11package net.i2p.router;
    22
     3import java.util.Date;
    34import java.util.Set;
    45import java.util.concurrent.CopyOnWriteArraySet;
     
    67import net.i2p.data.DataHelper;
    78import net.i2p.router.time.RouterTimestamper;
     9import net.i2p.time.BuildTime;
    810import net.i2p.time.Timestamper;
    911import net.i2p.util.Clock;
     
    109111        long delta = offsetMs - _offset;
    110112        if (!force) {
    111             if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
     113            if (!_isSystemClockBad && (offsetMs > MAX_OFFSET || offsetMs < 0 - MAX_OFFSET)) {
    112114                Log log = getLog();
    113115                if (log.shouldLog(Log.WARN))
     
    219221    @Override
    220222    public void setNow(long realTime, int stratum) {
     223        if (realTime < BuildTime.getEarliestTime() || realTime > BuildTime.getLatestTime()) {
     224            Log log = getLog();
     225            String msg = "Invalid time received: " + new Date(realTime);
     226            if (log.shouldWarn())
     227                log.warn(msg, new Exception());
     228            else
     229                log.logAlways(Log.WARN, msg);
     230            return;
     231        }
    221232        long diff = realTime - System.currentTimeMillis();
    222233        setOffset(diff, stratum);
  • router/java/src/net/i2p/router/RouterVersion.java

    r7d6fe01 r4089466  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 6;
     21    public final static long BUILD = 7;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.