org.klomp.snark.standalone

## Class HostCheckHandler

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.util.component.ContainerLifeCycle
    - - org.eclipse.jetty.server.handler.AbstractHandler
      - - org.klomp.snark.standalone.HostCheckHandler

- All Implemented Interfaces:
    Handler, Container, Destroyable, Dumpable, LifeCycle

      public class HostCheckHandler
      extends AbstractHandler

  Block certain Host headers to prevent DNS rebinding attacks.

  Unlike in the console, this is an AbstractHandler, not a HandlerWrapper.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

      `Container.InheritedListener, Container.Listener`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HostCheckHandler()`
    `HostCheckHandler(I2PAppContext ctx)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `handle(String pathInContext, Request baseRequest, HttpServletRequest httpRequest, HttpServletResponse httpResponse)` Block by Host header, redirect HTTP to HTTPS, pass everything else to the delegate.
    `void` | `setListenHosts(Set<String> hosts)` Unused, we can't get here from RunStandalone

    - ### Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler

      `destroy, doStart, doStop, dumpThis, getServer, setServer`

    - ### Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

      `addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

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

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

    - ### Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

- - ### Constructor Detail

    - #### HostCheckHandler

          public HostCheckHandler()

    - #### HostCheckHandler

          public HostCheckHandler(I2PAppContext ctx)

  - ### Method Detail

    - #### handle

          public void handle(String pathInContext,
                             Request baseRequest,
                             HttpServletRequest httpRequest,
                             HttpServletResponse httpResponse)
                      throws IOException,
                             ServletException

      Block by Host header, redirect HTTP to HTTPS, pass everything else to the delegate.
      Throws:
        `IOException`
        `ServletException`

    - #### setListenHosts

          public void setListenHosts(Set<String> hosts)

      Unused, we can't get here from RunStandalone
      Parameters:
        `hosts` - contains hostnames or IPs. But we allow all IPs anyway.