Class CommSystemFacadeImpl

java.lang.Object
net.i2p.router.CommSystemFacade
net.i2p.router.transport.CommSystemFacadeImpl
All Implemented Interfaces:
Service

public class CommSystemFacadeImpl extends CommSystemFacade
  • Constructor Details

    • CommSystemFacadeImpl

      public CommSystemFacadeImpl(RouterContext context)
  • Method Details

    • startup

      public void startup()
      Description copied from interface: Service
      Instruct the service that it should start normal operation. This call DOES block until the service is ready.
    • shutdown

      public void shutdown()
      Cannot be restarted after calling this. Use restart() for that.
    • restart

      public void restart()
      Description copied from interface: Service
      Perform a soft restart.
    • isRunning

      public boolean isRunning()
      Overrides:
      isRunning in class CommSystemFacade
      Since:
      0.9.53
    • countActivePeers

      public int countActivePeers()
      How many peers are we currently connected to, that we have sent a message to or received a message from in the last five minutes.
      Specified by:
      countActivePeers in class CommSystemFacade
    • countActiveSendPeers

      public int countActiveSendPeers()
      How many peers are we currently connected to, that we have sent a message to in the last minute. Unused for anything, to be removed.
      Specified by:
      countActiveSendPeers in class CommSystemFacade
    • haveInboundCapacity

      public boolean haveInboundCapacity(int pct)
      Overrides:
      haveInboundCapacity in class CommSystemFacade
    • haveOutboundCapacity

      public boolean haveOutboundCapacity(int pct)
      Overrides:
      haveOutboundCapacity in class CommSystemFacade
    • haveHighOutboundCapacity

      public boolean haveHighOutboundCapacity()
      Overrides:
      haveHighOutboundCapacity in class CommSystemFacade
    • getFramedAveragePeerClockSkew

      public long getFramedAveragePeerClockSkew(int percentToInclude)
      Description copied from class: CommSystemFacade
      Return framed average clock skew of connected peers in seconds, or null if we cannot answer. CommSystemFacadeImpl overrides this.
      Overrides:
      getFramedAveragePeerClockSkew in class CommSystemFacade
      Parameters:
      percentToInclude - 1-100
      Returns:
      Framed average clock skew of connected peers in milliseconds, or the clock offset if we cannot answer. Average is calculated over the middle "percentToInclude" peers. A positive number means our clock is ahead of theirs. Todo: change List to milliseconds
    • processMessage

      public void processMessage(OutNetMessage msg)
      Send the message out
      Specified by:
      processMessage in class CommSystemFacade
    • isBacklogged

      public boolean isBacklogged(Hash peer)
      Overrides:
      isBacklogged in class CommSystemFacade
    • isEstablished

      public boolean isEstablished(Hash peer)
      Specified by:
      isEstablished in class CommSystemFacade
    • getEstablished

      public Set<Hash> getEstablished()
      Description copied from class: CommSystemFacade
      Get all the peers we are connected to. This should be more efficient than repeated calls to isEstablished() if you have to check a lot.
      Specified by:
      getEstablished in class CommSystemFacade
      Returns:
      a new set, may be modified
      Since:
      0.9.34
    • wasUnreachable

      public boolean wasUnreachable(Hash peer)
      Overrides:
      wasUnreachable in class CommSystemFacade
    • getIP

      public byte[] getIP(Hash peer)
      Overrides:
      getIP in class CommSystemFacade
    • mayDisconnect

      public void mayDisconnect(Hash peer)
      Tell the comm system that we may disconnect from this peer. This is advisory only.
      Overrides:
      mayDisconnect in class CommSystemFacade
      Since:
      0.9.24
    • forceDisconnect

      public void forceDisconnect(Hash peer)
      Tell the comm system to disconnect from this peer.
      Overrides:
      forceDisconnect in class CommSystemFacade
      Since:
      0.9.38
    • getMostRecentErrorMessages

      public List<String> getMostRecentErrorMessages()
      Overrides:
      getMostRecentErrorMessages in class CommSystemFacade
    • getStatus

      public CommSystemFacade.Status getStatus()
      Description copied from class: CommSystemFacade
      Determine under what conditions we are remotely reachable.
      Overrides:
      getStatus in class CommSystemFacade
      Since:
      0.9.20
    • getLocalizedStatusString

      public String getLocalizedStatusString()
      getStatus().toStatusString(), translated if available.
      Overrides:
      getLocalizedStatusString in class CommSystemFacade
      Since:
      0.9.45
    • recheckReachability

      @Deprecated public void recheckReachability()
      Deprecated.
      unused
      Overrides:
      recheckReachability in class CommSystemFacade
    • renderStatusHTML

      public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException
      As of 0.9.31, only outputs UPnP status Warning - blocking, very slow, queries the active UPnP router, will take many seconds if it has vanished.
      Overrides:
      renderStatusHTML in class CommSystemFacade
      Throws:
      IOException
    • getTransports

      public SortedMap<String,Transport> getTransports()
      Overrides:
      getTransports in class CommSystemFacade
      Returns:
      SortedMap of style to Transport (a copy)
      Since:
      0.9.31
    • createAddresses

      public List<RouterAddress> createAddresses()
      Description copied from class: CommSystemFacade
      Create the list of RouterAddress structures based on the router's config
      Overrides:
      createAddresses in class CommSystemFacade
      Returns:
      non-null, possibly empty
    • notifyReplaceAddress

      public void notifyReplaceAddress(RouterAddress udpAddr)
      UDP changed addresses, tell NTCP and restart All the work moved to NTCPTransport.externalAddressReceived()
      Overrides:
      notifyReplaceAddress in class CommSystemFacade
      Parameters:
      udpAddr - may be null; or udpAddr's host/IP may be null
    • notifyRemoveAddress

      public void notifyRemoveAddress(RouterAddress address)
      Tell other transports our address changed
      Overrides:
      notifyRemoveAddress in class CommSystemFacade
      Parameters:
      address - may be null; or address's host/IP may be null
      Since:
      0.9.20
    • notifyRemoveAddress

      public void notifyRemoveAddress(boolean ipv6)
      Tell other transports our address changed
      Overrides:
      notifyRemoveAddress in class CommSystemFacade
      Since:
      0.9.20
    • registerTransport

      public void registerTransport(Transport t)
      Pluggable transports. Not for NTCP or SSU. Do not call from transport constructor. Transport must be ready to be started. Following transport methods will be called: setListener() externalAddressReceived() (zero or more times, one for each known address) startListening();
      Overrides:
      registerTransport in class CommSystemFacade
      Since:
      0.9.16
    • unregisterTransport

      public void unregisterTransport(Transport t)
      Pluggable transports. Not for NTCP or SSU. Following transport methods will be called: setListener(null) stoptListening();
      Overrides:
      unregisterTransport in class CommSystemFacade
      Since:
      0.9.16
    • getDHFactory

      public DHSessionKeyBuilder.Factory getDHFactory()
      Hook for pluggable transport creation.
      Overrides:
      getDHFactory in class CommSystemFacade
      Since:
      0.9.16
    • getXDHFactory

      public X25519KeyFactory getXDHFactory()
      Factory for making X25519 key pairs.
      Overrides:
      getXDHFactory in class CommSystemFacade
      Since:
      0.9.46
    • initGeoIP

      public void initGeoIP()
      Router must call after netdb is initialized
      Overrides:
      initGeoIP in class CommSystemFacade
      Since:
      0.9.41
    • queueLookup

      public void queueLookup(byte[] ip)
      Overrides:
      queueLookup in class CommSystemFacade
      Parameters:
      ip - ipv4 or ipv6
    • getOurCountry

      public String getOurCountry()
      Overrides:
      getOurCountry in class CommSystemFacade
      Returns:
      two-letter lower-case country code or null
      Since:
      0.8.11
    • isInStrictCountry

      public boolean isInStrictCountry()
      Are we in a strict country
      Overrides:
      isInStrictCountry in class CommSystemFacade
      Since:
      0.8.13
    • isInStrictCountry

      public boolean isInStrictCountry(Hash peer)
      Are they in a strict country. Not recommended for our local router hash, as we may not be either in the cache or netdb, or may not be publishing an IP.
      Overrides:
      isInStrictCountry in class CommSystemFacade
      Parameters:
      peer - non-null
      Since:
      0.9.16
    • isInStrictCountry

      public boolean isInStrictCountry(RouterInfo ri)
      Are they in a strict country
      Overrides:
      isInStrictCountry in class CommSystemFacade
      Parameters:
      ri - non-null
      Since:
      0.9.16
    • getCountry

      public String getCountry(Hash peer)
      Uses the transport IP first because that lookup is fast, then the IP from the netDb. Not recommended for our local router hash, as we may not be either in the cache or netdb, or may not be publishing an IP. As of 0.9.32, works only for literal IPs, returns null for hostnames.
      Overrides:
      getCountry in class CommSystemFacade
      Parameters:
      peer - not ourselves - use getOurCountry() for that
      Returns:
      two-letter lower-case country code or null
    • getCountryName

      public String getCountryName(String c)
      full name for a country code, or the code if we don't know the name
      Overrides:
      getCountryName in class CommSystemFacade
    • getCountries

      public Map<String,String> getCountries()
      Get the country code map
      Overrides:
      getCountries in class CommSystemFacade
      Returns:
      Map of two-letter lower case code to untranslated country name, unmodifiable
      Since:
      0.9.53
    • renderPeerHTML

      public String renderPeerHTML(Hash peer)
      Provide a consistent "look" for displaying router IDs in the console
      Overrides:
      renderPeerHTML in class CommSystemFacade
    • isDummy

      public boolean isDummy()
      Is everything disabled for testing?
      Overrides:
      isDummy in class CommSystemFacade
      Since:
      0.8.13