Changeset 79c68c5


Ignore:
Timestamp:
Feb 22, 2011 11:34:02 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
61f6ecd7
Parents:
4967f8d
Message:
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r4967f8d r79c68c5  
     12011-02-22 zzz
     2    * BuildHandler: Prelmiinary participating tunnel throttler
     3    * I2PTunnel:
     4      - Add spellcheck=false to textareas
     5      - Fix HTML error in 503 error page
     6
    172011-02-19 zzz
    28    * I2PTunnel: Fix standalone server tunnels
  • router/java/src/net/i2p/router/RouterVersion.java

    r4967f8d r79c68c5  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 16;
     21    public final static long BUILD = 17;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java

    r4967f8d r79c68c5  
    3838 */
    3939class BuildHandler {
    40     private RouterContext _context;
    41     private Log _log;
    42     private BuildExecutor _exec;
    43     private Job _buildMessageHandlerJob;
    44     private Job _buildReplyMessageHandlerJob;
     40    private final RouterContext _context;
     41    private final Log _log;
     42    private final BuildExecutor _exec;
     43    private final Job _buildMessageHandlerJob;
     44    private final Job _buildReplyMessageHandlerJob;
    4545    /** list of BuildMessageState, oldest first */
    4646    private final List<BuildMessageState> _inboundBuildMessages;
     
    4949    /** list of BuildEndMessageState, oldest first - unused unless HANDLE_REPLIES_INLINE == false */
    5050    private final List<BuildEndMessageState> _inboundBuildEndMessages;
    51     private BuildMessageProcessor _processor;
     51    private final BuildMessageProcessor _processor;
     52    private final ParticipatingThrottler _throttler;
    5253
    5354    private static final boolean HANDLE_REPLIES_INLINE = true;
     
    102103        ctx.inNetMessagePool().registerHandlerJobBuilder(VariableTunnelBuildMessage.MESSAGE_TYPE, tbmhjb);
    103104        ctx.inNetMessagePool().registerHandlerJobBuilder(VariableTunnelBuildReplyMessage.MESSAGE_TYPE, tbrmhjb);
     105        _throttler = new ParticipatingThrottler(ctx);
    104106    }
    105107   
     
    499501        boolean isInGW = req.readIsInboundGateway();
    500502        boolean isOutEnd = req.readIsOutboundEndpoint();
     503
    501504        // time is in hours, and only for log below - what's the point?
    502505        // tunnel-alt-creation.html specifies that this is enforced +/- 1 hour but it is not.
     
    532535            }
    533536        }
    534        
     537
    535538        /*
    536539         * Being a IBGW or OBEP generally leads to more connections, so if we are
     
    550553                _context.throttle().setTunnelStatus(_x("Rejecting tunnels: Connection limit"));
    551554                response = TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
     555        }
     556       
     557        // Check participating throttle counters for previous and next hops
     558        // This is at the end as it compares to a percentage of created tunnels.
     559        // We may need another counter above for requests.
     560        if (response == 0 && !isInGW) {
     561            Hash from = state.fromHash;
     562            if (from == null)
     563                from = state.from.calculateHash();
     564            if (_throttler.shouldThrottle(from)) {
     565                if (_log.shouldLog(Log.WARN))
     566                    _log.warn("Rejecting tunnel (hop throttle), previous hop: " + from);
     567                // no setTunnelStatus() indication
     568                response = TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
     569            }
     570        }
     571        if (response == 0 && (!isOutEnd) &&
     572            _throttler.shouldThrottle(req.readNextIdentity())) {
     573            if (_log.shouldLog(Log.WARN))
     574                _log.warn("Rejecting tunnel (hop throttle), next hop: " + req.readNextIdentity());
     575            // no setTunnelStatus() indication
     576            response = TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
    552577        }
    553578
Note: See TracChangeset for help on using the changeset viewer.