java.lang.Object
net.i2p.router.networkdb.reseed.Reseeder

public class Reseederextends Object
Reseed handler that fetches router infos from configured seed URLs. Uses the built-in URL list unless "i2p.reseedURL" is overridden. Writes results to ./netDb/. Logs to console, router log, and wrapper log.

Moved from ReseedHandler in routerconsole; see ReseedChecker for additional validation.

  • Field Details

    • _context

      private final RouterContext _context
      The router context.
    • _log

      private final Log _log
      Logger for reseeding.
    • _checker

      private final ReseedChecker _checker
      Checker watching for reseed updates.
    • MAX_SU3_RESPONSE_SIZE

      private static final long MAX_SU3_RESPONSE_SIZE
      Largest SU3 download accepted, in bytes.
      See Also:
    • MAX_FILE_AGE

      private static final long MAX_FILE_AGE
      Limit per host to avoid getting stuck on one that is seriously overloaded.
      See Also:
    • ENABLE_SU3

      private static final boolean ENABLE_SU3
      Don't disable this!
      See Also:
    • MIN_RI_WANTED

      private static final int MIN_RI_WANTED
      If false, use SU3 only; disable fallback to directory index and individual dat files.
      See Also:
    • MIN_RESEED_SERVERS

      private static final int MIN_RESEED_SERVERS
      Reseed URLs required before downloading.
      See Also:
    • NETID_PARAM

      private static final String NETID_PARAM
      URL parameter carrying the network id.
      See Also:
    • DEFAULT_SEED_URL

      public static final String DEFAULT_SEED_URL
      NOTE - URLs that are in both the standard and SSL groups must use the same hostname, so the reseed process will not download from both. Ports are supported as of 0.9.14.

      NOTE - Each seedURL must be a directory, it must end with a '/', it can't end with 'index.html', for example. Both because of how individual file URLs are constructed, and because SSLEepGet doesn't follow redirects.

      See Also:
    • DEFAULT_SSL_SEED_URL

      public static final String DEFAULT_SSL_SEED_URL
      The I2P reseed servers are managed by backup (backup@mail.i2p). Please contact him for support, change requests, or issues. See also the reseed forum http://zzz.i2p/forums/18 and the reseed setup and testing guide https://i2p.net/en/docs/guides/reseed-server/

      All supported reseed hosts need a corresponding reseed (SU3) signing certificate installed in the router.

      All supported reseed hosts with selfsigned SSL certificates need the corresponding SSL certificate installed in the router.

      While this implementation supports SNI, others may not, so SNI requirements are noted.

      See Also:
    • SU3_FILENAME

      private static final String SU3_FILENAME
      Name of the downloaded reseed file.
      See Also:
    • PROP_PROXY_HOST

      public static final String PROP_PROXY_HOST
      Host for the HTTP proxy used during reseed.
      See Also:
    • PROP_PROXY_PORT

      public static final String PROP_PROXY_PORT
      Port for the HTTP proxy used during reseed.
      See Also:
    • PROP_PROXY_ENABLE

      public static final String PROP_PROXY_ENABLE
      If true, route reseed fetches through the HTTP proxy.
      See Also:
    • PROP_SSL_DISABLE

      public static final String PROP_SSL_DISABLE
      If true, do not attempt SSL when fetching a reseed URL.
      See Also:
    • PROP_SSL_REQUIRED

      public static final String PROP_SSL_REQUIRED
      If true, only fetch reseed URLs over SSL.
      See Also:
    • PROP_RESEED_URL

      public static final String PROP_RESEED_URL
      Comma-separated list of reseed URLs to try in order.
      See Also:
    • PROP_PROXY_USERNAME

      public static final String PROP_PROXY_USERNAME
      Username for HTTP proxy authentication.
      See Also:
    • PROP_PROXY_PASSWORD

      public static final String PROP_PROXY_PASSWORD
      Password for HTTP proxy authentication.
      See Also:
    • PROP_PROXY_AUTH_ENABLE

      public static final String PROP_PROXY_AUTH_ENABLE
      If true, enable HTTP proxy authentication.
      See Also:
    • PROP_SPROXY_HOST

      public static final String PROP_SPROXY_HOST
      Host for the SSL proxy used during reseed.
      See Also:
    • PROP_SPROXY_PORT

      public static final String PROP_SPROXY_PORT
      Port for the SSL proxy used during reseed.
      See Also:
    • PROP_SPROXY_ENABLE

      public static final String PROP_SPROXY_ENABLE
      If true, enable SSL proxy for reseed.
      See Also:
    • PROP_SPROXY_USERNAME

      public static final String PROP_SPROXY_USERNAME
      Username for SSL proxy authentication.
      See Also:
    • PROP_SPROXY_PASSWORD

      public static final String PROP_SPROXY_PASSWORD
      Password for SSL proxy authentication.
      See Also:
    • PROP_SPROXY_AUTH_ENABLE

      public static final String PROP_SPROXY_AUTH_ENABLE
      If true, enable SSL proxy authentication.
      See Also:
    • PROP_SPROXY_TYPE

      public static final String PROP_SPROXY_TYPE
      Type of SSL proxy to use, e.g. HTTP or SOCKS.
      See Also:
    • PROP_DISABLE

      public static final String PROP_DISABLE
      If true, skip reseeding entirely.
      See Also:
    • ROUTERINFO_PREFIX

      private static final String ROUTERINFO_PREFIX
      Filename prefix of router infos.
      See Also:
    • ROUTERINFO_SUFFIX

      private static final String ROUTERINFO_SUFFIX
      Filename suffix of router infos.
      See Also:
    • PAREN_PATTERN

      private static final Pattern PAREN_PATTERN
      Matches a parenthesised comment in a reseed URL list.
    • VERIFY_FAIL_PATTERN

      private static final Pattern VERIFY_FAIL_PATTERN
      Matches a signature verification failure line.
    • URL_SPLIT_PATTERN

      private static final Pattern URL_SPLIT_PATTERN
      Splits the reseed URL list entries.
    • BUNDLE_NAME

      private static final String BUNDLE_NAME
      Bundle holding the translated console strings.
      See Also:
  • Constructor Details

    • Reseeder

      Reseeder(RouterContext ctx, ReseedChecker rc)
      Holds context and checker references for reseed operations.
      Parameters:
      ctx - the router context
      rc - status and error reporting
  • Method Details

    • requestReseed

      void requestReseed()
      Start a reseed using the default reseed URLs. Supports su3 and directories. Threaded, nonblocking.
    • requestReseed

      void requestReseed(URI url) throws IllegalArgumentException
      Start a reseed from a single zip or su3 URL only. Threaded, nonblocking.
      Parameters:
      url - the zip or su3 resource to fetch; must end with .zip or .su3
      Throws:
      IllegalArgumentException - if it doesn't end with zip or su3
    • requestReseed

      int requestReseed(InputStream in) throws IOException
      Start a reseed from a zip or su3 input stream. Blocking, inline. Should be fast. This will close the stream.
      Parameters:
      in - the stream to read the zip or su3 data from; it is closed by this call
      Returns:
      number of valid routerinfos imported
      Throws:
      IOException - on most errors
    • isSNISupported

      private static boolean isSNISupported()
      Whether the current JVM supports Server Name Indication (SNI). True for Java 7+ and Android 2.3+ (API 9). Not guaranteed on all platforms, e.g. FreeBSD: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201446
      Returns:
      true if SNI is supported
    • _t

      private String _t(String key)
      Look up a localized string from the router console bundle.
      Parameters:
      key - the message key in the bundle
      Returns:
      the localized string for the key
    • _t

      private String _t(String s, Object o)
      Look up a localized string with one {0} substitution.
      Parameters:
      s - the message key, with {0} where the argument goes
      o - the argument substituted for {0}
      Returns:
      the localized string with the substitution applied
    • _t

      private String _t(String s, Object o, Object o2)
      Look up a localized string with {0} and {1} substitutions.
      Parameters:
      s - the message key, with {0} and {1} where the arguments go
      o - the argument substituted for {0}
      o2 - the argument substituted for {1}
      Returns:
      the localized string with both substitutions applied
    • ngettext

      private String ngettext(String s, String p, int n)
      Look up a localized string with singular/plural forms.
      Parameters:
      s - the singular form, may contain {0} for the count
      p - the plural form, may contain {0} for the count
      n - the count, used to choose between s and p
      Returns:
      the localized form matching the count