Changeset 63a2a6d


Ignore:
Timestamp:
Dec 22, 2016 2:08:44 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
dd400bb
Parents:
3846e08
Message:

Router: Check blocklist when loading RIs
Ensure blocklist is initialized before netdb

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

Legend:

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

    r3846e08 r63a2a6d  
    7878    private final Set<Hash> _inProcess = new HashSet<Hash>(4);
    7979    private final File _blocklistFeedFile;
     80    private boolean _started;
    8081    // temp
    8182    private Map<Hash, String> _peerBlocklist = new HashMap<Hash, String>(4);
     
    100101    private static final Object DUMMY = Integer.valueOf(0);   
    101102
     103    /**
     104     *  Router MUST call startup()
     105     */
    102106    public Blocklist(RouterContext context) {
    103107        _context = context;
     
    120124     *  File if specified with router.blocklist.file
    121125     */
    122     public void startup() {
     126    public synchronized void startup() {
     127        if (_started)
     128            return;
     129        _started = true;
    123130        if (! _context.getBooleanPropertyDefaultTrue(PROP_BLOCKLIST_ENABLED))
    124131            return;
     
    143150        }
    144151        Job job = new ReadinJob(files);
    145         job.getTiming().setStartAfter(_context.clock().now() + 30*1000);
     152        // Run immediately, so it's initialized before netdb.
     153        // As this is called by Router.runRouter() before job queue parallel operation,
     154        // this will block StartupJob, and will complete before netdb initialization.
     155        // If there is a huge blocklist, it will delay router startup,
     156        // but it's important to have this initialized before we read in the netdb.
     157        //job.getTiming().setStartAfter(_context.clock().now() + 30*1000);
    146158        _context.jobQueue().addJob(job);
    147159    }
     
    172184            }
    173185            merge(ccount);
     186         /**** debug, and now run before netdb is initialized anyway
    174187            if (_log.shouldLog(Log.WARN)) {
    175188                if (_blocklistSize <= 0)
     
    185198                    _log.warn("Blocklisted " + count + " routers in the netDb");
    186199            }
     200          ****/
    187201            _peerBlocklist = null;
    188202        }
  • router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java

    r3846e08 r63a2a6d  
    524524                        if (_log.shouldLog(Log.WARN))
    525525                            _log.warn("Skipping since netdb newer than " + _routerFile);
     526                    } else if (getContext().blocklist().isBlocklisted(ri)) {
     527                        corrupt = true;
     528                        if (_log.shouldLog(Log.WARN))
     529                            _log.warn(ri.getHash() + " is blocklisted");
    526530                    } else {
    527531                        try {
Note: See TracChangeset for help on using the changeset viewer.