java.lang.Object
net.i2p.router.CommSystemFacade
net.i2p.router.dummy.VMCommSystem
- All Implemented Interfaces:
Service
Hacked up in-VM comm system for talking between contexts within the same Java virtual machine. It doesn't generate any routerAddresses, but instead tracks the peers through a singleton. It cannot connect to anything outside of its own Java VM. It does not implement TCP, UDP, and therefore no NTCP or SSU. Currently, the comm system doesn't even inject any lag, though it could (later). It does honor the standard transport stats though, but no TCP or UDP specific ones (since UDP and TCP are not implemented).
Typically, VMCommSystem is enabled by developers when it is desirable to test the router without enabling a real comm system. For a variety of testing purposes, it can be advantageous to start the router in a mode where contact with the actual network is disabled.
VMCommSystem can be enabled with the following setting in the router.config file:
i2p.vmCommSystem=true
FOR DEBUGGING AND LOCAL TESTING ONLY.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classDelivers a message received from another router.Nested classes/interfaces inherited from class CommSystemFacade
CommSystemFacade.StatusModifier and TypeClassDescriptionstatic enumNetwork connectivity status enumeration for IPv4 and IPv6 transport capabilities.Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map<Hash, VMCommSystem> Mapping from Hash to VMCommSystem for all routers hooked together.private final RouterContextThe router this transport serves.private final LogLogger for this class.private final X25519KeyFactoryXDH factory kept for the tests.Fields inherited from class 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_UNKNOWNModifier and TypeFieldDescriptionprotected static final StringBundle holding the translatable messages this subsystem logs.static final shortWe are behind a symmetric NAT which will make our 'from' address look differently when we talk to multiple people.static final shortWe have no network interface at all enabled transports.static final shortOur detection system is broken (SSU bind port failed).static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe 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 final shortWe 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 final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortWe have an IPv6 transport enabled and a public IPv6 address.static final shortThese must be increasing in "badness" (see TransportManager.java), but UNKNOWN must be last.static final shortWe are able to talk to peers that we initiate communication with, but cannot receive unsolicited connections, i.e.static final shortOur reachability is unknown on all.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionintReturn the count of active peers.intReturn the count of active send peers.booleanNo transports, so no IPs to reverse-resolve.Return the established.Factory for making X25519 key pairs.booleanisEstablished(Hash peer) Return whether established.voidThe router wants us to send the given message to the peer.voidWe send messages between comms as bytes so that we strip any router-local info.voidrenderStatusHTML(Writer out, String urlBase, int sortFlags) Render the transport status section of the router console page.voidrestart()Restart the service.voidshutdown()Shut down and release resources.voidstartup()Start up and initialize.booleanwasFailsafeClosed(Hash peer, long withinMs) Always false, the VM transport never disconnects.Methods inherited from class CommSystemFacade
createAddresses, exemptIncoming, forceDisconnect, forceDisconnect, getCanonicalHostName, getCanonicalHostNameSync, getCountries, getCountry, getCountry, getCountryName, getFramedAveragePeerClockSkew, getIP, getLocalHostName, getLocalizedStatusString, getMedianPeerClockSkew, getMostRecentErrorMessages, getOurCountry, getStatus, getTransports, haveHighOutboundCapacity, haveInboundCapacity, haveOutboundCapacity, initGeoIP, isBacklogged, isConnecting, isDummy, isExemptIncoming, isInStrictCountry, isInStrictCountry, isInStrictCountry, isRunning, mayDisconnect, notifyRemoveAddress, notifyRemoveAddress, notifyReplaceAddress, queueLookup, registerTransport, removeExemption, renderPeerCaps, renderPeerFlag, renderPeerHTML, renderStatusHTML, unregisterTransport, wasUnreachableModifier and TypeMethodDescriptionCreate the list of RouterAddress structures based on the router's config.voidexemptIncoming(Hash peer) Exempt this router hash from any incoming throttles or rejections.voidforceDisconnect(Hash peer) Tell the comm system to disconnect from this peer.voidforceDisconnect(Hash peer, String reason) Tell the comm system to disconnect from this peer with a reason.getCanonicalHostName(String ipAddress) Look up the canonical hostname for the given IP, blocking on DNS if necessary.getCanonicalHostNameSync(String ipAddress) Synchronous canonical hostname lookup for the given IP.The map of all country codes.getCountry(String ip) Get the two-letter country code for the given IP address.getCountry(Hash peer) Get the two-letter country code for the given peer's IP address.getCountryName(String code) Resolve a two-letter country code to its full country name.longgetFramedAveragePeerClockSkew(int percentToInclude) Return framed average clock skew of connected peers in seconds, or null if we cannot answer.byte[]Get the IP address associated with the given destination.getLocalHostName(String ipAddress) Fast hostname lookup that never blocks on network DNS.Localized reachability status string.Median clock skew of connected peers in seconds, or null if we cannot answer.Retrieve recent transport-related error messages for display in the console.Our two-letter country code determined from our external IP.Determine under what conditions we are remotely reachable.Registered transports by style name.booleanReport whether outbound bandwidth is operating well below its limit.booleanhaveInboundCapacity(int pct) Report whether inbound bandwidth has capacity for the given percentage load.booleanhaveOutboundCapacity(int pct) Report whether outbound bandwidth has capacity for the given percentage load.voidRouter must call after netdb is initialized.booleanisBacklogged(Hash peer) Check whether the given peer has excessive pending outbound messages.booleanisConnecting(Hash peer) Check if any transport has a connection attempt in progress for the given peer (handshake started but not yet complete).booleanisDummy()Whether this is a dummy implementation with no real transports.booleanIs this IP exempt from any incoming throttles or rejections.booleanWhether country blocking is enabled at all.booleanisInStrictCountry(Hash peer) Whether the given peer's country is blocked.booleanWhether the given router's country is blocked.booleanWhether the comm system is fully initialized and running.voidmayDisconnect(Hash peer) Tell the comm system that we may disconnect from this peer.voidnotifyRemoveAddress(boolean ipv6) Tell other transports our address changed.voidnotifyRemoveAddress(RouterAddress address) Tell other transports our address changed.voidnotifyReplaceAddress(RouterAddress address) Tell other transports our address changed.voidqueueLookup(byte[] ip) Queue a reverse-DNS lookup for the given IP address.voidRegister a transport for use by the comm system.voidRemove this IP from the exemptions.renderPeerCaps(Hash peer, boolean inline) Render the peer's capabilities as HTML, optionally inline.renderPeerFlag(Hash peer) Render the country flag for the given peer as HTML.renderPeerHTML(Hash peer, boolean extended) Render an HTML snippet identifying the given peer, optionally with extended details.voidrenderStatusHTML(Writer out) Render the transport status section of the router console page with default flags.voidUnregister a transport from the comm system.booleanwasUnreachable(Hash peer) Check whether the given peer was recently unreachable.
Field Details
_log
Logger for this class._context
The router this transport serves._xdhThread
XDH factory kept for the tests._commSystemFacades
Mapping from Hash to VMCommSystem for all routers hooked together.
Constructor Details
VMCommSystem
Create a comm system.- Parameters:
context- the router context
Method Details
getXDHFactory
Factory for making X25519 key pairs.- Overrides:
getXDHFactoryin classCommSystemFacade- Returns:
- the XDHE factory
countActivePeers
public int countActivePeers()Return the count of active peers.- Specified by:
countActivePeersin classCommSystemFacade- Returns:
- the number of active peers
countActiveSendPeers
public int countActiveSendPeers()Return the count of active send peers.- Specified by:
countActiveSendPeersin classCommSystemFacade- Returns:
- the number of peers in the map other than this router
isEstablished
Return whether established.- Specified by:
isEstablishedin classCommSystemFacade- Parameters:
peer- the router to test, identified by its router identity hash- Returns:
- true if a connection is established
wasFailsafeClosed
Always false, the VM transport never disconnects.- Specified by:
wasFailsafeClosedin classCommSystemFacade- Parameters:
peer- the peer to ask about, non-nullwithinMs- how far back counts as recent in ms; non-positive means nothing is recent- Returns:
- true when some transport closed a session to the peer that recently
getEstablished
Return the established.- Specified by:
getEstablishedin classCommSystemFacade- Returns:
- the hashes of all the routers we are connected to, non-null
processMessage
The router wants us to send the given message to the peer. Do so, or fire off the failing job.- Specified by:
processMessagein classCommSystemFacade- Parameters:
msg- the message to send
receive
We send messages between comms as bytes so that we strip any router-local info. For example, a router tags the # attempts to send through a leaseSet, what type of tunnel a tunnelId is bound to, etc.- Parameters:
message- the serialized I2NP message bytes to hand to the receive jobfromPeer- the hash of the peer the bytes came from, used for profile accounting
shutdown
public void shutdown()Shut down and release resources.startup
public void startup()Start up and initialize.restart
public void restart()Restart the service.renderStatusHTML
Description copied from class:CommSystemFacadeRender the transport status section of the router console page.- Overrides:
renderStatusHTMLin classCommSystemFacade- Parameters:
out- receives the HTML for this transport's status sectionurlBase- base URL for links, may be nullsortFlags- flags controlling sort order- Throws:
IOException- on write error
enableReverseLookups
public boolean enableReverseLookups()No transports, so no IPs to reverse-resolve.- Specified by:
enableReverseLookupsin classCommSystemFacade- Returns:
- true if reverse lookups are enabled