Changeset 671e9dd


Ignore:
Timestamp:
Jan 9, 2019 6:41:36 PM (21 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8cd7e7d
Parents:
4ff9092
Message:

I2CP: Stub out client-side creation of meta and enc. LS2

Location:
core/java/src/net/i2p/client/impl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    r4ff9092 r671e9dd  
    2626import net.i2p.data.DataHelper;
    2727import net.i2p.data.Destination;
     28import net.i2p.data.EncryptedLeaseSet;
    2829import net.i2p.data.Hash;
    2930import net.i2p.data.Lease;
     
    3132import net.i2p.data.LeaseSet;
    3233import net.i2p.data.LeaseSet2;
     34import net.i2p.data.MetaLease;
     35import net.i2p.data.MetaLeaseSet;
    3336import net.i2p.data.PrivateKey;
    3437import net.i2p.data.PublicKey;
     
    4952class RequestLeaseSetMessageHandler extends HandlerImpl {
    5053    private final Map<Destination, LeaseInfo> _existingLeaseSets;
     54    protected int _ls2Type = DatabaseEntry.KEY_TYPE_LS2;
    5155
    5256    // LS 1
     
    7579    /**
    7680     *  Do we send a LeaseSet or a LeaseSet2?
     81     *
     82     *  Side effect: sets _ls2Type
     83     *
    7784     *  @since 0.9.38
    7885     */
    79     protected static boolean requiresLS2(I2PSessionImpl session) {
     86    protected boolean requiresLS2(I2PSessionImpl session) {
    8087        if (!session.supportsLS2())
    8188            return false;
     
    9299            try {
    93100                int type = Integer.parseInt(s);
     101                _ls2Type = type;
    94102                if (type != DatabaseEntry.KEY_TYPE_LEASESET)
    95103                    return true;
    96             } catch (NumberFormatException nfe) {}
     104            } catch (NumberFormatException nfe) {
     105              session.propogateError("Bad LS2 type", nfe);
     106              return true;
     107            }
    97108        }
    98109        return false;
     
    104115        RequestLeaseSetMessage msg = (RequestLeaseSetMessage) message;
    105116        boolean isLS2 = requiresLS2(session);
    106         LeaseSet leaseSet = isLS2 ? new LeaseSet2() : new LeaseSet();
     117        LeaseSet leaseSet;
     118        if (isLS2) {
     119            if (_ls2Type == DatabaseEntry.KEY_TYPE_LS2) {
     120                leaseSet = new LeaseSet2();
     121            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     122                leaseSet = new EncryptedLeaseSet();
     123            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
     124                leaseSet = new MetaLeaseSet();
     125            } else {
     126              session.propogateError("Unsupported LS2 type", new Exception());
     127              return;
     128            }
     129        } else {
     130            leaseSet = new LeaseSet();
     131        }
     132        // Full Meta and Encrypted support TODO
    107133        for (int i = 0; i < msg.getEndpoints(); i++) {
    108             Lease lease = isLS2 ? new Lease2() : new Lease();
     134            Lease lease;
     135            if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
     136                lease = new MetaLease();
     137            } else if (isLS2) {
     138                lease = new Lease2();
     139                lease.setTunnelId(msg.getTunnelId(i));
     140            } else {
     141                lease = new Lease();
     142                lease.setTunnelId(msg.getTunnelId(i));
     143            }
    109144            lease.setGateway(msg.getRouter(i));
    110             lease.setTunnelId(msg.getTunnelId(i));
    111145            lease.setEndDate(msg.getEndDate());
    112146            //lease.setStartDate(msg.getStartDate());
     
    219253        }
    220254
    221         leaseSet.setEncryptionKey(li.getPublicKey());
     255        if (_ls2Type != DatabaseEntry.KEY_TYPE_META_LS2)
     256            leaseSet.setEncryptionKey(li.getPublicKey());
    222257        leaseSet.setSigningKey(li.getSigningPublicKey());
    223258        // SubSession options aren't updated via the gui, so use the primary options
  • core/java/src/net/i2p/client/impl/RequestVariableLeaseSetMessageHandler.java

    r4ff9092 r671e9dd  
    1111
    1212import net.i2p.I2PAppContext;
     13import net.i2p.data.DatabaseEntry;
     14import net.i2p.data.EncryptedLeaseSet;
    1315import net.i2p.data.Lease;
    1416import net.i2p.data.Lease2;
    1517import net.i2p.data.LeaseSet;
    1618import net.i2p.data.LeaseSet2;
     19import net.i2p.data.MetaLease;
     20import net.i2p.data.MetaLeaseSet;
    1721import net.i2p.data.i2cp.I2CPMessage;
    1822import net.i2p.data.i2cp.RequestVariableLeaseSetMessage;
     
    3741        RequestVariableLeaseSetMessage msg = (RequestVariableLeaseSetMessage) message;
    3842        boolean isLS2 = requiresLS2(session);
    39         LeaseSet leaseSet = isLS2 ? new LeaseSet2() : new LeaseSet();
     43        LeaseSet leaseSet;
     44        if (isLS2) {
     45            if (_ls2Type == DatabaseEntry.KEY_TYPE_LS2) {
     46                leaseSet = new LeaseSet2();
     47            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     48                leaseSet = new EncryptedLeaseSet();
     49            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
     50                leaseSet = new MetaLeaseSet();
     51            } else {
     52              session.propogateError("Unsupported LS2 type", new Exception());
     53              return;
     54            }
     55        } else {
     56            leaseSet = new LeaseSet();
     57        }
     58        // Full Meta and Encrypted support TODO
    4059        for (int i = 0; i < msg.getEndpoints(); i++) {
    4160            Lease lease;
     
    4362                // convert Lease to Lease2
    4463                Lease old = msg.getEndpoint(i);
    45                 lease = new Lease2();
     64                if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
     65                    lease = new MetaLease();
     66                } else {
     67                    lease = new Lease2();
     68                    lease.setTunnelId(old.getTunnelId());
     69                }
    4670                lease.setGateway(old.getGateway());
    47                 lease.setTunnelId(old.getTunnelId());
    4871                lease.setEndDate(old.getEndDate());
    4972            } else {
Note: See TracChangeset for help on using the changeset viewer.