net.i2p.i2ptunnel

## Class I2PTunnelHTTPBidirServer

- java.lang.Object
- - net.i2p.util.EventDispatcherImpl
  - - net.i2p.i2ptunnel.I2PTunnelTask
    - - net.i2p.i2ptunnel.I2PTunnelServer
      - - net.i2p.i2ptunnel.I2PTunnelHTTPServer
        - - net.i2p.i2ptunnel.I2PTunnelHTTPBidirServer

- All Implemented Interfaces:
    Runnable, EventDispatcher

      public class I2PTunnelHTTPBidirServer
      extends I2PTunnelHTTPServer

  Bidirectional HTTP server tunnel combining server and client functionality.

  Extends I2PTunnelHTTPServer to provide both inbound and outbound HTTP connectivity through I2P. Creates a server tunnel for receiving requests and a client tunnel (proxy) for outbound requests, enabling bidirectional HTTP communication through a single I2P destination.

  This class manages two tunnel components:

  - Server: Incoming HTTP connections via I2PServerSocket
  - Client: I2PTunnelHTTPBidirProxy for outbound HTTP requests

  Useful for applications requiring both server and client HTTP capabilities through I2P, such as web applications making external API calls.

  See Also:
    `I2PTunnelHTTPServer`, `I2PTunnelHTTPBidirProxy`

- - ### Field Summary

    - ### Fields inherited from class net.i2p.i2ptunnel.I2PTunnelHTTPServer

      `DEFAULT_POST_BAN_TIME, DEFAULT_POST_MAX, DEFAULT_POST_TOTAL_BAN_TIME, DEFAULT_POST_TOTAL_MAX, DEFAULT_POST_WINDOW, ERR_FORBIDDEN, ERR_NOT_FOUND, ERR_REQUEST_TIMEOUT, OPT_ADD_RESPONSE_HEADER_ALLOW, OPT_ADD_RESPONSE_HEADER_CACHE_CONTROL, OPT_ADD_RESPONSE_HEADER_NOSNIFF, OPT_ADD_RESPONSE_HEADER_REFERRER_POLICY, OPT_KEEPALIVE, OPT_POST_BAN_TIME, OPT_POST_MAX, OPT_POST_TOTAL_BAN_TIME, OPT_POST_TOTAL_MAX, OPT_POST_WINDOW, OPT_REJECT_INPROXY, OPT_REJECT_REFERER, OPT_REJECT_USER_AGENTS, OPT_USER_AGENTS`

    - ### Fields inherited from class net.i2p.i2ptunnel.I2PTunnelServer

      `__serverId, _clientExecutor, _log, bidir, i2pss, l, localPort, PROP_ALT_PKF, PROP_UNIQUE_LOCAL, PROP_USE_SSL, readTimeout, remoteHost, remotePort, slock, sockMgr, sslLock, task`

    - ### Fields inherited from class net.i2p.i2ptunnel.I2PTunnelTask

      `open, tunnel`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, File privkey, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)` Creates a bidirectional HTTP server tunnel with a private key file.
    `I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, InputStream privData, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)` Creates a bidirectional HTTP server tunnel with an input stream for the private key.
    `I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)` Creates a bidirectional HTTP server tunnel.

  - ### Method Summary

    - ### Methods inherited from class net.i2p.i2ptunnel.I2PTunnelHTTPServer

      `addEntry, blockingHandle, close, formatHeaders, formatHeadersCompact, optionsUpdated, readHeaders, readHeaders, setEntry, startRunning`

    - ### Methods inherited from class net.i2p.i2ptunnel.I2PTunnelServer

      `destroy, getReadTimeout, getSocket, getSocket, getSocketString, run, setReadTimeout, shutdownAndAwaitTermination`

    - ### Methods inherited from class net.i2p.i2ptunnel.I2PTunnelTask

      `connected, disconnected, errorOccurred, getBooleanOption, getId, getTunnel, isOpen, reportAbuse, routerDisconnected, setId, setName, setTunnel, toString`

    - ### Methods inherited from class net.i2p.util.EventDispatcherImpl

      `attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValue`

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

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

- - ### Constructor Detail

    - #### I2PTunnelHTTPBidirServer

          public I2PTunnelHTTPBidirServer(InetAddress host,
                                          int port,
                                          int proxyport,
                                          File privkey,
                                          String privkeyname,
                                          String spoofHost,
                                          Logging l,
                                          EventDispatcher notifyThis,
                                          I2PTunnel tunnel)

      Creates a bidirectional HTTP server tunnel with a private key file.
      Parameters:
        `host` - the local InetAddress to bind the server to
        `port` - the local port for incoming HTTP server connections
        `proxyport` - the local port for the outbound HTTP proxy
        `privkey` - File containing Base64-encoded private key data
        `privkeyname` - the name of the private key file (for logging)
        `spoofHost` - the spoofed hostname for the server destination
        `l` - the Logging instance for status messages
        `notifyThis` - the EventDispatcher for tunnel events
        `tunnel` - the parent I2PTunnel instance
      Throws:
        `IllegalArgumentException` - if the key file cannot be read

    - #### I2PTunnelHTTPBidirServer

          public I2PTunnelHTTPBidirServer(InetAddress host,
                                          int port,
                                          int proxyport,
                                          InputStream privData,
                                          String privkeyname,
                                          String spoofHost,
                                          Logging l,
                                          EventDispatcher notifyThis,
                                          I2PTunnel tunnel)

      Creates a bidirectional HTTP server tunnel with an input stream for the private key.
      Parameters:
        `host` - the local InetAddress to bind the server to
        `port` - the local port for incoming HTTP server connections
        `proxyport` - the local port for the outbound HTTP proxy
        `privData` - InputStream containing Base64-encoded private key data
        `privkeyname` - the name of the private key (for logging)
        `spoofHost` - the spoofed hostname for the server destination
        `l` - the Logging instance for status messages
        `notifyThis` - the EventDispatcher for tunnel events
        `tunnel` - the parent I2PTunnel instance
      Throws:
        `IllegalArgumentException` - if the key data is invalid

    - #### I2PTunnelHTTPBidirServer

          public I2PTunnelHTTPBidirServer(InetAddress host,
                                          int port,
                                          int proxyport,
                                          String privData,
                                          String spoofHost,
                                          Logging l,
                                          EventDispatcher notifyThis,
                                          I2PTunnel tunnel)

      Creates a bidirectional HTTP server tunnel.

      The server listens for incoming HTTP connections on the specified port, while the client proxy handles outbound requests through a separate port.

      Parameters:
        `host` - the local InetAddress to bind the server to (usually null/0.0.0.0)
        `port` - the local port for incoming HTTP server connections
        `proxyport` - the local port for the outbound HTTP proxy
        `privData` - Base64-encoded private key data for the I2P destination
        `spoofHost` - the spoofed hostname for the server destination
        `l` - the Logging instance for status messages
        `notifyThis` - the EventDispatcher for tunnel events
        `tunnel` - the parent I2PTunnel instance
      Throws:
        `IllegalArgumentException` - if the I2CP configuration is invalid