Changeset bfafdd34


Ignore:
Timestamp:
Mar 4, 2019 7:04:42 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
10bae6a
Parents:
0b28965
Message:

NetDB: Fix tunnel selection for verify of encrypted ls2 store
Fix NPE handling lookup of encrypted ls2

Location:
router/java/src/net/i2p/router/networkdb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/HandleDatabaseLookupMessageJob.java

    r0b28965 rbfafdd34  
    103103            // As this is complex, lots of comments follow...
    104104
    105             boolean isLocal = getContext().clientManager().isLocal(ls.getDestination());
     105            boolean isLocal = getContext().clientManager().isLocal(ls.getHash());
    106106            boolean shouldPublishLocal = isLocal && getContext().clientManager().shouldPublishLeaseSet(_message.getSearchKey());
    107107       
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java

    r0b28965 rbfafdd34  
    1414import net.i2p.data.DatabaseEntry;
    1515import net.i2p.data.Hash;
     16import net.i2p.data.LeaseSet;
    1617import net.i2p.data.LeaseSet2;
    1718import net.i2p.router.Job;
     
    4243     *               already know they have it).  This can be null.
    4344     */
    44     public FloodfillStoreJob(RouterContext context, FloodfillNetworkDatabaseFacade facade, Hash key, DatabaseEntry data, Job onSuccess, Job onFailure, long timeoutMs, Set<Hash> toSkip) {
     45    public FloodfillStoreJob(RouterContext context, FloodfillNetworkDatabaseFacade facade, Hash key, DatabaseEntry data,
     46                             Job onSuccess, Job onFailure, long timeoutMs, Set<Hash> toSkip) {
    4547        super(context, facade, key, data, onSuccess, onFailure, timeoutMs, toSkip);
    4648        _facade = facade;
     
    6163
    6264        final boolean shouldLog = _log.shouldInfo();
     65        final Hash key = _state.getTarget();
    6366
    64             if (_facade.isVerifyInProgress(_state.getTarget())) {
     67            if (_facade.isVerifyInProgress(key)) {
    6568                if (shouldLog)
    66                     _log.info("Skipping verify, one already in progress for: " + _state.getTarget());
     69                    _log.info("Skipping verify, one already in progress for: " + key);
    6770                return;
    6871            }
    6972            if (getContext().router().gracefulShutdownInProgress()) {
    7073                if (shouldLog)
    71                     _log.info("Skipping verify, shutdown in progress for: " + _state.getTarget());
     74                    _log.info("Skipping verify, shutdown in progress for: " + key);
    7275                return;
    7376            }
     
    9699                sentTo = _state.getSuccessful().iterator().next();
    97100            } catch (NoSuchElementException nsee) {}
    98             Job fvsj = new FloodfillVerifyStoreJob(getContext(), _state.getTarget(),
     101            Hash client;
     102            if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     103                // get the real client hash
     104                client = ((LeaseSet)data).getDestination().calculateHash();
     105            } else {
     106                client = key;
     107            }
     108            Job fvsj = new FloodfillVerifyStoreJob(getContext(), key, client,
    99109                                                   published, type,
    100110                                                   sentTo, _facade);
    101111            if (shouldLog)
    102                 _log.info(getJobId() + ": Succeeded sending key " + _state.getTarget() +
     112                _log.info(getJobId() + ": Succeeded sending key " + key +
    103113                          ", queueing verify job " + fvsj.getJobId());
    104114            getContext().jobQueue().addJob(fvsj);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r0b28965 rbfafdd34  
    3333class FloodfillVerifyStoreJob extends JobImpl {
    3434    private final Log _log;
    35     private final Hash _key;
     35    private final Hash _key, _client;
    3636    private Hash _target;
    3737    private final Hash _sentTo;
     
    5555    /**
    5656     *  Delay a few seconds, then start the verify
     57     *  @param client generally the same as key, unless encrypted LS2
    5758     *  @param published getDate() for RI or LS1, getPublished() for LS2
    5859     *  @param sentTo who to give the credit or blame to, can be null
    5960     */
    60     public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, int type,
     61    public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, Hash client, long published, int type,
    6162                                   Hash sentTo, FloodfillNetworkDatabaseFacade facade) {
    6263        super(ctx);
    6364        facade.verifyStarted(key);
    6465        _key = key;
     66        _client = client;
    6567        _published = published;
    6668        _isRouterInfo = type == DatabaseEntry.KEY_TYPE_ROUTERINFO;
     
    106108            isInboundExploratory = true;
    107109        } else {
    108             replyTunnelInfo = getContext().tunnelManager().selectInboundTunnel(_key, _target);
     110            replyTunnelInfo = getContext().tunnelManager().selectInboundTunnel(_client, _target);
    109111            isInboundExploratory = false;
    110112        }
     
    112114            if (_log.shouldLog(Log.WARN))
    113115                _log.warn("No inbound tunnels to get a reply from!");
     116            _facade.verifyFinished(_key);
    114117            return;
    115118        }
     
    123126            outTunnel = getContext().tunnelManager().selectOutboundExploratoryTunnel(_target);
    124127        else
    125             outTunnel = getContext().tunnelManager().selectOutboundTunnel(_key, _target);
     128            outTunnel = getContext().tunnelManager().selectOutboundTunnel(_client, _target);
    126129        if (outTunnel == null) {
    127130            if (_log.shouldLog(Log.WARN))
     
    145148                sess = MessageWrapper.generateSession(getContext());
    146149            } else {
    147                 sess = MessageWrapper.generateSession(getContext(), _key);
     150                sess = MessageWrapper.generateSession(getContext(), _client);
    148151                if (sess == null) {
    149152                     if (_log.shouldLog(Log.WARN))
     
    161164            fromKey = null;
    162165        else
    163             fromKey = _key;
     166            fromKey = _client;
    164167        _wrappedMessage = MessageWrapper.wrap(getContext(), lookup, fromKey, peer);
    165168        if (_wrappedMessage == null) {
Note: See TracChangeset for help on using the changeset viewer.