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 String PROP_I2NP_NTCP_AUTO_IP
           
static String PROP_I2NP_NTCP_AUTO_PORT
           
static String PROP_I2NP_NTCP_HOSTNAME
           
static String PROP_I2NP_NTCP_PORT
           
 
Fields inherited from class net.i2p.router.CommSystemFacade
STATUS_DIFFERENT, STATUS_DISCONNECTED, STATUS_HOSED, STATUS_OK, STATUS_REJECT_UNSOLICITED, STATUS_UNKNOWN
 
Constructor Summary
CommSystemFacadeImpl(RouterContext context)
           
 
Method Summary
 int countActivePeers()
           
 int countActiveSendPeers()
           
 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)
           
 List<TransportBid> getBids(OutNetMessage msg)
           
 String getCountry(Hash peer)
          Uses the transport IP first because that lookup is fast, then the SSU IP from the netDb.
 String getCountryName(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)
           
 List getMostRecentErrorMessages()
           
 TransportBid getNextBid(OutNetMessage msg)
           
 String getOurCountry()
           
 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 isDummy()
           
 boolean isEstablished(Hash dest)
           
 boolean isInBadCountry()
          Are we in a bad place
 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()
           
 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.
 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 String PROP_I2NP_NTCP_HOSTNAME
See Also:
Constant Field Values

PROP_I2NP_NTCP_PORT

public static final String PROP_I2NP_NTCP_PORT
See Also:
Constant Field Values

PROP_I2NP_NTCP_AUTO_PORT

public static final String PROP_I2NP_NTCP_AUTO_PORT
See Also:
Constant Field Values

PROP_I2NP_NTCP_AUTO_IP

public static final 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()
Cannot be restarted.


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 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 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(Writer out,
                             String urlBase,
                             int sortFlags)
                      throws IOException
Overrides:
renderStatusHTML in class CommSystemFacade
Throws:
IOException

createAddresses

public 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
Returns:
non-null, possibly empty

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

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

getCountry

public 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 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()
Overrides:
isDummy in class CommSystemFacade
Since:
0.8.13