net.i2p.addressbook

## Class HostChecker

- java.lang.Object
- - net.i2p.addressbook.HostChecker

-     public class HostChecker
      extends Object

  Ping tester for address book entries. Tests I2P destinations for reachability and stores results.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `HostChecker.PingResult` Ping result data structure containing the outcome of a host reachability test.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HostChecker()` Construct a HostChecker that uses the default naming service This works with the blockfile format (hostsdb.blockfile)
    `HostChecker(NamingService namingService)` Construct a HostChecker for given naming service

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Map<String,String>` | `getAllCategories()` Get all host categories
    `Map<String,HostChecker.PingResult>` | `getAllPingResults()` Get all ping results
    `String` | `getCategory(String hostname)` Get category for a hostname
    `String` | `getCategoryDescription(String category)` Get description for a category
    `HostChecker.PingResult` | `getPingResult(String hostname)` Get ping result for a hostname
    `boolean` | `getUseLeaseSetCheck()` Get whether to use LeaseSet checking
    `boolean` | `isDefensiveMode()` Get defensive mode status
    `boolean` | `isRunning()` Check if ping tester is running
    `static void` | `main(String[] args)` Test method
    `void` | `setUseLeaseSetCheck(boolean useLeaseSetCheck)` Set whether to use LeaseSet checking
    `void` | `start()` Start periodic ping testing
    `void` | `stop()` Stop periodic ping testing
    `HostChecker.PingResult` | `testDestination(String hostname)` Test a single destination immediately If LeaseSet lookup succeeds, we don't overwrite the result with failed ping/eephead

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HostChecker

          public HostChecker()

      Construct a HostChecker that uses the default naming service This works with the blockfile format (hostsdb.blockfile)

    - #### HostChecker

          public HostChecker(NamingService namingService)

      Construct a HostChecker for given naming service
      Parameters:
        `namingService` - naming service to test entries from

  - ### Method Detail

    - #### getAllCategories

          public Map<String,String> getAllCategories()

      Get all host categories

    - #### getAllPingResults

          public Map<String,HostChecker.PingResult> getAllPingResults()

      Get all ping results
      Returns:
        map of hostname to ping result

    - #### getCategory

          public String getCategory(String hostname)

      Get category for a hostname

    - #### getCategoryDescription

          public String getCategoryDescription(String category)

      Get description for a category
      Parameters:
        `category` - the category name
      Returns:
        the category description, or the category itself if unknown

    - #### getPingResult

          public HostChecker.PingResult getPingResult(String hostname)

      Get ping result for a hostname
      Parameters:
        `hostname` - hostname
      Returns:
        ping result, or null if no test has been performed

    - #### getUseLeaseSetCheck

          public boolean getUseLeaseSetCheck()

      Get whether to use LeaseSet checking
      Returns:
        true if LeaseSet checking is enabled

    - #### isDefensiveMode

          public boolean isDefensiveMode()

      Get defensive mode status
      Returns:
        true if defensive mode is active

    - #### isRunning

          public boolean isRunning()

      Check if ping tester is running
      Returns:
        true if running

    - #### main

          public static void main(String[] args)
                           throws Exception

      Test method
      Throws:
        `Exception`

    - #### setUseLeaseSetCheck

          public void setUseLeaseSetCheck(boolean useLeaseSetCheck)

      Set whether to use LeaseSet checking
      Parameters:
        `useLeaseSetCheck` - true to use LeaseSet lookup first

    - #### start

          public void start()

      Start periodic ping testing

    - #### stop

          public void stop()

      Stop periodic ping testing

    - #### testDestination

          public HostChecker.PingResult testDestination(String hostname)

      Test a single destination immediately If LeaseSet lookup succeeds, we don't overwrite the result with failed ping/eephead
      Parameters:
        `hostname` - hostname to test
      Returns:
        ping result