class ConnectionAcceptor extends Object implements Runnable
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:
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.
When multi-dest is enabled, each torrent additionally runs a TorrentAcceptLoop on
its own server socket, so that incoming connections are received on the torrent's own
destination.
Connections that repeatedly fail protocol validation may be temporarily blacklisted to prevent abuse.
| Constructor and Description |
|---|
ConnectionAcceptor(I2PSnarkUtil util,
PeerAcceptor peeracceptor)Unused (single torrent). |
ConnectionAcceptor(I2PSnarkUtil util,
PeerAcceptor peeracceptor,
TorrentDest td)Single torrent on its own destination. |
ConnectionAcceptor(I2PSnarkUtil util,
PeerCoordinatorSet set)Multitorrent. |
| Modifier and Type | Method and Description |
|---|---|
void | addTorrentAcceptor(TorrentDest td,
PeerCoordinator coordinator)Start an accept loop on a torrent's destination, adding the torrent to the
destination's loop when one already runs for a pooled destination. |
void | ban(Hash h)Ban the given hash. |
int | getPort()Returns the port this acceptor is listening on. |
void | halt()May be restarted later with startAccepting(). |
boolean | isBanned(Hash h)Is the given hash banned? |
void | removeTorrentAcceptor(TorrentDest td,
PeerCoordinator coordinator)Remove a torrent from its destination's accept loop, halting the loop when it no
longer serves any torrent. |
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. |
public ConnectionAcceptor(I2PSnarkUtil util, PeerAcceptor peeracceptor)
public ConnectionAcceptor(I2PSnarkUtil util, PeerAcceptor peeracceptor, TorrentDest td)
public ConnectionAcceptor(I2PSnarkUtil util, PeerCoordinatorSet set)
public void addTorrentAcceptor(TorrentDest td, PeerCoordinator coordinator)
td - the torrent's destinationcoordinator - the torrent's peer coordinatorpublic void ban(Hash h)
h - the hashpublic int getPort()
public void halt()
public boolean isBanned(Hash h)
h - the hashpublic void removeTorrentAcceptor(TorrentDest td, PeerCoordinator coordinator)
td - the torrent's destination, or null if it never got onecoordinator - the torrent's peer coordinatorpublic void restart()
public void startAccepting()