Class I2PTunnelHTTPClient

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

public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runnable
Act as a mini HTTP proxy, handling various different types of requests, forwarding them through I2P appropriately, and displaying the reply. Supported request formats are:
   $method http://$site[$port]/$path $protocolVersion
 or
   $method $path $protocolVersion\nHost: $site
 or
   $method http://i2p/$b64key/$path $protocolVersion
 or
   $method /$site/$path $protocolVersion
 or (deprecated)
   $method /eepproxy/$site/$path $protocolVersion
 
CONNECT (https) supported as of release 0.9.11. Note that http://i2p/$b64key/... and /eepproxy/$site/... are not recommended in browsers or other user-visible applications, as relative links will not resolve correctly, cookies won't work, etc. Note that http://$b64key/... and http://$b64key.i2p/... are NOT supported, as a b64 key may contain '=' and '~', both of which are illegal hostname characters. Rewrite as http://i2p/$b64key/... If the $site resolves with the I2P naming service, then it is directed towards that I2P Site, otherwise it is directed towards this client's outproxy (typically "squid.i2p"). Only HTTP and HTTPS are supported (no ftp, mailto, etc). Both GET and POST have been tested, though other $methods should work.
  • Field Details

  • Constructor Details

    • I2PTunnelHTTPClient

      public I2PTunnelHTTPClient(int localPort, Logging l, I2PSocketManager sockMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId)
      This constructor always starts the tunnel (ignoring the i2cp.delayOpen option). It is used to add a client to an existing socket manager. As of 0.9.20 this is fast, and does NOT connect the manager to the router, or open the local socket. You MUST call startRunning() for that.
      Parameters:
      sockMgr - the existing socket manager
    • I2PTunnelHTTPClient

      public I2PTunnelHTTPClient(int localPort, Logging l, boolean ownDest, String wwwProxy, EventDispatcher notifyThis, I2PTunnel tunnel) throws IllegalArgumentException
      As of 0.9.20 this is fast, and does NOT connect the manager to the router, or open the local socket. You MUST call startRunning() for that.
      Throws:
      IllegalArgumentException - if the I2PTunnel does not contain valid config to contact the router
  • Method Details

    • getDefaultOptions

      protected I2PSocketOptions getDefaultOptions()
      Create the default options (using the default timeout, etc). Warning, this does not make a copy of I2PTunnel's client options, it modifies them directly. unused?
      Overrides:
      getDefaultOptions in class I2PTunnelClientBase
    • getDefaultOptions

      protected I2PSocketOptions getDefaultOptions(Properties overrides)
      Create the default options (using the default timeout, etc). Warning, this does not make a copy of I2PTunnel's client options, it modifies them directly. Do not use overrides for per-socket options.
      Overrides:
      getDefaultOptions in class I2PTunnelClientBase
    • startRunning

      public void startRunning()
      Actually start working on incoming connections. Overridden to start an internal socket too.
      Overrides:
      startRunning in class I2PTunnelClientBase
    • close

      public boolean close(boolean forced)
      Overridden to close internal socket too.
      Overrides:
      close in class I2PTunnelClientBase
      Returns:
      success
    • getRealm

      protected String getRealm()
      Specified by:
      getRealm in class I2PTunnelHTTPClientBase
      Since:
      0.9.4
    • clientConnectionRun

      protected void clientConnectionRun(Socket s)
      Note: This does not handle RFC 2616 header line splitting, which is obsoleted in RFC 7230.
      Specified by:
      clientConnectionRun in class I2PTunnelClientBase