Changeset bc7bd62


Ignore:
Timestamp:
Feb 26, 2008 7:33:11 PM (13 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c68977ca
Parents:
bc7ab391
Message:
  • Reintroduce NTCP backlog pushback, with switch back to previous tunnel when no longer backlogged
  • Catch an nio exception in an NTCP logging statement if loglevel is WARN
  • IRC Proxy: terminate all messages with \r\n (thanks TrivialPursuit?!)
Files:
5 edited

Legend:

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

    rbc7ab391 rbc7bd62  
    165165                                    _log.info("inbound: "+outmsg);
    166166                            }
    167                             outmsg=outmsg+"\n";
     167                            outmsg=outmsg+"\r\n";   // rfc1459 sec. 2.3
    168168                            output.write(outmsg.getBytes("ISO-8859-1"));
    169169                        } else {
     
    239239                                        _log.info("outbound: "+outmsg);
    240240                                }
    241                                 outmsg=outmsg+"\n";
     241                                outmsg=outmsg+"\r\n";   // rfc1459 sec. 2.3
    242242                                output.write(outmsg.getBytes("ISO-8859-1"));
    243243                            } else {
  • history.txt

    rbc7ab391 rbc7bd62  
     12008-02-26 zzz
     2    * Reintroduce NTCP backlog pushback, with switch back to
     3      previous tunnel when no longer backlogged
     4    * Catch an nio exception in an NTCP logging statement if loglevel is WARN
     5    * IRC Proxy: terminate all messages with \r\n (thanks TrivialPursuit!)
     6
    172008-02-21 zzz
    28    * Raise inbound default bandwidth to 32KBps
  • router/java/src/net/i2p/router/RouterVersion.java

    rbc7ab391 rbc7bd62  
    1818    public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $";
    1919    public final static String VERSION = "0.6.1.31";
    20     public final static long BUILD = 6;
     20    public final static long BUILD = 7;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java

    rbc7ab391 rbc7bd62  
    256256        }
    257257       
     258        // Right here is where we should use a persistent lease and caching like
     259        // we do for outbound tunnel selection below???
     260
    258261        // randomize the ordering (so leases with equal # of failures per next
    259262        // sort are randomly ordered)
     
    436439    }
    437440   
     441    /**
     442     * Clean out old tunnels from a set.
     443     * Caller must synchronize on tc.
     444     */
     445    private void cleanTunnelCache(HashMap tc) {
     446        List deleteList = new ArrayList();
     447        for (Iterator iter = tc.keySet().iterator(); iter.hasNext(); ) {
     448            Destination dest = (Destination) iter.next();
     449            TunnelInfo tunnel = (TunnelInfo) tc.get(dest);
     450            if (!getContext().tunnelManager().isValidTunnel(_from.calculateHash(), tunnel))
     451                deleteList.add(dest);
     452        }
     453        for (Iterator iter = deleteList.iterator(); iter.hasNext(); ) {
     454            Destination dest = (Destination) iter.next();
     455            tc.remove(dest);
     456        }
     457    }
    438458
    439459    /**
    440460     * Use the same outbound tunnel as we did for the same destination previously,
    441461     * if possible, to keep the streaming lib happy
     462     * Use two caches - although a cache of a list of tunnels per dest might be
     463     * more elegant.
     464     * Key the caches just on the dest, not on source+dest, as different sources
     465     * simultaneously talking to the same dest is probably rare enough
     466     * to not bother separating out.
    442467     *
    443468     */
    444469    private static HashMap _tunnelCache = new HashMap();
     470    private static HashMap _backloggedTunnelCache = new HashMap();
    445471    private static long _cleanTime = 0;
    446472    private TunnelInfo selectOutboundTunnel(Destination to) {
     
    449475        synchronized (_tunnelCache) {
    450476            if (now - _cleanTime > 5*60*1000) {  // clean out periodically
    451                 List deleteList = new ArrayList();
    452                 for (Iterator iter = _tunnelCache.keySet().iterator(); iter.hasNext(); ) {
    453                     Destination dest = (Destination) iter.next();
    454                     tunnel = (TunnelInfo) _tunnelCache.get(dest);
    455                     if (!getContext().tunnelManager().isValidTunnel(_from.calculateHash(), tunnel))
    456                         deleteList.add(dest);
    457                 }
    458                 for (Iterator iter = deleteList.iterator(); iter.hasNext(); ) {
    459                     Destination dest = (Destination) iter.next();
    460                     _tunnelCache.remove(dest);
    461                 }
     477                cleanTunnelCache(_tunnelCache);
     478                cleanTunnelCache(_backloggedTunnelCache);
    462479                _cleanTime = now;
    463480            }
     481            /**
     482             * If old tunnel is valid and no longer backlogged, use it.
     483             * This prevents an active anonymity attack, where a peer could tell
     484             * if you were the originator by backlogging the tunnel, then removing the
     485             * backlog and seeing if traffic came back or not.
     486             */
     487            tunnel = (TunnelInfo) _backloggedTunnelCache.get(to);
     488            if (tunnel != null) {
     489                if (getContext().tunnelManager().isValidTunnel(_from.calculateHash(), tunnel)) {
     490                    if (!getContext().commSystem().isBacklogged(tunnel.getPeer(1))) {
     491                        if (_log.shouldLog(Log.WARN))
     492                            _log.warn("Switching back to tunnel " + tunnel + " for dest " + to.calculateHash().toBase64());
     493                        _backloggedTunnelCache.remove(to);
     494                        _tunnelCache.put(to, tunnel);
     495                        return tunnel;
     496                    }  // else still backlogged
     497                } else // no longer valid
     498                    _backloggedTunnelCache.remove(to);
     499            }
     500            // Use the same tunnel unless backlogged
    464501            tunnel = (TunnelInfo) _tunnelCache.get(to);
    465502            if (tunnel != null) {
    466                 if (getContext().tunnelManager().isValidTunnel(_from.calculateHash(), tunnel))
    467                     return(tunnel);
    468                 else
    469                     _tunnelCache.remove(to);
    470             }
     503                if (getContext().tunnelManager().isValidTunnel(_from.calculateHash(), tunnel)) {
     504                    if (tunnel.getLength() <= 1 || !getContext().commSystem().isBacklogged(tunnel.getPeer(1)))
     505                        return tunnel;
     506                    // backlogged
     507                    if (_log.shouldLog(Log.WARN))
     508                        _log.warn("Switching from backlogged " + tunnel + " for dest " + to.calculateHash().toBase64());
     509                    _backloggedTunnelCache.put(to, tunnel);
     510                } // else no longer valid
     511                _tunnelCache.remove(to);
     512            }
     513            // Pick a new tunnel
    471514            tunnel = selectOutboundTunnel();
    472515            if (tunnel != null)
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    rbc7ab391 rbc7bd62  
    326326            synchronized (_writeBufs) { writeBufs = _writeBufs.size(); }
    327327            if (_log.shouldLog(Log.WARN))
    328                 _log.warn("Too backlogged: queue time " + queueTime + " and the size is " + size
     328                try {
     329                    _log.warn("Too backlogged: queue time " + queueTime + " and the size is " + size
    329330                          + ", wantsWrite? " + (0 != (_conKey.interestOps()&SelectionKey.OP_WRITE))
    330331                          + ", currentOut set? " + currentOutboundSet
    331332                          + ", writeBufs: " + writeBufs + " on " + toString());
     333                } catch (Exception e) {}  // java.nio.channels.CancelledKeyException
    332334            _context.statManager().addRateData("ntcp.sendBacklogTime", queueTime, size);
    333335            return true;
Note: See TracChangeset for help on using the changeset viewer.