Changeset 129b16d


Ignore:
Timestamp:
Jun 19, 2012 8:26:46 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e383477
Parents:
48f29ff1
Message:
  • Streaming:
    • Listen only on local port if set
    • Listen only for streaming protocol if configured (new option)
    • Javadocs re: ports
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java

    r48f29ff1 r129b16d  
    123123            String spoofHost;
    124124            int ourPort = socket.getLocalPort();
    125             if (ourPort != 80 && ourPort > 0 && ourPort < 65535 && opts != null) {
     125            if (ourPort != 80 && ourPort > 0 && ourPort <= 65535 && opts != null) {
    126126                String portSpoof = opts.getProperty("spoofedHost." + ourPort);
    127127                if (portSpoof != null)
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java

    r48f29ff1 r129b16d  
    112112                String host = url.getHost();
    113113                int port = url.getPort();
    114                 if (port <= 0 || port >= 65535)
     114                if (port <= 0 || port > 65535)
    115115                    port = 80;
    116116
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketOptions.java

    r48f29ff1 r129b16d  
    106106    /**
    107107     *  The local port.
     108     *  Zero (default) means you will receive traffic on all ports.
     109     *  Nonzero means you will get traffic ONLY for that port, use with care,
     110     *  as most applications do not specify a remote port.
    108111     *  @param port 0 - 65535
    109112     *  @since 0.8.9
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketOptionsImpl.java

    r48f29ff1 r129b16d  
    201201    /**
    202202     *  The local port.
     203     *  Zero (default) means you will receive traffic on all ports.
     204     *  Nonzero means you will get traffic ONLY for that port, use with care,
     205     *  as most applications do not specify a remote port.
    203206     *  @param port 0 - 65535
    204207     *  @since 0.8.9
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionManager.java

    r48f29ff1 r129b16d  
    6868        // Right now we get everything, and rely on Datagram to specify PROTO_UDP.
    6969        // PacketQueue has sent PROTO_STREAMING since the beginning of mux support (0.7.1)
    70         _session.addMuxedSessionListener(_messageHandler, I2PSession.PROTO_ANY, I2PSession.PORT_ANY);
     70        // As of 0.9.1, new option to enforce streaming protocol, off by default
     71        // As of 0.9.1, listen on configured port (default 0 = all)
     72        int protocol = defaultOptions.getEnforceProtocol() ? I2PSession.PROTO_STREAMING : I2PSession.PROTO_ANY;
     73        _session.addMuxedSessionListener(_messageHandler, protocol, defaultOptions.getLocalPort());
    7174        _outboundQueue = new PacketQueue(_context, _session, this);
    7275        /** Socket timeout for accept() */
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionOptions.java

    r48f29ff1 r129b16d  
    2020    private boolean _fullySigned;
    2121    private boolean _answerPings;
     22    private boolean _enforceProto;
    2223    private volatile int _windowSize;
    2324    private int _receiveWindow;
     
    8889    public static final String PROP_MAX_TOTAL_CONNS_HOUR = "i2p.streaming.maxTotalConnsPerHour";
    8990    public static final String PROP_MAX_TOTAL_CONNS_DAY = "i2p.streaming.maxTotalConnsPerDay";
     91    /** @since 0.9.1 */
     92    public static final String PROP_ENFORCE_PROTO = "i2p.streaming.enforceProtocol";
    9093   
    9194    private static final int TREND_COUNT = 3;
     
    9699    static final int MIN_WINDOW_SIZE = 1;
    97100    private static final boolean DEFAULT_ANSWER_PINGS = true;
     101    /**
     102     *  If PROTO is enforced, we cannot communicate with destinations earlier than version 0.7.1.
     103     *  @since 0.9.1
     104     */
     105    private static final boolean DEFAULT_ENFORCE_PROTO = true;
    98106
    99107    // Syncronization fix, but doing it this way causes NPE...
     
    285293            //setReadTimeout(opts.getReadTimeout());
    286294            setAnswerPings(opts.getAnswerPings());
     295            setEnforceProtocol(opts.getEnforceProtocol());
    287296            initLists(opts);
    288297            _maxConnsPerMinute = opts.getMaxConnsPerMinute();
     
    318327        setConnectTimeout(getInt(opts, PROP_CONNECT_TIMEOUT, Connection.DISCONNECT_TIMEOUT));
    319328        setAnswerPings(getBool(opts, PROP_ANSWER_PINGS, DEFAULT_ANSWER_PINGS));
     329        setEnforceProtocol(getBool(opts, PROP_ENFORCE_PROTO, DEFAULT_ENFORCE_PROTO));
    320330        initLists(opts);
    321331        _maxConnsPerMinute = getInt(opts, PROP_MAX_CONNS_MIN, 0);
     
    372382        if (opts.containsKey(PROP_ANSWER_PINGS))
    373383            setAnswerPings(getBool(opts, PROP_ANSWER_PINGS, DEFAULT_ANSWER_PINGS));
     384        if (opts.containsKey(PROP_ENFORCE_PROTO))
     385            setEnforceProtocol(getBool(opts, PROP_ENFORCE_PROTO, DEFAULT_ENFORCE_PROTO));
    374386        initLists(opts);
    375387        if (opts.containsKey(PROP_MAX_CONNS_MIN))
     
    420432    public boolean getAnswerPings() { return _answerPings; }
    421433    public void setAnswerPings(boolean yes) { _answerPings = yes; }
     434   
     435    /**
     436     * Do we receive all traffic, or only traffic marked with I2PSession.PROTO_STREAMING (6) ?
     437     * Default false.
     438     * If PROTO is enforced, we cannot communicate with destinations earlier than version 0.7.1
     439     * (released March 2009), which is when streaming started sending the PROTO_STREAMING indication.
     440     * Set to true if you are running multiple protocols on a single Destination.
     441     *
     442     * @return if we do
     443     * @since 0.9.1
     444     */
     445    public boolean getEnforceProtocol() { return _enforceProto; }
     446    public void setEnforceProtocol(boolean yes) { _enforceProto = yes; }
    422447   
    423448    /**
  • core/java/src/net/i2p/client/I2PSession.java

    r48f29ff1 r129b16d  
    3939     * payload, returning true if the router feels confident that the message
    4040     * was delivered.
     41     *
     42     * WARNING: It is recommended that you use a method that specifies the protocol and ports.
     43     *
    4144     * @param dest location to send the message
    4245     * @param payload body of the message to be sent (unencrypted)
     
    150153
    151154    /** Instruct the I2PSession where it should send event notifications
     155     *
     156     *  WARNING: It is recommended that you use a method that specifies the protocol and ports.
     157     *
    152158     * @param lsnr listener to retrieve events
    153159     */
Note: See TracChangeset for help on using the changeset viewer.