java.lang.Object
net.i2p.router.CommSystemFacade
net.i2p.router.dummy.VMCommSystem
All Implemented Interfaces:
Service

public class VMCommSystemextends CommSystemFacade
Hacked up in-VM comm system for talking between contexts within the same Java virtual machine. It doesn't generate any routerAddresses, but instead tracks the peers through a singleton. It cannot connect to anything outside of its own Java VM. It does not implement TCP, UDP, and therefore no NTCP or SSU. Currently, the comm system doesn't even inject any lag, though it could (later). It does honor the standard transport stats though, but no TCP or UDP specific ones (since UDP and TCP are not implemented).

Typically, VMCommSystem is enabled by developers when it is desirable to test the router without enabling a real comm system. For a variety of testing purposes, it can be advantageous to start the router in a mode where contact with the actual network is disabled.

VMCommSystem can be enabled with the following setting in the router.config file:

i2p.vmCommSystem=true

FOR DEBUGGING AND LOCAL TESTING ONLY.

  • Field Details

    • _log

      private final Log _log
      Logger for this class.
    • _context

      private final RouterContext _context
      The router this transport serves.
    • _xdhThread

      private final X25519KeyFactory _xdhThread
      XDH factory kept for the tests.
    • _commSystemFacades

      private static Map<Hash, VMCommSystem> _commSystemFacades
      Mapping from Hash to VMCommSystem for all routers hooked together.
  • Constructor Details

    • VMCommSystem

      public VMCommSystem(RouterContext context)
      Create a comm system.
      Parameters:
      context - the router context
  • Method Details

    • getXDHFactory

      public X25519KeyFactory getXDHFactory()
      Factory for making X25519 key pairs.
      Overrides:
      getXDHFactory in class CommSystemFacade
      Returns:
      the XDHE factory
    • countActivePeers

      public int countActivePeers()
      Return the count of active peers.
      Specified by:
      countActivePeers in class CommSystemFacade
      Returns:
      the number of active peers
    • countActiveSendPeers

      public int countActiveSendPeers()
      Return the count of active send peers.
      Specified by:
      countActiveSendPeers in class CommSystemFacade
      Returns:
      the number of peers in the map other than this router
    • isEstablished

      public boolean isEstablished(Hash peer)
      Return whether established.
      Specified by:
      isEstablished in class CommSystemFacade
      Parameters:
      peer - the router to test, identified by its router identity hash
      Returns:
      true if a connection is established
    • wasFailsafeClosed

      public boolean wasFailsafeClosed(Hash peer, long withinMs)
      Always false, the VM transport never disconnects.
      Specified by:
      wasFailsafeClosed in class CommSystemFacade
      Parameters:
      peer - the peer to ask about, non-null
      withinMs - how far back counts as recent in ms; non-positive means nothing is recent
      Returns:
      true when some transport closed a session to the peer that recently
    • getEstablished

      public List<Hash> getEstablished()
      Return the established.
      Specified by:
      getEstablished in class CommSystemFacade
      Returns:
      the hashes of all the routers we are connected to, non-null
    • processMessage

      public void processMessage(OutNetMessage msg)
      The router wants us to send the given message to the peer. Do so, or fire off the failing job.
      Specified by:
      processMessage in class CommSystemFacade
      Parameters:
      msg - the message to send
    • receive

      public void receive(byte[] message, Hash fromPeer)
      We send messages between comms as bytes so that we strip any router-local info. For example, a router tags the # attempts to send through a leaseSet, what type of tunnel a tunnelId is bound to, etc.
      Parameters:
      message - the serialized I2NP message bytes to hand to the receive job
      fromPeer - the hash of the peer the bytes came from, used for profile accounting
    • shutdown

      public void shutdown()
      Shut down and release resources.
    • startup

      public void startup()
      Start up and initialize.
    • restart

      public void restart()
      Restart the service.
    • renderStatusHTML

      public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException
      Description copied from class: CommSystemFacade
      Render the transport status section of the router console page.
      Overrides:
      renderStatusHTML in class CommSystemFacade
      Parameters:
      out - receives the HTML for this transport's status section
      urlBase - base URL for links, may be null
      sortFlags - flags controlling sort order
      Throws:
      IOException - on write error
    • enableReverseLookups

      public boolean enableReverseLookups()
      No transports, so no IPs to reverse-resolve.
      Specified by:
      enableReverseLookups in class CommSystemFacade
      Returns:
      true if reverse lookups are enabled