net.i2p.i2ptunnel.socks

## Class SOCKSServer

- java.lang.Object
- - net.i2p.i2ptunnel.socks.SOCKSServer

- Direct Known Subclasses:
    SOCKS4aServer, SOCKS5Server

      abstract class SOCKSServer
      extends Object

  Abstract base class used by all SOCKS servers.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected I2PAppContext` | `_context`
    `protected Log` | `_log`
    `protected int` | `addressType`
    `protected Socket` | `clientSock`
    `protected String` | `connHostName`
    `protected int` | `connPort`
    `protected Properties` | `props`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SOCKSServer(I2PAppContext ctx, Socket clientSock, Properties props)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `confirmConnection()` Confirm to the client that the connection has succeeded
    `abstract Socket` | `getClientSocket()` Get a socket that can be used to send/receive 8-bit clean data to/from the client.
    `abstract I2PSocket` | `getDestinationI2PSocket(I2PSOCKSTunnel t)` Get an I2PSocket that can be used to send/receive 8-bit clean data to/from the destination of the SOCKS connection.
    `protected String` | `getMappedDomainNameForIP(String ip)` IP to domain name mapping support.
    `protected Outproxy` | `getOutproxyPlugin()`
    `protected abstract void` | `setupServer()` Perform server initialization (expecially regarding protected variables).

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

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

- - ### Field Detail

    - #### _context

          protected final I2PAppContext _context

    - #### _log

          protected final Log _log

    - #### addressType

          protected int addressType

    - #### clientSock

          protected final Socket clientSock

    - #### connHostName

          protected String connHostName

    - #### connPort

          protected int connPort

    - #### props

          protected final Properties props

  - ### Constructor Detail

    - #### SOCKSServer

          protected SOCKSServer(I2PAppContext ctx,
                                Socket clientSock,
                                Properties props)

  - ### Method Detail

    - #### confirmConnection

          protected abstract void confirmConnection()
                                             throws SOCKSException

      Confirm to the client that the connection has succeeded
      Throws:
        `SOCKSException`

    - #### getClientSocket

          public abstract Socket getClientSocket()
                                          throws SOCKSException

      Get a socket that can be used to send/receive 8-bit clean data to/from the client.
      Returns:
        a Socket connected with the client
      Throws:
        `SOCKSException`

    - #### getDestinationI2PSocket

          public abstract I2PSocket getDestinationI2PSocket(I2PSOCKSTunnel t)
                                                     throws SOCKSException

      Get an I2PSocket that can be used to send/receive 8-bit clean data to/from the destination of the SOCKS connection.
      Returns:
        an I2PSocket connected with the destination
      Throws:
        `SOCKSException`

    - #### getMappedDomainNameForIP

          protected String getMappedDomainNameForIP(String ip)

      IP to domain name mapping support. This matches the given IP string against a user-set list of mappings. This enables applications which do not properly support the SOCKS5 DOMAINNAME feature to be used with I2P.
      Parameters:
        `ip` - The IP address to check.
      Returns:
        The domain name if a mapping is found, or null otherwise.

    - #### getOutproxyPlugin

          protected Outproxy getOutproxyPlugin()

      Returns:
        null if disabled or not installed

    - #### setupServer

          protected abstract void setupServer()
                                       throws SOCKSException

      Perform server initialization (expecially regarding protected variables).
      Throws:
        `SOCKSException`