Opened 10 months ago

Closed 9 months ago

#2285 closed defect (fixed)

i2p/router: Fix router.rejectStartupTime Configuration Parameter

Reported by: obscuratus Owned by:
Priority: minor Milestone: 0.9.36
Component: router/general Version: 0.9.35
Keywords: Cc:
Parent Tickets:

Description

There is a configuration parameter available (router.rejectStartupTime)
to allow users to adjust the amount of time a router will reject peers
during startup.

Currently, this parameter is subsequently ignored.

I'm including a patch that implements the changes to provide functionality
for router.rejectStartupTime.

I've included an arbitrary minimum 90 second delay period to allow the
router some time to initialize. A minimum delay seems like a good idea,
but 90 seconds is just my personal estimate.

From: obscuratus <obscuratus@mail.i2p>
Date: Wed, 4 Jul 2018 10:05:51 -0500
Subject: i2p/router: Fix router.rejectStartupTime Configuration Parameter

There is a configuration parameter available (router.rejectStartupTime)
to allow users to adjust the amount of time a router will reject peers
during startup.

Currently, this parameter is subsequently ignored.

This patch implements the changes to provide functionality for
router.rejectStartupTime.

It includes a minimum 90 second delay period to allow the router
to establish its initial tunnels.

Signed-off-by: obscuratus <obscuratus@mail.i2p>
---
 router/java/src/net/i2p/router/RouterThrottleImpl.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/router/java/src/net/i2p/router/RouterThrottleImpl.java b/router/java/src/net/i2p/router/RouterThrottleImpl.java
index eb31bc6b2..e5d6a55d4 100644
--- a/router/java/src/net/i2p/router/RouterThrottleImpl.java
+++ b/router/java/src/net/i2p/router/RouterThrottleImpl.java
@@ -17,10 +17,11 @@ import net.i2p.util.SystemVersion;
  */
 public class RouterThrottleImpl implements RouterThrottle {
     protected final RouterContext _context;
     private final Log _log;
     private volatile String _tunnelStatus;
+    private final long _rejectStartupTime;
     
     /** 
      * arbitrary hard limit - if it's taking this long to get 
      * to a job, we're congested.
      *
@@ -51,11 +52,12 @@ public class RouterThrottleImpl implements RouterThrottle {
     
     public RouterThrottleImpl(RouterContext context) {
         _context = context;
         _log = context.logManager().getLog(RouterThrottleImpl.class);
         setTunnelStatus();
-        _context.simpleTimer2().addEvent(new ResetStatus(), 5*1000 + _context.getProperty(PROP_REJECT_STARTUP_TIME, DEFAULT_REJECT_STARTUP_TIME));
+        _rejectStartupTime = _context.getProperty(PROP_REJECT_STARTUP_TIME, DEFAULT_REJECT_STARTUP_TIME);
+        _context.simpleTimer2().addEvent(new ResetStatus(), 5*1000 + _rejectStartupTime);
         _context.statManager().createRateStat("router.throttleNetworkCause", "How lagged the jobQueue was when an I2NP was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
         //_context.statManager().createRateStat("router.throttleNetDbCause", "How lagged the jobQueue was when a networkDb request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
         _context.statManager().createRateStat("router.throttleTunnelCause", "How lagged the jobQueue was when a tunnel request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
         _context.statManager().createRateStat("tunnel.bytesAllocatedAtAccept", "How many bytes had been 'allocated' for participating tunnels when we accepted a request?", "Tunnels", new long[] { 10*60*1000, 60*60*1000, 24*60*60*1000 });
         _context.statManager().createRateStat("router.throttleTunnelProcessingTime1m", "How long it takes to process a message (1 minute average) when we throttle a tunnel?", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
@@ -133,11 +135,12 @@ public class RouterThrottleImpl implements RouterThrottle {
             // Don't use CRIT because this tells everybody we are shutting down
             return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
         }
         
         // Don't use CRIT because we don't want peers to think we're failing
-        if (_context.router().getUptime() < DEFAULT_REJECT_STARTUP_TIME) {
+        long localUptime = _context.router().getUptime();
+        if ((localUptime < _rejectStartupTime) || (localUptime < 90*1000)) {
             setTunnelStatus(_x("Rejecting tunnels: Starting up"));
             return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
         }
 
     /**** Moved to BuildHandler
-- 
2.16.4

Subtickets

Change History (3)

comment:1 Changed 10 months ago by obscuratus

  • Component changed from unspecified to router/general

comment:2 Changed 9 months ago by echelon

  • Milestone changed from undecided to 0.9.36
  • Priority changed from minor to maintenance
  • Type changed from defect to task

Hey

this config is old and ignoring was a lazy man way of just set this non functional.
A fixed ignore time which is the same on all I2P routers is good in terms of anonymity and security, thats why this is fixed now and this value is ignored.

echelon

comment:3 Changed 9 months ago by zzz

  • Priority changed from maintenance to minor
  • Resolution set to fixed
  • Status changed from new to closed
  • Type changed from task to defect

On review of the history, this feature was added by hottuna in 2013 for testing. It appears he just didn't add the code to actually use the configured value instead of the default value. Looks like a bug to me.

I don't see any evidence that it used to be configurable and was changed to fixed later, as was theorized in comment 2.

Patch from OP with some tweaks in 9fc6bba2c1fe4e35b338ee8b4333865cb5e11d96 0.9.35-18

Note: See TracTickets for help on using tickets.