Changeset bb56a11 for apps/streaming


Ignore:
Timestamp:
Dec 8, 2015 5:27:03 AM (5 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
77a6db1
Parents:
843e2a8 (diff), 7ea2be3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

propagate from branch 'i2p.i2p.unittests' (head 53586f73fb813f519cdb6a1f7b1b40efec2e35dc)

to branch 'i2p.i2p' (head 628a2c591ca44095e2f93acd026046d4512cf692)

Location:
apps/streaming/java/src/net/i2p/client/streaming/impl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionHandler.java

    r843e2a8 rbb56a11  
    297297        public PoisonPacket() {
    298298            super(null);
    299             setOptionalDelay(POISON_MAX_DELAY_REQUEST);
     299        }
     300
     301        @Override
     302        public int getOptionalDelay() { return POISON_MAX_DELAY_REQUEST; }
     303
     304        @Override
     305        public String toString() {
     306            return "POISON";
    300307        }
    301308    }
  • apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java

    r843e2a8 rbb56a11  
    1010import java.net.Socket;
    1111import java.net.SocketTimeoutException;
     12import java.security.GeneralSecurityException;
    1213import java.util.HashSet;
    1314import java.util.List;
     
    2829import net.i2p.client.streaming.I2PSocketManager;
    2930import net.i2p.client.streaming.I2PSocketOptions;
     31import net.i2p.crypto.SigAlgo;
    3032import net.i2p.crypto.SigType;
    3133import net.i2p.data.Certificate;
     
    6365    private final AtomicBoolean _isDestroyed = new AtomicBoolean();
    6466
    65     /** @since 0.9.21 */
    66     private static final Set<Hash> _dsaOnly = new HashSet<Hash>(16);
    67     private static final String[] DSA_ONLY_HASHES = {
     67    /**
     68     *  Does not support EC
     69     *  @since 0.9.21
     70     */
     71    private static final Set<Hash> _ecUnsupported = new HashSet<Hash>(16);
     72    private static final String[] EC_UNSUPPORTED_HASHES = {
    6873        // list from http://zzz.i2p/topics/1682?page=1#p8414
    6974        // bzr.welterde.i2p
     
    8792        // paste.i2p2.i2p
    8893        "DoyMyUUgOSTddvRpqYfKHFPPjkkX~iQmResyfjjBYWs=",
    89         // syndie.wetlerde.i2p
     94        // syndie.welterde.i2p
    9095        "xMxC54BFgyp-~zzrQI3F8m2CK--9XMcNmSAep6RH4Kk=",
    9196        // ugha.i2p
     
    96101        "im9gytzKT15mT1sB5LC9bHXCcwytQ4EPcrGQhoam-4w="
    97102    };
     103
     104    /**
     105     *  Does not support Ed
     106     *  @since 0.9.23
     107     */
     108    private static final Set<Hash> _edUnsupported = new HashSet<Hash>(16);
     109    private static final String[] ED_UNSUPPORTED_HASHES = {
     110        // list from http://zzz.i2p/topics/1682?page=1#p8414
     111        // minus those tested to support Ed
     112        // last tested 2015-11-04
     113        // bzr.welterde.i2p
     114        "Cvs1gCZTTkgD2Z2byh2J9atPmh5~I8~L7BNQnQl0hUE=",
     115        // docs.i2p2.i2p
     116        "WCXV87RdrF6j-mnn6qt7kVSBifHTlPL0PmVMFWwaolo=",
     117        // i2jump.i2p
     118        "9vaoGZbOaeqdRK2qEunlwRM9mUSW-I9R4OON35TDKK4=",
     119        // irc.welterde.i2p
     120        "5rjezx4McFk3bNhoJV-NTLlQW1AR~jiUcN6DOWMCCVc=",
     121        // lists.i2p2.i2p
     122        "qwtgoFoMSK0TOtbT4ovBX1jHUzCoZCPzrJVxjKD7RCg=",
     123        // mtn.i2p2.i2p
     124        "X5VDzYaoX9-P6bAWnrVSR5seGLkOeORP2l3Mh4drXPo=",
     125        // nntp.welterde.i2p
     126        "VXwmNIwMy1BcUVmut0oZ72jbWoqFzvxJukmS-G8kAAE=",
     127        // paste.i2p2.i2p
     128        "DoyMyUUgOSTddvRpqYfKHFPPjkkX~iQmResyfjjBYWs=",
     129        // syndie.welterde.i2p
     130        "xMxC54BFgyp-~zzrQI3F8m2CK--9XMcNmSAep6RH4Kk=",
     131        // tracker.welterde.i2p
     132        "EVkFgKkrDKyGfI7TIuDmlHoAmvHC~FbnY946DfujR0A=",
     133        // www.i2p2.i2p
     134        "im9gytzKT15mT1sB5LC9bHXCcwytQ4EPcrGQhoam-4w="
     135    };
    98136   
    99137    static {
    100         for (int i = 0; i < DSA_ONLY_HASHES.length; i++) {
    101             String s = DSA_ONLY_HASHES[i];
     138        for (int i = 0; i < EC_UNSUPPORTED_HASHES.length; i++) {
     139            String s = EC_UNSUPPORTED_HASHES[i];
    102140            Hash h = ConvertToHash.getHash(s);
    103141            if (h != null)
    104                 _dsaOnly.add(h);
     142                _ecUnsupported.add(h);
     143            else
     144                System.out.println("Bad hash " + s);
     145        }
     146        for (int i = 0; i < ED_UNSUPPORTED_HASHES.length; i++) {
     147            String s = ED_UNSUPPORTED_HASHES[i];
     148            Hash h = ConvertToHash.getHash(s);
     149            if (h != null)
     150                _edUnsupported.add(h);
    105151            else
    106152                System.out.println("Bad hash " + s);
     
    215261                priv.writeBytes(keyStream);
    216262                keys[1].writeBytes(keyStream); // signing priv
    217             } catch (Exception e) {
     263            } catch (GeneralSecurityException e) {
     264                throw new I2PSessionException("Error creating keys", e);
     265            } catch (I2PException e) {
     266                throw new I2PSessionException("Error creating keys", e);
     267            } catch (IOException e) {
     268                throw new I2PSessionException("Error creating keys", e);
     269            } catch (RuntimeException e) {
    218270                throw new I2PSessionException("Error creating keys", e);
    219271            }
     
    487539            updateUserDsaList();
    488540            Hash h = peer.calculateHash();
    489             if (_dsaOnly.contains(h) || (!_userDsaOnly.isEmpty() && _userDsaOnly.contains(h))) {
     541            SigAlgo myAlgo = session.getMyDestination().getSigType().getBaseAlgorithm();
     542            if ((myAlgo == SigAlgo.EC && _ecUnsupported.contains(h)) ||
     543                (myAlgo == SigAlgo.EdDSA && _edUnsupported.contains(h)) ||
     544                (!_userDsaOnly.isEmpty() && _userDsaOnly.contains(h))) {
    490545                // FIXME just taking the first one for now
    491546                for (I2PSession sess : _subsessions) {
     
    513568    /**
    514569     * Update the global user DSA-only list.
    515      * This does not affect the hardcoded DSA_ONLY_HASHES list above,
     570     * This does not affect the hardcoded Ex_UNSUPPORTED_HASHES lists above,
    516571     * the user can only add, not remove.
    517572     *
  • apps/streaming/java/src/net/i2p/client/streaming/impl/Packet.java

    r843e2a8 rbb56a11  
    586586        setAckThrough(DataHelper.fromLong(buffer, cur, 4));
    587587        cur += 4;
    588         int numNacks = (int)DataHelper.fromLong(buffer, cur, 1);
     588        int numNacks = buffer[cur] & 0xff;
    589589        cur++;
    590590        if (length < 22 + numNacks*4)
     
    600600            setNacks(null);
    601601        }
    602         setResendDelay((int)DataHelper.fromLong(buffer, cur, 1));
     602        setResendDelay(buffer[cur] & 0xff);
    603603        cur++;
    604604        setFlags((int)DataHelper.fromLong(buffer, cur, 2));
Note: See TracChangeset for help on using the changeset viewer.