net.i2p.i2ptunnel.socks

## Class I2PSOCKSTunnel

- java.lang.Object
- - net.i2p.util.EventDispatcherImpl
  - - net.i2p.i2ptunnel.I2PTunnelTask
    - - net.i2p.i2ptunnel.I2PTunnelClientBase
      - - net.i2p.i2ptunnel.socks.I2PSOCKSTunnel

- All Implemented Interfaces:
    Runnable, EventDispatcher
  Direct Known Subclasses:
    I2PSOCKSIRCTunnel

      public class I2PSOCKSTunnel
      extends I2PTunnelClientBase

  SOCKS proxy server that routes TCP connections through I2P network.

  This class implements a SOCKS4a/5 proxy server that accepts local SOCKS connections and forwards them to I2P destinations or configured outproxies. It supports both I2P destination routing (for .i2p addresses) and outproxy routing for clearnet access, with authentication and port-specific proxy configuration.

  The tunnel provides dynamic destination resolution, connection management, and serves as a flexible proxy solution for applications that support SOCKS protocol, enabling seamless I2P integration for various clients.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `AUTH_REALM`
    `static String` | `DEFAULT`
    `protected static int` | `INITIAL_SO_TIMEOUT` This is a standard soTimeout, not a total timeout.
    `static String` | `PROP_OUTPROXY_TYPE`
    `static String` | `PROP_PROXY_DEFAULT`
    `static String` | `PROP_PROXY_PREFIX` add "default" or port number

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

      `_clientId, _context, _log, _ownDest, dest, l, listenerReady, mySockets, PROP_USE_SSL, sockLock, sockMgr, ss`

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

      `open, tunnel`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2PSOCKSTunnel(int localPort, Logging l, boolean ownDest, EventDispatcher notifyThis, I2PTunnel tunnel, String pkf)` As of 0.9.20 this is fast, and does NOT connect the manager to the router, or open the local socket.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `I2PSocketOptions` | `buildOptions(Properties overrides)` Because getDefaultOptions() in super() is protected
    `protected void` | `clientConnectionRun(Socket s)` Manage a connection in a separate thread.
    `List<String>` | `getDefaultProxies()`
    `List<String>` | `getProxies(int port)` Gets the proxy list for a specific port.
    `HashMap<String,List<String>>` | `getProxyMap()` Gets the proxy map for all configured ports.
    `void` | `optionsUpdated(I2PTunnel tunnel)` Update the outproxy list then call super.

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

      `buildSocketManager, buildSocketManager, buildSocketManager, buildSocketManager, close, closeSocket, createI2PSocket, createI2PSocket, createI2PSocket, destroy, getDefaultOptions, getDefaultOptions, getListenHost, getLocalPort, getSocketManager, getSocketManager, getSocketManager, killSharedClient, manageConnection, run, startRunning, verifySocketManager`

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

- - ### Field Detail

    - #### AUTH_REALM

          public static final String AUTH_REALM

      See Also:
        Constant Field Values

    - #### DEFAULT

          public static final String DEFAULT

      See Also:
        Constant Field Values

    - #### INITIAL_SO_TIMEOUT

          protected static final int INITIAL_SO_TIMEOUT

      This is a standard soTimeout, not a total timeout. We have no slowloris protection on the client side. See I2PTunnelHTTPServer or SAM's ReadLine if we need that.
      See Also:
        Constant Field Values

    - #### PROP_OUTPROXY_TYPE

          public static final String PROP_OUTPROXY_TYPE

      See Also:
        Constant Field Values

    - #### PROP_PROXY_DEFAULT

          public static final String PROP_PROXY_DEFAULT

      See Also:
        Constant Field Values

    - #### PROP_PROXY_PREFIX

          public static final String PROP_PROXY_PREFIX

      add "default" or port number
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### I2PSOCKSTunnel

          public I2PSOCKSTunnel(int localPort,
                                Logging l,
                                boolean ownDest,
                                EventDispatcher notifyThis,
                                I2PTunnel tunnel,
                                String pkf)

      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:
        `pkf` - private key file name or null for transient key

  - ### Method Detail

    - #### buildOptions

          public I2PSocketOptions buildOptions(Properties overrides)

      Because getDefaultOptions() in super() is protected

    - #### clientConnectionRun

          protected void clientConnectionRun(Socket s)

      Description copied from class: `I2PTunnelClientBase`
      Manage a connection in a separate thread. This only works if you do not override manageConnection(). This is run in a thread from an unlimited-size thread pool, so it may block or run indefinitely.
      Specified by:
        `clientConnectionRun` in class `I2PTunnelClientBase`

    - #### getDefaultProxies

          public List<String> getDefaultProxies()

    - #### getProxies

          public List<String> getProxies(int port)

      Gets the proxy list for a specific port.

      If no proxies are configured for the port, returns the default proxies.

      Parameters:
        `port` - the local port to get proxies for
      Returns:
        the list of proxy destinations for the port, or default proxies

    - #### getProxyMap

          public HashMap<String,List<String>> getProxyMap()

      Gets the proxy map for all configured ports.
      Returns:
        a map of port strings to proxy lists

    - #### optionsUpdated

          public void optionsUpdated(I2PTunnel tunnel)

      Update the outproxy list then call super.
      Overrides:
        `optionsUpdated` in class `I2PTunnelClientBase`