Changeset cc2056d


Ignore:
Timestamp:
Aug 23, 2018 3:25:45 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1453527
Parents:
6cf84ac
Message:

NTCP2 code consolidation, minor changes

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

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/router/RouterAddress.java

    r6cf84ac rcc2056d  
    289289        else if (_transportStyle.equals("NTCP"))
    290290            _transportStyle = "NTCP";
     291        else if (_transportStyle.equals("NTCP2"))
     292            _transportStyle = "NTCP2";
    291293        DataHelper.readProperties(in, _options);
    292294    }
  • router/java/src/net/i2p/router/RouterVersion.java

    r6cf84ac rcc2056d  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 0;
     21    public final static long BUILD = 1;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/crypto/X25519KeyFactory.java

    r6cf84ac rcc2056d  
    6767     *  You don't want to do this if there are multiple routers in the JVM.
    6868     *  Fix this if you care. See Router.shutdown().
    69      *  @since 0.8.8
    7069     */
    7170    public void shutdown() {
  • router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java

    r6cf84ac rcc2056d  
    10071007    /** @since 0.9.36 */
    10081008    public void gotOptions(byte[] options, boolean isHandshake) {
    1009         if (options.length < 12) {
     1009        NTCP2Options hisPadding = NTCP2Options.fromByteArray(options);
     1010        if (hisPadding == null) {
    10101011            if (_log.shouldWarn())
    10111012                _log.warn("Got options length " + options.length + " on: " + this);
    10121013            return;
    10131014        }
    1014         float tmin = (options[0] & 0xff) / 16.0f;
    1015         float tmax = (options[1] & 0xff) / 16.0f;
    1016         float rmin = (options[2] & 0xff) / 16.0f;
    1017         float rmax = (options[3] & 0xff) / 16.0f;
    1018         int tdummy = (int) DataHelper.fromLong(options, 4, 2);
    1019         int rdummy = (int) DataHelper.fromLong(options, 6, 2);
    1020         int tdelay = (int) DataHelper.fromLong(options, 8, 2);
    1021         int rdelay = (int) DataHelper.fromLong(options, 10, 2);
    1022         _hisPadding = new NTCP2Options(tmin, tmax, rmin, rmax,
    1023                                        tdummy, rdummy, tdelay, rdelay);
     1015        _hisPadding = hisPadding;
    10241016    }
    10251017
  • router/java/src/net/i2p/router/transport/ntcp/NTCP2Options.java

    r6cf84ac rcc2056d  
    11package net.i2p.router.transport.ntcp;
     2
     3import net.i2p.data.DataHelper;
    24
    35/**
     
    6163    }
    6264
     65    /**
     66     *  @since 0.9.37 consolidated from two places
     67     *  @return null on error
     68     */
     69    public static NTCP2Options fromByteArray(byte[] options) {
     70        if (options.length < 12)
     71            return null;
     72        float tmin = (options[0] & 0xff) / 16.0f;
     73        float tmax = (options[1] & 0xff) / 16.0f;
     74        float rmin = (options[2] & 0xff) / 16.0f;
     75        float rmax = (options[3] & 0xff) / 16.0f;
     76        int tdummy = (int) DataHelper.fromLong(options, 4, 2);
     77        int rdummy = (int) DataHelper.fromLong(options, 6, 2);
     78        int tdelay = (int) DataHelper.fromLong(options, 8, 2);
     79        int rdelay = (int) DataHelper.fromLong(options, 10, 2);
     80        return new NTCP2Options(tmin, tmax, rmin, rmax,
     81                                tdummy, rdummy, tdelay, rdelay);
     82    }
     83
    6384    @Override
    6485    public String toString() {
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    r6cf84ac rcc2056d  
    21322132
    21332133        public void gotOptions(byte[] options, boolean isHandshake) {
    2134             if (options.length < 12) {
     2134            NTCP2Options hisPadding = NTCP2Options.fromByteArray(options);
     2135            if (hisPadding == null) {
    21352136                if (_log.shouldWarn())
    21362137                    _log.warn("Got options length " + options.length + " on: " + this);
    21372138                return;
    21382139            }
    2139             float tmin = (options[0] & 0xff) / 16.0f;
    2140             float tmax = (options[1] & 0xff) / 16.0f;
    2141             float rmin = (options[2] & 0xff) / 16.0f;
    2142             float rmax = (options[3] & 0xff) / 16.0f;
    2143             int tdummy = (int) DataHelper.fromLong(options, 4, 2);
    2144             int rdummy = (int) DataHelper.fromLong(options, 6, 2);
    2145             int tdelay = (int) DataHelper.fromLong(options, 8, 2);
    2146             int rdelay = (int) DataHelper.fromLong(options, 10, 2);
    2147             NTCP2Options hisPadding = new NTCP2Options(tmin, tmax, rmin, rmax,
    2148                                                        tdummy, rdummy, tdelay, rdelay);
    21492140            _paddingConfig = OUR_PADDING.merge(hisPadding);
    21502141            if (_log.shouldDebug())
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r6cf84ac rcc2056d  
    274274            if (iv == null || iv.length != NTCP2_IV_LEN) {
    275275                iv = new byte[NTCP2_IV_LEN];
    276                 ctx.random().nextBytes(iv);
     276                do {
     277                    ctx.random().nextBytes(iv);
     278                } while (DataHelper.eq(iv, 0, OutboundNTCP2State.ZEROKEY, 0, NTCP2_IV_LEN));
    277279                shouldSave = true;
    278280            }
Note: See TracChangeset for help on using the changeset viewer.