net.i2p.i2ptunnel

## Class I2PTunnelIRCServer

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

- All Implemented Interfaces:
    Runnable, EventDispatcher

      public class I2PTunnelIRCServer
      extends I2PTunnelServer
      implements Runnable

  IRC server tunnel that filters registration to pass client destination hash as hostname.

  Enables IRC servers to track users across nick changes. Requires IRC daemon to use client-provided hostname rather than IP. Many IRCds ignore hostname in USER message (easily spoofed) unless from another server. May require IRCd configuration; not configurable in unrealircd/ngircd.

  Destination mangling options (in i2ptunnel custom options):

         ircserver.method unset:     Defaults to user method
         ircserver.method=user:       Use described method
         ircserver.method=webirc:     Use WEBIRC protocol
         ircserver.cloakKey unset:    Random persistent cloaking (default)
         ircserver.cloakKey=pass:     Consistent cloaking via passphrase hash
         ircserver.webircPassword=pw:  WEBIRC protocol password
         ircserver.webircSpoofIP=IP:   Spoofed IP for WEBIRC
         ircserver.fakeHostname=%f.b32.i2p: Fake hostname (%f=full B32, %c=cloaked)

  Note: No quotes/spaces in passphrase for GUI compatibility. No outbound filtering.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PROP_CLOAK`
    `static String` | `PROP_HOSTNAME`
    `static String` | `PROP_HOSTNAME_DEFAULT`
    `static String` | `PROP_METHOD`
    `static String` | `PROP_METHOD_DEFAULT`
    `static String` | `PROP_WEBIRC_PASSWORD`
    `static String` | `PROP_WEBIRC_SPOOF_IP`
    `static String` | `PROP_WEBIRC_SPOOF_IP_DEFAULT`

    - ### 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
    `I2PTunnelIRCServer(InetAddress host, int port, File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `blockingHandle(I2PSocket socket)` This is run in a thread from a limited-size thread pool via Handler.run(), except for a standard server (this class, no extension, as determined in getUsePool()), it is run directly in the acceptor thread (see run()).

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

      `close, destroy, getReadTimeout, getSocket, getSocket, getSocketString, optionsUpdated, run, setReadTimeout, shutdownAndAwaitTermination, startRunning`

    - ### 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`

    - ### Methods inherited from interface java.lang.Runnable

      `run`

- - ### Field Detail

    - #### PROP_CLOAK

          public static final String PROP_CLOAK

      See Also:
        Constant Field Values

    - #### PROP_HOSTNAME

          public static final String PROP_HOSTNAME

      See Also:
        Constant Field Values

    - #### PROP_HOSTNAME_DEFAULT

          public static final String PROP_HOSTNAME_DEFAULT

      See Also:
        Constant Field Values

    - #### PROP_METHOD

          public static final String PROP_METHOD

      See Also:
        Constant Field Values

    - #### PROP_METHOD_DEFAULT

          public static final String PROP_METHOD_DEFAULT

      See Also:
        Constant Field Values

    - #### PROP_WEBIRC_PASSWORD

          public static final String PROP_WEBIRC_PASSWORD

      See Also:
        Constant Field Values

    - #### PROP_WEBIRC_SPOOF_IP

          public static final String PROP_WEBIRC_SPOOF_IP

      See Also:
        Constant Field Values

    - #### PROP_WEBIRC_SPOOF_IP_DEFAULT

          public static final String PROP_WEBIRC_SPOOF_IP_DEFAULT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### I2PTunnelIRCServer

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

      Throws:
        `IllegalArgumentException` - if the I2PTunnel does not contain valid config to contact the router

  - ### Method Detail

    - #### blockingHandle

          protected void blockingHandle(I2PSocket socket)

      Description copied from class: `I2PTunnelServer`
      This is run in a thread from a limited-size thread pool via Handler.run(), except for a standard server (this class, no extension, as determined in getUsePool()), it is run directly in the acceptor thread (see run()). Handles an incoming I2P connection by forwarding it to the local TCP destination.

      This method is called by the server socket's acceptance thread when a new I2P connection arrives. It creates a local TCP socket connection and spawns an I2PTunnelRunner to handle bidirectional data streaming between the I2P and TCP connections.

      Implementation Notes:

      - Subclasses that override this must call super.blockingHandle() or implement
      full connection handling themselves
    - For protocol-specific handling (HTTP, IRC), spawn a handler thread and return
    - For simple forwarding, this base implementation handles all cases
    - Performance: local connections are fast enough to handle synchronously

    Error Handling: SocketException and IOException are caught and logged, with the socket being reset to notify the peer of the failure.

Overrides:
  `blockingHandle` in class `I2PTunnelServer`
Parameters:
  `socket` - the incoming I2P connection from a remote peer; never null
See Also:
  `I2PTunnelServer.getSocket(Hash, int)`, `I2PTunnelRunner`