All Implemented Interfaces:
Runnable, EventDispatcher

public class I2PTunnelDCCServerextends I2PTunnelServer
A standard server that only answers for registered ports, and each port can only be used once.

                                           direct conn
               <---> I2PTunnelDCCServer <--------------->I2PTunnelDCCClient <---->
  originating                                                                     responding
  chat client                                                                     chat client
       CHAT    ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->
       SEND    ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->
       RESUME  <--- I2PTunnelIRCClient <-- IRC server <-- I2TunnelIRCClient <-----
       ACCEPT  ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->
  • Field Details

  • Constructor Details

    • I2PTunnelDCCServer

      public I2PTunnelDCCServer(I2PSocketManager sktMgr, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)
      There's no support for unsolicited incoming I2P connections, so there's no server host or port parameters.
      Parameters:
      sktMgr - an existing socket manager
      l - the logging system the base class reports through
      notifyThis - the dispatcher notified of connection and transfer events
      tunnel - the owning I2PTunnel supplying the router context and configuration
      Throws:
      IllegalArgumentException - if the I2PTunnel does not contain valid config to contact the router
  • Method Details

    • blockingHandle

      protected void blockingHandle(I2PSocket socket)
      An incoming DCC connection, only accept for a known port. Passed through without filtering.
      Overrides:
      blockingHandle in class I2PTunnelServer
      Parameters:
      socket - the incoming I2P socket connection
      See Also:
    • close

      public boolean close(boolean forced)
      Closes all connections and clears all pending/outgoing/active maps.
      Overrides:
      close in class I2PTunnelServer
      Parameters:
      forced - unused, for interface compatibility
      Returns:
      true if closed successfully
    • newOutgoing

      public int newOutgoing(byte[] ip, int port, String type)
      An outgoing DCC request.
      Parameters:
      ip - local irc client IP
      port - local irc client port
      type - ignored; the overload always lets the router pick the I2P port
      Returns:
      i2p port or -1 on error
    • newOutgoing

      private int newOutgoing(byte[] ip, int port, int i2pPort)
      Register an outgoing DCC session, returning its id.
      Parameters:
      ip - local irc client IP
      port - local dcc server I2P port or 0 to pick one at random
      i2pPort - the I2P port to reserve, or 0 to pick an unused one at random
      Returns:
      the reserved I2P port, or -1 on error
    • resumeIncoming

      public int resumeIncoming(int port)
      An incoming RESUME request.
      Parameters:
      port - local dcc server I2P port
      Returns:
      local IRC client DCC port or -1 on error
    • acceptOutgoing

      public int acceptOutgoing(int port)
      An outgoing ACCEPT response.
      Parameters:
      port - local irc client DCC port
      Returns:
      local DCC server i2p port or -1 on error
    • expireOutbound

      private void expireOutbound()
      Drops the expired outgoing DCC connections.