net.i2p.router.transport
Class CommSystemFacadeImpl

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

public class CommSystemFacadeImpl
extends CommSystemFacade


Nested Class Summary
 
Nested classes/interfaces inherited from class net.i2p.router.CommSystemFacade
CommSystemFacade.Status
 
Field Summary
 
Fields inherited from class net.i2p.router.CommSystemFacade
STATUS_DIFFERENT, STATUS_DISCONNECTED, STATUS_HOSED, STATUS_IPV4_DISABLED_IPV6_FIREWALLED, STATUS_IPV4_DISABLED_IPV6_OK, STATUS_IPV4_DISABLED_IPV6_UNKNOWN, STATUS_IPV4_FIREWALLED_IPV6_OK, STATUS_IPV4_FIREWALLED_IPV6_UNKNOWN, STATUS_IPV4_OK_IPV6_FIREWALLED, STATUS_IPV4_OK_IPV6_UNKNOWN, STATUS_IPV4_SNAT_IPV6_OK, STATUS_IPV4_SNAT_IPV6_UNKNOWN, STATUS_IPV4_UNKNOWN_IPV6_FIREWALLED, STATUS_IPV4_UNKNOWN_IPV6_OK, STATUS_OK, STATUS_REJECT_UNSOLICITED, STATUS_UNKNOWN
 
Constructor Summary
CommSystemFacadeImpl(RouterContext context)
           
 
Method Summary
 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.
 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
 String getCountry(Hash peer)
          Uses the transport IP first because that lookup is fast, then the IP from the netDb.
 String getCountryName(String c)
          full name for a country code, or the code if we don't know the name
 DHSessionKeyBuilder.Factory getDHFactory()
          Hook for pluggable transport creation.
 long getFramedAveragePeerClockSkew(int percentToInclude)
          Return framed average clock skew of connected peers in seconds, or null if we cannot answer.
 byte[] getIP(Hash dest)
           
 List<String> getMostRecentErrorMessages()
           
 String getOurCountry()
           
 CommSystemFacade.Status getStatus()
          Determine under what conditions we are remotely reachable.
 boolean haveHighOutboundCapacity()
           
 boolean haveInboundCapacity(int pct)
           
 boolean haveOutboundCapacity(int pct)
           
 boolean isBacklogged(Hash dest)
           
 boolean isDummy()
          Is everything disabled for testing?
 boolean isEstablished(Hash dest)
           
 boolean isInBadCountry()
          Are we in a bad place
 boolean isInBadCountry(Hash peer)
          Are they in a bad place
 boolean isInBadCountry(RouterInfo ri)
          Are they in a bad place
 void notifyRemoveAddress(boolean ipv6)
          Tell other transports our address changed
 void notifyRemoveAddress(RouterAddress address)
          Tell other transports our address changed
 void notifyReplaceAddress(RouterAddress udpAddr)
          UDP changed addresses, tell NTCP and restart All the work moved to NTCPTransport.externalAddressReceived()
 void processMessage(OutNetMessage msg)
          Send the message out
 void queueLookup(byte[] ip)
           
 void recheckReachability()
          Deprecated. unused
 void registerTransport(Transport t)
          Pluggable transports.
 String renderPeerHTML(Hash peer)
          Provide a consistent "look" for displaying router IDs in the console
 void renderStatusHTML(Writer out, String urlBase, int sortFlags)
           
 void restart()
          Perform a soft restart.
 void shutdown()
          Cannot be restarted after calling this.
 void startup()
          Instruct the service that it should start normal operation.
 void unregisterTransport(Transport t)
          Pluggable transports.
 boolean wasUnreachable(Hash dest)
           
 
Methods inherited from class net.i2p.router.CommSystemFacade
getMedianPeerClockSkew, getReachabilityStatus, renderStatusHTML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommSystemFacadeImpl

public CommSystemFacadeImpl(RouterContext context)
Method Detail

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.


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.

Overrides:
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.

Overrides:
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 Vectors to milliseconds

processMessage

public void processMessage(OutNetMessage msg)
Send the message out

Specified by:
processMessage in class CommSystemFacade

isBacklogged

public boolean isBacklogged(Hash dest)
Overrides:
isBacklogged in class CommSystemFacade

isEstablished

public boolean isEstablished(Hash dest)
Overrides:
isEstablished in class CommSystemFacade

wasUnreachable

public boolean wasUnreachable(Hash dest)
Overrides:
wasUnreachable in class CommSystemFacade

getIP

public byte[] getIP(Hash dest)
Overrides:
getIP in class CommSystemFacade

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

recheckReachability

public void recheckReachability()
Deprecated. unused

Overrides:
recheckReachability in class CommSystemFacade

renderStatusHTML

public void renderStatusHTML(Writer out,
                             String urlBase,
                             int sortFlags)
                      throws IOException
Overrides:
renderStatusHTML in class CommSystemFacade
Throws:
IOException

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 - non-null; but 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

queueLookup

public void queueLookup(byte[] ip)
Overrides:
queueLookup in class CommSystemFacade

getOurCountry

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

isInBadCountry

public boolean isInBadCountry()
Are we in a bad place

Overrides:
isInBadCountry in class CommSystemFacade
Since:
0.8.13

isInBadCountry

public boolean isInBadCountry(Hash peer)
Are they in a bad place

Overrides:
isInBadCountry in class CommSystemFacade
Parameters:
peer - non-null
Since:
0.9.16

isInBadCountry

public boolean isInBadCountry(RouterInfo ri)
Are they in a bad place

Overrides:
isInBadCountry 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.

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

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