Changeset c7d0526 for router


Ignore:
Timestamp:
May 9, 2019 8:11:03 PM (14 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d8980d1
Parents:
de8a079
Message:

Transport: Start first GeoIP lookup when netdb is ready

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

Legend:

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

    rde8a079 rc7d0526  
    184184     */
    185185    public DHSessionKeyBuilder.Factory getDHFactory() { return null; }
     186
     187    /**
     188     *  Router must call after netdb is initialized
     189     *  @since 0.9.41
     190     */
     191    public void initGeoIP() {}
    186192
    187193    /*
  • router/java/src/net/i2p/router/Router.java

    rde8a079 rc7d0526  
    876876            // but just to be safe
    877877            _context.simpleTimer2().addEvent(r, 0);
     878            _context.commSystem().initGeoIP();
    878879        }
    879880    }
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    rde8a079 rc7d0526  
    3333import net.i2p.util.SimpleTimer;
    3434import net.i2p.util.SimpleTimer2;
     35import net.i2p.util.SystemVersion;
    3536import net.i2p.util.Translate;
    3637
     
    5657        _geoIP = new GeoIP(_context);
    5758        _manager = new TransportManager(_context);
    58         startGeoIP();
    5959    }
    6060   
     
    364364     */
    365365
     366    /**
     367     *  Router must call after netdb is initialized
     368     *  @since 0.9.41
     369     */
     370    @Override
     371    public void initGeoIP() {
     372        startGeoIP();
     373    }
     374
    366375    /* We hope the routerinfos are read in and things have settled down by now, but it's not required to be so */
    367     private static final int START_DELAY = 5*60*1000;
     376    private static final int START_DELAY = SystemVersion.isSlow() ? 5*60*1000 : 5*1000;
    368377    private static final int LOOKUP_TIME = 30*60*1000;
    369378
  • router/java/src/net/i2p/router/transport/GeoIP.java

    rde8a079 rc7d0526  
    127127     * Results will be added to the table and available via get() after completion.
    128128     */
    129     public void blockingLookup() {
     129    void blockingLookup() {
    130130        if (! _context.getBooleanPropertyDefaultTrue(PROP_GEOIP_ENABLED)) {
    131131            _pendingSearch.clear();
     
    154154            File geoip2 = getGeoIP2();
    155155            DatabaseReader dbr = null;
     156            long start = _context.clock().now();
    156157            try {
    157158                // clear the negative cache every few runs, to prevent it from getting too big
     
    296297                _lock.set(false);
    297298            }
     299            if (_log.shouldInfo())
     300                _log.info("GeoIP processing finished, time: " + (_context.clock().now() - start));
    298301        }
    299302    }
     
    424427        String[] rv = new String[search.length];
    425428        int idx = 0;
    426         long start = _context.clock().now();
    427429        BufferedReader br = null;
    428430        try {
     
    460462        }
    461463
    462         if (_log.shouldLog(Log.INFO)) {
    463             _log.info("GeoIP processing finished, time: " + (_context.clock().now() - start));
    464         }
    465464        return rv;
    466465    }
     
    500499     * @param ip IPv4 or IPv6
    501500     */
    502     public void add(String ip) {
     501    void add(String ip) {
    503502        byte[] pib = Addresses.getIP(ip);
    504503        if (pib == null) return;
     
    510509     * @param ip IPv4 or IPv6
    511510     */
    512     public void add(byte ip[]) {
     511    void add(byte ip[]) {
    513512        add(toLong(ip));
    514513    }
     
    530529     * @return lower-case code, generally two letters, or null.
    531530     */
    532     public String get(String ip) {
     531    String get(String ip) {
    533532        byte[] pib = Addresses.getIP(ip);
    534533        if (pib == null) return null;
     
    541540     * @return lower-case code, generally two letters, or null.
    542541     */
    543     public String get(byte ip[]) {
     542    String get(byte ip[]) {
    544543        return get(toLong(ip));
    545544    }
     
    598597     * @return untranslated name or null
    599598     */
    600     public String fullName(String code) {
     599    String fullName(String code) {
    601600        return _codeToName.get(code);
    602601    }
Note: See TracChangeset for help on using the changeset viewer.