net.i2p.router

## Class CommSystemFacade

- java.lang.Object
- - net.i2p.router.CommSystemFacade

- All Implemented Interfaces:
    Service
  Direct Known Subclasses:
    CommSystemFacadeImpl, VMCommSystem

      public abstract class CommSystemFacade
      extends Object
      implements Service

  Manages peer communication subsystem including transport protocols, connection handling, and network address management for router-to-router messaging.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CommSystemFacade.Status` Network connectivity status enumeration for IPv4 and IPv6 transport capabilities.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `ROUTER_BUNDLE_NAME`
    `static short` | `STATUS_DIFFERENT` We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people
    `static short` | `STATUS_DISCONNECTED` We have no network interface at all enabled transports
    `static short` | `STATUS_HOSED` Our detection system is broken (SSU bind port failed)
    `static short` | `STATUS_IPV4_DISABLED_IPV6_FIREWALLED` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_DISABLED_IPV6_OK` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_DISABLED_IPV6_UNKNOWN` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_FIREWALLED_IPV6_OK` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_FIREWALLED_IPV6_UNKNOWN` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_OK_IPV6_FIREWALLED` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_OK_IPV6_UNKNOWN` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_SNAT_IPV6_OK` We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people We can receive unsolicited connections on IPv6.
    `static short` | `STATUS_IPV4_SNAT_IPV6_UNKNOWN` We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people We might be able to receive unsolicited connections on IPv6.
    `static short` | `STATUS_IPV4_UNKNOWN_IPV6_FIREWALLED` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_IPV4_UNKNOWN_IPV6_OK` We have an IPv6 transport enabled and a public IPv6 address.
    `static short` | `STATUS_OK` These must be increasing in "badness" (see TransportManager.java), but UNKNOWN must be last.
    `static short` | `STATUS_REJECT_UNSOLICITED` We are able to talk to peers that we initiate communication with, but cannot receive unsolicited connections, i.e.
    `static short` | `STATUS_UNKNOWN` Our reachability is unknown on all

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommSystemFacade()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract 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.
    `abstract int` | `countActiveSendPeers()` How many peers are we currently connected to, that we have sent a message to in the last minute.
    `List<RouterAddress>` | `createAddresses()` Create the list of RouterAddress structures based on the router's config
    `void` | `exemptIncoming(Hash peer)` Exempt this router hash from any incoming throttles or rejections
    `void` | `forceDisconnect(Hash peer)` Tell the comm system to disconnect from this peer.
    `String` | `getCanonicalHostName(String ipAddress)`
    `String` | `getCanonicalHostNameSync(String ipAddress)`
    `Map<String,String>` | `getCountries()` Get the country code map
    `String` | `getCountry(Hash peer)`
    `String` | `getCountry(String ip)` Get country code for an IP address
    `String` | `getCountryName(String code)`
    `abstract List<Hash>` | `getEstablished()` Get all the peers we are connected to.
    `long` | `getFramedAveragePeerClockSkew(int percentToInclude)` Return framed average clock skew of connected peers in seconds, or null if we cannot answer.
    `byte[]` | `getIP(Hash dest)`
    `String` | `getLocalizedStatusString()` getStatus().toStatusString(), translated if available.
    `Long` | `getMedianPeerClockSkew()` Median clock skew of connected peers in seconds, or null if we cannot answer.
    `List<String>` | `getMostRecentErrorMessages()`
    `String` | `getOurCountry()`
    `CommSystemFacade.Status` | `getStatus()` Determine under what conditions we are remotely reachable.
    `SortedMap<String,Transport>` | `getTransports()`
    `X25519KeyFactory` | `getXDHFactory()` Factory for making X25519 key pairs.
    `boolean` | `haveHighOutboundCapacity()`
    `boolean` | `haveInboundCapacity(int pct)`
    `boolean` | `haveOutboundCapacity(int pct)`
    `void` | `initGeoIP()` Router must call after netdb is initialized
    `boolean` | `isBacklogged(Hash peer)`
    `boolean` | `isDummy()`
    `abstract boolean` | `isEstablished(Hash peer)`
    `boolean` | `isExemptIncoming(String ip)` Is this IP exempt from any incoming throttles or rejections
    `boolean` | `isInStrictCountry()`
    `boolean` | `isInStrictCountry(Hash peer)`
    `boolean` | `isInStrictCountry(RouterInfo ri)`
    `boolean` | `isRunning()`
    `void` | `mayDisconnect(Hash peer)` Tell the comm system that we may disconnect from this peer.
    `void` | `notifyRemoveAddress(boolean ipv6)` Tell other transports our address changed
    `void` | `notifyRemoveAddress(RouterAddress address)` Tell other transports our address changed
    `void` | `notifyReplaceAddress(RouterAddress address)` Tell other transports our address changed
    `abstract void` | `processMessage(OutNetMessage msg)`
    `void` | `queueLookup(byte[] ip)`
    `void` | `registerTransport(Transport t)` Pluggable transport
    `void` | `removeExemption(String ip)` Remove this IP from the exemptions
    `String` | `renderPeerCaps(Hash peer, boolean inline)`
    `String` | `renderPeerFlag(Hash peer)`
    `String` | `renderPeerHTML(Hash peer, boolean extended)`
    `void` | `renderStatusHTML(Writer out)`
    `void` | `renderStatusHTML(Writer out, String urlBase, int sortFlags)`
    `void` | `unregisterTransport(Transport t)` Pluggable transport
    `boolean` | `wasUnreachable(Hash peer)`

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

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

    - ### Methods inherited from interface net.i2p.router.Service

      `restart, shutdown, startup`

- - ### Field Detail

    - #### ROUTER_BUNDLE_NAME

          protected static final String ROUTER_BUNDLE_NAME

      See Also:
        Constant Field Values

    - #### STATUS_DIFFERENT

          public static final short STATUS_DIFFERENT

      We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people
      See Also:
        Constant Field Values

    - #### STATUS_DISCONNECTED

          public static final short STATUS_DISCONNECTED

      We have no network interface at all enabled transports
      See Also:
        Constant Field Values

    - #### STATUS_HOSED

          public static final short STATUS_HOSED

      Our detection system is broken (SSU bind port failed)
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_DISABLED_IPV6_FIREWALLED

          public static final short STATUS_IPV4_DISABLED_IPV6_FIREWALLED

      We have an IPv6 transport enabled and a public IPv6 address. IPv4 is disabled. We can receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_DISABLED_IPV6_OK

          public static final short STATUS_IPV4_DISABLED_IPV6_OK

      We have an IPv6 transport enabled and a public IPv6 address. IPv4 is disabled. We can receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_DISABLED_IPV6_UNKNOWN

          public static final short STATUS_IPV4_DISABLED_IPV6_UNKNOWN

      We have an IPv6 transport enabled and a public IPv6 address. IPv4 is disabled. We might be able to receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_FIREWALLED_IPV6_OK

          public static final short STATUS_IPV4_FIREWALLED_IPV6_OK

      We have an IPv6 transport enabled and a public IPv6 address. We cannot receive unsolicited connections on IPv4. We can receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_FIREWALLED_IPV6_UNKNOWN

          public static final short STATUS_IPV4_FIREWALLED_IPV6_UNKNOWN

      We have an IPv6 transport enabled and a public IPv6 address. We cannot receive unsolicited connections on IPv4. We might be able to receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_OK_IPV6_FIREWALLED

          public static final short STATUS_IPV4_OK_IPV6_FIREWALLED

      We have an IPv6 transport enabled and a public IPv6 address. We can receive unsolicited connections on IPv4. We cannot receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_OK_IPV6_UNKNOWN

          public static final short STATUS_IPV4_OK_IPV6_UNKNOWN

      We have an IPv6 transport enabled and a public IPv6 address. We can receive unsolicited connections on IPv4. We might be able to receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_SNAT_IPV6_OK

          public static final short STATUS_IPV4_SNAT_IPV6_OK

      We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people We can receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_SNAT_IPV6_UNKNOWN

          public static final short STATUS_IPV4_SNAT_IPV6_UNKNOWN

      We are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people We might be able to receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_UNKNOWN_IPV6_FIREWALLED

          public static final short STATUS_IPV4_UNKNOWN_IPV6_FIREWALLED

      We have an IPv6 transport enabled and a public IPv6 address. We may be able to receive unsolicited connections on IPv4. We cannot receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_IPV4_UNKNOWN_IPV6_OK

          public static final short STATUS_IPV4_UNKNOWN_IPV6_OK

      We have an IPv6 transport enabled and a public IPv6 address. We may be able to receive unsolicited connections on IPv4. We can receive unsolicited connections on IPv6.
      See Also:
        Constant Field Values

    - #### STATUS_OK

          public static final short STATUS_OK

      These must be increasing in "badness" (see TransportManager.java), but UNKNOWN must be last. We are able to receive unsolicited connections on all enabled transports
      See Also:
        Constant Field Values

    - #### STATUS_REJECT_UNSOLICITED

          public static final short STATUS_REJECT_UNSOLICITED

      We are able to talk to peers that we initiate communication with, but cannot receive unsolicited connections, i.e. Firewalled, on all enabled transports.
      See Also:
        Constant Field Values

    - #### STATUS_UNKNOWN

          public static final short STATUS_UNKNOWN

      Our reachability is unknown on all
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CommSystemFacade

          public CommSystemFacade()

  - ### Method Detail

    - #### countActivePeers

          public abstract 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.

    - #### countActiveSendPeers

          public abstract 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.

    - #### createAddresses

          public List<RouterAddress> createAddresses()

      Create the list of RouterAddress structures based on the router's config

    - #### exemptIncoming

          public void exemptIncoming(Hash peer)

      Exempt this router hash from any incoming throttles or rejections

    - #### forceDisconnect

          public void forceDisconnect(Hash peer)

      Tell the comm system to disconnect from this peer.

    - #### getCanonicalHostName

          public String getCanonicalHostName(String ipAddress)

    - #### getCanonicalHostNameSync

          public String getCanonicalHostNameSync(String ipAddress)

    - #### getCountries

          public Map<String,String> getCountries()

      Get the country code map
      Returns:
        Map of two-letter lower case code to untranslated country name, unmodifiable

    - #### getCountry

          public String getCountry(Hash peer)

    - #### getCountry

          public String getCountry(String ip)

      Get country code for an IP address
      Parameters:
        `ip` - IP address string (IPv4 or IPv6)
      Returns:
        two-letter lower-case country code or null if not found

    - #### getCountryName

          public String getCountryName(String code)

    - #### getEstablished

          public abstract List<Hash> getEstablished()

      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.
      Returns:
        the hashes of all the routers we are connected to, non-null

    - #### getFramedAveragePeerClockSkew

          public long getFramedAveragePeerClockSkew(int percentToInclude)

      Return framed average clock skew of connected peers in seconds, or null if we cannot answer. CommSystemFacadeImpl overrides this.

    - #### getIP

          public byte[] getIP(Hash dest)

    - #### getLocalizedStatusString

          public String getLocalizedStatusString()

      getStatus().toStatusString(), translated if available.

    - #### getMedianPeerClockSkew

          public Long getMedianPeerClockSkew()

      Median clock skew of connected peers in seconds, or null if we cannot answer. CommSystemFacadeImpl overrides this.

    - #### getMostRecentErrorMessages

          public List<String> getMostRecentErrorMessages()

    - #### getOurCountry

          public String getOurCountry()

    - #### getStatus

          public CommSystemFacade.Status getStatus()

      Determine under what conditions we are remotely reachable.

    - #### getTransports

          public SortedMap<String,Transport> getTransports()

      Returns:
        SortedMap of style to Transport (a copy)

    - #### getXDHFactory

          public X25519KeyFactory getXDHFactory()

      Factory for making X25519 key pairs.

    - #### haveHighOutboundCapacity

          public boolean haveHighOutboundCapacity()

    - #### haveInboundCapacity

          public boolean haveInboundCapacity(int pct)

    - #### haveOutboundCapacity

          public boolean haveOutboundCapacity(int pct)

    - #### initGeoIP

          public void initGeoIP()

      Router must call after netdb is initialized

    - #### isBacklogged

          public boolean isBacklogged(Hash peer)

    - #### isDummy

          public boolean isDummy()

    - #### isEstablished

          public abstract boolean isEstablished(Hash peer)

    - #### isExemptIncoming

          public boolean isExemptIncoming(String ip)

      Is this IP exempt from any incoming throttles or rejections

    - #### isInStrictCountry

          public boolean isInStrictCountry()

    - #### isInStrictCountry

          public boolean isInStrictCountry(Hash peer)

    - #### isInStrictCountry

          public boolean isInStrictCountry(RouterInfo ri)

    - #### isRunning

          public boolean isRunning()

    - #### mayDisconnect

          public void mayDisconnect(Hash peer)

      Tell the comm system that we may disconnect from this peer. This is advisory only.

    - #### notifyRemoveAddress

          public void notifyRemoveAddress(boolean ipv6)

      Tell other transports our address changed

    - #### notifyRemoveAddress

          public void notifyRemoveAddress(RouterAddress address)

      Tell other transports our address changed

    - #### notifyReplaceAddress

          public void notifyReplaceAddress(RouterAddress address)

      Tell other transports our address changed

    - #### processMessage

          public abstract void processMessage(OutNetMessage msg)

    - #### queueLookup

          public void queueLookup(byte[] ip)

    - #### registerTransport

          public void registerTransport(Transport t)

      Pluggable transport

    - #### removeExemption

          public void removeExemption(String ip)

      Remove this IP from the exemptions

    - #### renderPeerCaps

          public String renderPeerCaps(Hash peer,
                                       boolean inline)

    - #### renderPeerFlag

          public String renderPeerFlag(Hash peer)

    - #### renderPeerHTML

          public String renderPeerHTML(Hash peer,
                                       boolean extended)

    - #### renderStatusHTML

          public void renderStatusHTML(Writer out)
                                throws IOException

      Specified by:
        `renderStatusHTML` in interface `Service`
      Throws:
        `IOException`

    - #### renderStatusHTML

          public void renderStatusHTML(Writer out,
                                       String urlBase,
                                       int sortFlags)
                                throws IOException

      Throws:
        `IOException`

    - #### unregisterTransport

          public void unregisterTransport(Transport t)

      Pluggable transport

    - #### wasUnreachable

          public boolean wasUnreachable(Hash peer)