Search in sources :

Example 1 with NetworkDatabaseFacade

use of net.i2p.router.NetworkDatabaseFacade in project i2p.i2p by i2p.

the class ProfileOrganizer method isSelectable.

public boolean isSelectable(Hash peer) {
    NetworkDatabaseFacade netDb = _context.netDb();
    // the CLI shouldn't depend upon the netDb
    if (netDb == null)
        return true;
    if (_context.router() == null)
        return true;
    if ((_context.banlist() != null) && (_context.banlist().isBanlisted(peer))) {
        // never select a banlisted peer
        return false;
    }
    RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
    if (null != info) {
        if (info.isHidden()) {
            if (_log.shouldLog(Log.WARN))
                _log.warn("Peer " + peer.toBase64() + " is marked as hidden, disallowing its use");
            return false;
        } else {
            boolean exclude = TunnelPeerSelector.shouldExclude(_context, info);
            if (exclude) {
                // _log.warn("Peer " + peer.toBase64() + " has capabilities or other stats suggesting we avoid it");
                return false;
            } else {
                // _log.info("Peer " + peer.toBase64() + " is locally known, allowing its use");
                return true;
            }
        }
    } else {
        // _log.warn("Peer " + peer.toBase64() + " is NOT locally known, disallowing its use");
        return false;
    }
}
Also used : NetworkDatabaseFacade(net.i2p.router.NetworkDatabaseFacade) RouterInfo(net.i2p.data.router.RouterInfo)

Aggregations

RouterInfo (net.i2p.data.router.RouterInfo)1 NetworkDatabaseFacade (net.i2p.router.NetworkDatabaseFacade)1