Package net.i2p.router.transport
Class CommSystemFacadeImpl
- java.lang.Object
-
- net.i2p.router.CommSystemFacade
-
- 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
ROUTER_BUNDLE_NAME, 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
Constructors Constructor Description CommSystemFacadeImpl(RouterContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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 configvoid
forceDisconnect(Hash peer)
Tell the comm system to disconnect from this peer.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 nameDHSessionKeyBuilder.Factory
getDHFactory()
Hook for pluggable transport creation.Set<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 peer)
String
getLocalizedStatusString()
getStatus().toStatusString(), translated if available.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 initializedboolean
isBacklogged(Hash peer)
boolean
isDummy()
Is everything disabled for testing?boolean
isEstablished(Hash peer)
boolean
isInStrictCountry()
Are we in a strict countryboolean
isInStrictCountry(Hash peer)
Are they in a strict country.boolean
isInStrictCountry(RouterInfo ri)
Are they in a strict countryvoid
mayDisconnect(Hash peer)
Tell the comm system that we may disconnect from this peer.void
notifyRemoveAddress(boolean ipv6)
Tell other transports our address changedvoid
notifyRemoveAddress(RouterAddress address)
Tell other transports our address changedvoid
notifyReplaceAddress(RouterAddress udpAddr)
UDP changed addresses, tell NTCP and restart All the work moved to NTCPTransport.externalAddressReceived()void
processMessage(OutNetMessage msg)
Send the message outvoid
queueLookup(byte[] ip)
void
recheckReachability()
Deprecated.unusedvoid
registerTransport(Transport t)
Pluggable transports.String
renderPeerHTML(Hash peer)
Provide a consistent "look" for displaying router IDs in the consolevoid
renderStatusHTML(Writer out, String urlBase, int sortFlags)
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.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 peer)
-
Methods inherited from class net.i2p.router.CommSystemFacade
getMedianPeerClockSkew, getReachabilityStatus, renderStatusHTML
-
-
-
-
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.- Specified by:
countActivePeers
in classCommSystemFacade
-
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 classCommSystemFacade
-
haveInboundCapacity
public boolean haveInboundCapacity(int pct)
- Overrides:
haveInboundCapacity
in classCommSystemFacade
-
haveOutboundCapacity
public boolean haveOutboundCapacity(int pct)
- Overrides:
haveOutboundCapacity
in classCommSystemFacade
-
haveHighOutboundCapacity
public boolean haveHighOutboundCapacity()
- Overrides:
haveHighOutboundCapacity
in classCommSystemFacade
-
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 classCommSystemFacade
- 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 classCommSystemFacade
-
isBacklogged
public boolean isBacklogged(Hash peer)
- Overrides:
isBacklogged
in classCommSystemFacade
-
isEstablished
public boolean isEstablished(Hash peer)
- Specified by:
isEstablished
in classCommSystemFacade
-
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 classCommSystemFacade
- Returns:
- a new set, may be modified
- Since:
- 0.9.34
-
wasUnreachable
public boolean wasUnreachable(Hash peer)
- Overrides:
wasUnreachable
in classCommSystemFacade
-
getIP
public byte[] getIP(Hash peer)
- Overrides:
getIP
in classCommSystemFacade
-
mayDisconnect
public void mayDisconnect(Hash peer)
Tell the comm system that we may disconnect from this peer. This is advisory only.- Overrides:
mayDisconnect
in classCommSystemFacade
- Since:
- 0.9.24
-
forceDisconnect
public void forceDisconnect(Hash peer)
Tell the comm system to disconnect from this peer.- Overrides:
forceDisconnect
in classCommSystemFacade
- Since:
- 0.9.38
-
getMostRecentErrorMessages
public List<String> getMostRecentErrorMessages()
- Overrides:
getMostRecentErrorMessages
in classCommSystemFacade
-
getStatus
public CommSystemFacade.Status getStatus()
Description copied from class:CommSystemFacade
Determine under what conditions we are remotely reachable.- Overrides:
getStatus
in classCommSystemFacade
- Since:
- 0.9.20
-
getLocalizedStatusString
public String getLocalizedStatusString()
getStatus().toStatusString(), translated if available.- Overrides:
getLocalizedStatusString
in classCommSystemFacade
- Since:
- 0.9.45
-
recheckReachability
@Deprecated public void recheckReachability()
Deprecated.unused- Overrides:
recheckReachability
in classCommSystemFacade
-
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 classCommSystemFacade
- Throws:
IOException
-
getTransports
public SortedMap<String,Transport> getTransports()
- Overrides:
getTransports
in classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- Since:
- 0.9.16
-
getDHFactory
public DHSessionKeyBuilder.Factory getDHFactory()
Hook for pluggable transport creation.- Overrides:
getDHFactory
in classCommSystemFacade
- Since:
- 0.9.16
-
getXDHFactory
public X25519KeyFactory getXDHFactory()
Factory for making X25519 key pairs.- Overrides:
getXDHFactory
in classCommSystemFacade
- Since:
- 0.9.46
-
initGeoIP
public void initGeoIP()
Router must call after netdb is initialized- Overrides:
initGeoIP
in classCommSystemFacade
- Since:
- 0.9.41
-
queueLookup
public void queueLookup(byte[] ip)
- Overrides:
queueLookup
in classCommSystemFacade
- Parameters:
ip
- ipv4 or ipv6
-
getOurCountry
public String getOurCountry()
- Overrides:
getOurCountry
in classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
- Parameters:
peer
- non-null- Since:
- 0.9.16
-
isInStrictCountry
public boolean isInStrictCountry(RouterInfo ri)
Are they in a strict country- Overrides:
isInStrictCountry
in classCommSystemFacade
- 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 classCommSystemFacade
- 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 classCommSystemFacade
-
renderPeerHTML
public String renderPeerHTML(Hash peer)
Provide a consistent "look" for displaying router IDs in the console- Overrides:
renderPeerHTML
in classCommSystemFacade
-
isDummy
public boolean isDummy()
Is everything disabled for testing?- Overrides:
isDummy
in classCommSystemFacade
- Since:
- 0.8.13
-
-