Class HostCheckHandler

All Implemented Interfaces:
Handler, Handler.Container, Handler.Singleton, Request.Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable

public class HostCheckHandler extends Handler.Wrapper
Block certain Host headers to prevent DNS rebinding attacks. This Handler wraps the ContextHandlerCollection, which handles all the webapps (not just routerconsole). Therefore, this protects all the webapps. This class is NOT used for the webapp or the bare ServerSocket implementation.
Since:
0.12 copied from routerconsole
  • Constructor Details

    • HostCheckHandler

      public HostCheckHandler(I2PAppContext ctx)
      MUST call setListenHosts() afterwards.
  • Method Details

    • setListenHosts

      public void setListenHosts(Set<String> hosts)
      Set the legal hosts. Not synched. Call this BEFORE starting. If empty, all are allowed.
      Parameters:
      hosts - contains hostnames or IPs. But we allow all IPs anyway.
    • handle

      public boolean handle(Request request, Response response, Callback callback) throws Exception
      Block by Host header, pass everything else to the delegate.
      Specified by:
      handle in interface Request.Handler
      Overrides:
      handle in class Handler.Wrapper
      Throws:
      Exception