Class I2PTunnelHTTPServer

All Implemented Interfaces:
Runnable, EventDispatcher
Direct Known Subclasses:
I2PTunnelHTTPBidirServer

public class I2PTunnelHTTPServer extends I2PTunnelServer
Simple extension to the I2PTunnelServer that filters the HTTP headers sent from the client to the server, replacing the Host header with whatever this instance has been configured with, and if the browser set Accept-Encoding: x-i2p-gzip, gzip the http message body and set Content-Encoding: x-i2p-gzip.
  • Field Details

  • Constructor Details

  • Method Details

    • startRunning

      public void startRunning()
      Description copied from class: I2PTunnelServer
      Start running the I2PTunnelServer. Warning, blocks while connecting to router and building tunnels;
      Overrides:
      startRunning in class I2PTunnelServer
    • close

      public boolean close(boolean forced)
      Description copied from class: I2PTunnelServer
      Note that the tunnel can be reopened after this by calling startRunning(). This does not release all resources. In particular, the I2PSocketManager remains and it may have timer threads that continue running. To release all resources permanently, call destroy().
      Overrides:
      close in class I2PTunnelServer
      Returns:
      success
      Since:
      0.9.9
    • optionsUpdated

      public void optionsUpdated(I2PTunnel tunnel)
      Description copied from class: I2PTunnelServer
      Update the I2PSocketManager. And since 0.9.15, the target host and port.
      Overrides:
      optionsUpdated in class I2PTunnelServer
      Since:
      0.9.9
    • blockingHandle

      protected void blockingHandle(I2PSocket socket)
      Called by the thread pool of I2PSocket handlers
      Overrides:
      blockingHandle in class I2PTunnelServer
    • formatHeaders

      protected static String formatHeaders(Map<String,List<String>> headers, StringBuilder command)
      Returns:
      the command followed by the header lines
    • readHeaders

      public static Map<String,List<String>> readHeaders(I2PSocket socket, InputStream in, StringBuilder command, String[] skipHeaders, I2PAppContext ctx) throws IOException
      From I2P to server: socket non-null, in null. From server to I2P: socket null, in non-null. Note: This does not handle RFC 2616 header line splitting, which is obsoleted in RFC 7230.
      Parameters:
      socket - if null, use in as InputStream
      in - if null, use socket.getInputStream() as InputStream
      command - out parameter, first line
      skipHeaders - MUST be lower case
      Throws:
      SocketTimeoutException - if timeout is reached before newline
      EOFException - if EOF is reached before newline
      net.i2p.i2ptunnel.I2PTunnelHTTPServer.LineTooLongException - if one header too long, or too many headers, or total size too big
      net.i2p.i2ptunnel.I2PTunnelHTTPServer.RequestTooLongException - if too long
      net.i2p.i2ptunnel.I2PTunnelHTTPServer.BadRequestException - on bad headers
      IOException - on other errors in the underlying stream
      Since:
      public since 0.9.57 for SOCKS