Changeset c1afbd3


Ignore:
Timestamp:
Nov 11, 2015 1:48:38 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
37a4fcb
Parents:
1451dc6
Message:

SSU: Version check to send extended options

Location:
router/java/src/net/i2p/router/transport/udp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java

    r1451dc6 rc1afbd3  
    3030import net.i2p.util.I2PThread;
    3131import net.i2p.util.Log;
     32import net.i2p.util.VersionComparator;
    3233
    3334/**
     
    127128    private static final int DATA_MESSAGE_TIMEOUT = 10*1000;
    128129   
     130    /**
     131     * Java I2P has always parsed the length of the extended options field,
     132     * but i2pd hasn't recognized it until this release.
     133     * No matter, the options weren't defined until this release anyway.
     134     */
     135    private static final String VERSION_ALLOW_EXTENDED_OPTIONS = "0.9.24";
     136
     137
    129138    public EstablishmentManager(RouterContext ctx, UDPTransport transport) {
    130139        _context = ctx;
     
    357366                        return;
    358367                    }
     368                    boolean allowExtendedOptions = VersionComparator.comp(toRouterInfo.getVersion(),
     369                                                                          VERSION_ALLOW_EXTENDED_OPTIONS) >= 0;
    359370                    state = new OutboundEstablishState(_context, maybeTo, to,
    360                                                        toIdentity,
     371                                                       toIdentity, allowExtendedOptions,
    361372                                                       sessionKey, addr, _transport.getDHFactory());
    362373                    OutboundEstablishState oldState = _outboundStates.putIfAbsent(to, state);
     
    478489            // Only offer for an IPv4 session.
    479490            // TODO if already we have their RI, only offer if they need it (no 'C' cap)
     491            // TODO if extended options, only if they asked for it
    480492            if (_transport.canIntroduce() && state.getSentPort() >= 1024 &&
    481493                state.getSentIP().length == 4) {
  • router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java

    r1451dc6 rc1afbd3  
    5757    private final RemoteHostId _claimedAddress;
    5858    private final RouterIdentity _remotePeer;
     59    private final boolean _allowExtendedOptions;
    5960    private final SessionKey _introKey;
    6061    private final Queue<OutNetMessage> _queuedMessages;
     
    113114    public OutboundEstablishState(RouterContext ctx, RemoteHostId claimedAddress,
    114115                                  RemoteHostId remoteHostId,
    115                                   RouterIdentity remotePeer, SessionKey introKey, UDPAddress addr,
     116                                  RouterIdentity remotePeer, boolean allowExtendedOptions,
     117                                  SessionKey introKey, UDPAddress addr,
    116118                                  DHSessionKeyBuilder.Factory dh) {
    117119        _context = ctx;
     
    126128        _claimedAddress = claimedAddress;
    127129        _remoteHostId = remoteHostId;
     130        _allowExtendedOptions = allowExtendedOptions;
    128131        _remotePeer = remotePeer;
    129132        _introKey = introKey;
     
    158161    /** @return -1 if unset */
    159162    public long getIntroNonce() { return _introductionNonce; }
     163
     164    /** @since 0.9.24 */
     165    public boolean isExtendedOptionsAllowed() { return _allowExtendedOptions; }
    160166   
    161167    /**
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    r1451dc6 rc1afbd3  
    785785    public UDPPacket buildSessionRequestPacket(OutboundEstablishState state) {
    786786        // TODO
     787        // boolean ext = state.isExtendedOptionsAllowed();
     788        // if (ext)
    787789        //byte[] options = new byte[3];
    788790        //UDPPacket packet = buildPacketHeader(SESSION_REQUEST_FLAG_BYTE, options);
Note: See TracChangeset for help on using the changeset viewer.