org.klomp.snark

## Class ConnectionAcceptor

- java.lang.Object
- - org.klomp.snark.ConnectionAcceptor

- All Implemented Interfaces:
    Runnable

      class ConnectionAcceptor
      extends Object
      implements Runnable

  Accepts incoming I2P connections and routes them to the appropriate PeerAcceptor.

  This class manages the main I2P server socket that listens for incoming peer connections and routes them to the correct PeerAcceptor based on the torrent's info hash. It handles:

  - Listening on the I2P server socket for incoming connections
  - Basic connection validation and handshake parsing
  - Routing connections to the appropriate PeerAcceptor
  - Connection rate limiting and blacklisting of misbehaving peers
  - Thread management for accepting connections
  - Cleanup of stale connection data

  The acceptor supports multi-torrent operation by working with a PeerCoordinatorSet to determine which torrent a connection belongs to based on the info hash in the BitTorrent handshake.

  Connections that repeatedly fail protocol validation may be temporarily blacklisted to prevent abuse.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectionAcceptor(I2PSnarkUtil util, PeerAcceptor peeracceptor)` Unused (single torrent).
    `ConnectionAcceptor(I2PSnarkUtil util, PeerCoordinatorSet set)` Multitorrent.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getPort()`
    `void` | `halt()` May be restarted later with startAccepting().
    `void` | `restart()` Effectively unused, would only be called if we changed I2CP host/port, which is hidden in the gui if in router context
    `void` | `run()`
    `void` | `startAccepting()` May be called even when already running.

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

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

- - ### Constructor Detail

    - #### ConnectionAcceptor

          public ConnectionAcceptor(I2PSnarkUtil util,
                                    PeerAcceptor peeracceptor)

      Unused (single torrent). Do NOT call startAccepting().

    - #### ConnectionAcceptor

          public ConnectionAcceptor(I2PSnarkUtil util,
                                    PeerCoordinatorSet set)

      Multitorrent. Caller MUST call startAccepting()

  - ### Method Detail

    - #### getPort

          public int getPort()

    - #### halt

          public void halt()

      May be restarted later with startAccepting().

    - #### restart

          public void restart()

      Effectively unused, would only be called if we changed I2CP host/port, which is hidden in the gui if in router context

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### startAccepting

          public void startAccepting()

      May be called even when already running. May be called to start up again after halt().