java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.startup.LoadRouterInfoJob
All Implemented Interfaces:
Job

class LoadRouterInfoJobextends JobImpl
Run once or twice at startup by StartupJob, and then runs BootCommSystemJob.
  • Field Details

    • _log

      private final Log _log
      Logger for this class.
    • _banLogger

      private final BanLogger _banLogger
      Records routers that send bad data.
    • _us

      private RouterInfo _us
      Our own router info, read once.
    • _keyLengthChecked

      private static final AtomicBoolean _keyLengthChecked
      True once the key length has been checked.
    • REKEY_PROBABILITY

      private static final int REKEY_PROBABILITY
      One chance in this many to rekey if the key is too short.
      See Also:
  • Constructor Details

    • LoadRouterInfoJob

      public LoadRouterInfoJob(RouterContext ctx)
      Opens the job's log and initializes the ban logger.
      Parameters:
      ctx - the router context supplying the log and the ban logger
  • Method Details

    • getName

      public String getName()
      Name of this job.
      Returns:
      the name this job is listed under in the job queue and the logs, "Load Local RouterInfo"
    • runJob

      public void runJob()
      Load the local RouterInfo, rebuilding it if the files are missing.
    • loadRouterInfo

      private void loadRouterInfo()
      Loads router.info and either router.keys.dat or router.keys.

      See CreateRouterInfoJob for file formats.

    • shouldRebuild

      private boolean shouldRebuild(PrivateKey privkey)
      Does our RI ElGamal private key length match the configuration? If not, return true.
      Parameters:
      privkey - the router's ElGamal private key whose data length is checked
      Returns:
      true if the ElGamal key length disagrees with the configured exponent, so the RouterInfo must be rebuilt; at most once ever
    • readKeyData

      public static LoadRouterInfoJob.KeyData readKeyData(File rkf1, File rkf2) throws DataFormatException, IOException
      Read key data from the specified files.
      Parameters:
      rkf1 - in router.keys format, tried second
      rkf2 - in eepPriv.dat format, tried first
      Returns:
      non-null, throws IOE if neither exists
      Throws:
      DataFormatException - if the stored key pairs do not validate against each other
      IOException - if a key file exists but cannot be opened or read