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


Field Summary
static java.lang.String PROP_I2NP_NTCP_AUTO_IP
           
static java.lang.String PROP_I2NP_NTCP_AUTO_PORT
           
static java.lang.String PROP_I2NP_NTCP_HOSTNAME
           
static java.lang.String PROP_I2NP_NTCP_PORT
           
 
Fields inherited from class net.i2p.router.CommSystemFacade
STATUS_DIFFERENT, STATUS_HOSED, STATUS_OK, STATUS_REJECT_UNSOLICITED, STATUS_UNKNOWN
 
Constructor Summary
CommSystemFacadeImpl(RouterContext context)
           
 
Method Summary
 int countActivePeers()
           
 int countActiveSendPeers()
           
 java.util.Set<RouterAddress> createAddresses()
          Create the set of RouterAddress structures based on the router's config
static RouterAddress createNTCPAddress(RouterContext ctx)
          This only creates an address if the hostname AND port are set in router.config, which should be rare.
 TransportBid getBid(OutNetMessage msg)
           
 java.util.List<TransportBid> getBids(OutNetMessage msg)
           
 java.lang.String getCountry(Hash peer)
          Uses the transport IP first because that lookup is fast, then the SSU IP from the netDb.
 java.lang.String getCountryName(java.lang.String c)
          full name for a country code, or the code if we don't know the name
 long getFramedAveragePeerClockSkew(int percentToInclude)
          Return framed average clock skew of connected peers in seconds, or null if we cannot answer.
 byte[] getIP(Hash dest)
           
 java.util.List getMostRecentErrorMessages()
           
 TransportBid getNextBid(OutNetMessage msg)
           
 short getReachabilityStatus()
          Determine under what conditions we are remotely reachable.
(package private)  int getTransportCount()
           
 boolean haveHighOutboundCapacity()
           
 boolean haveInboundCapacity(int pct)
           
 boolean haveOutboundCapacity(int pct)
           
 boolean isBacklogged(Hash dest)
           
 boolean isEstablished(Hash dest)
           
 void notifyReplaceAddress(RouterAddress UDPAddr)
          UDP changed addresses, tell NTCP and restart This should really be moved to ntcp/NTCPTransport.java, why is it here?
 void processMessage(OutNetMessage msg)
          Send the message out
 void queueLookup(byte[] ip)
           
 void recheckReachability()
           
 java.lang.String renderPeerHTML(Hash peer)
          Provide a consistent "look" for displaying router IDs in the console
 void renderStatusHTML(java.io.Writer out, java.lang.String urlBase, int sortFlags)
           
 void restart()
          Perform a soft restart.
 void shutdown()
          Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully.
 void startup()
          Instruct the service that it should start normal operation.
 boolean wasUnreachable(Hash dest)
           
 
Methods inherited from class net.i2p.router.CommSystemFacade
getMedianPeerClockSkew, renderStatusHTML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_I2NP_NTCP_HOSTNAME

public static final java.lang.String PROP_I2NP_NTCP_HOSTNAME
See Also:
Constant Field Values

PROP_I2NP_NTCP_PORT

public static final java.lang.String PROP_I2NP_NTCP_PORT
See Also:
Constant Field Values

PROP_I2NP_NTCP_AUTO_PORT

public static final java.lang.String PROP_I2NP_NTCP_AUTO_PORT
See Also:
Constant Field Values

PROP_I2NP_NTCP_AUTO_IP

public static final java.lang.String PROP_I2NP_NTCP_AUTO_IP
See Also:
Constant Field Values
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()
Description copied from interface: Service
Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully. It should not depend on other components at this point. This call DOES block.


restart

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


countActivePeers

public int countActivePeers()
Overrides:
countActivePeers in class CommSystemFacade

countActiveSendPeers

public int countActiveSendPeers()
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. Todo: change Vectors to milliseconds

getBids

public java.util.List<TransportBid> getBids(OutNetMessage msg)

getBid

public TransportBid getBid(OutNetMessage msg)

getNextBid

public TransportBid getNextBid(OutNetMessage msg)

getTransportCount

int getTransportCount()

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 java.util.List getMostRecentErrorMessages()
Overrides:
getMostRecentErrorMessages in class CommSystemFacade

getReachabilityStatus

public short getReachabilityStatus()
Description copied from class: CommSystemFacade
Determine under what conditions we are remotely reachable.

Overrides:
getReachabilityStatus in class CommSystemFacade

recheckReachability

public void recheckReachability()
Overrides:
recheckReachability in class CommSystemFacade

renderStatusHTML

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

createAddresses

public java.util.Set<RouterAddress> createAddresses()
Description copied from class: CommSystemFacade
Create the set of RouterAddress structures based on the router's config

Overrides:
createAddresses in class CommSystemFacade

createNTCPAddress

public static RouterAddress createNTCPAddress(RouterContext ctx)
This only creates an address if the hostname AND port are set in router.config, which should be rare. Otherwise, notifyReplaceAddress() below takes care of it. Note this is called both from above and from NTCPTransport.startListening() This should really be moved to ntcp/NTCPTransport.java, why is it here?


notifyReplaceAddress

public void notifyReplaceAddress(RouterAddress UDPAddr)
UDP changed addresses, tell NTCP and restart This should really be moved to ntcp/NTCPTransport.java, why is it here?

Overrides:
notifyReplaceAddress in class CommSystemFacade

queueLookup

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

getCountry

public java.lang.String getCountry(Hash peer)
Uses the transport IP first because that lookup is fast, then the SSU IP from the netDb.

Overrides:
getCountry in class CommSystemFacade
Returns:
two-letter lower-case country code or null

getCountryName

public java.lang.String getCountryName(java.lang.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 java.lang.String renderPeerHTML(Hash peer)
Provide a consistent "look" for displaying router IDs in the console

Overrides:
renderPeerHTML in class CommSystemFacade