java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.tasks.ReadConfigJob
All Implemented Interfaces:
Job

public class ReadConfigJobextends JobImpl
Simply read the router config periodically, so that the user may make config changes externally. This isn't advertised as a feature, but it could be used, for example, to change bandwidth limits at certain times of day.

Unfortunately it will also read the file back in every time the router writes it.

We must keep this enabled, as it's the only way for people to set routerconsole.advanced=true without restarting.

  • Field Details

    • DELAY

      private static final long DELAY
      How often the config is reread - every minute.
      See Also:
    • _lastRead

      private volatile long _lastRead
      When the config file was last read, in ms.
    • PROP_ADVANCED

      private static final String PROP_ADVANCED
      Property the advanced settings live under.
      See Also:
  • Constructor Details

    • ReadConfigJob

      public ReadConfigJob(RouterContext ctx)
      Create a new configuration reader job.
      Parameters:
      ctx - router context for accessing configuration and clock
  • Method Details

    • isAdvanced

      public boolean isAdvanced()
      Check if advanced console mode is enabled.
      Returns:
      true if routerconsole.advanced property is true
    • getName

      public String getName()
      Name of this job.
      Returns:
      job name for logging and identification
    • runJob

      public void runJob()
      Check for and reload router configuration if file has changed.

      This job runs periodically to detect external configuration changes. If the router.config file has been modified since last check, it will be reloaded and the last read timestamp updated.

      The check interval varies based on console mode:

      • Normal mode: every 60 seconds
      • Advanced mode: every 90 seconds

      Note: This will also trigger when the router itself writes the config file, but that's acceptable behavior.

    • shouldReread

      private boolean shouldReread(File configFile)
      Checks whether the config file changed since the last read.
      Parameters:
      configFile - the config file to check
      Returns:
      true if it is newer than the last read