- All Implemented Interfaces:
Transport
- Direct Known Subclasses:
NTCPTransport, UDPTransport
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classCompare based on published cost, adjusting for our IPv6 preference.private classTimer clearing the unreachable entries.Nested classes/interfaces inherited from interface Transport
Transport.AddressSourceModifier and TypeInterfaceDescriptionstatic enumSource of transport address configuration.Field Summary
Modifier and TypeFieldDescriptionprivate TransportImpl.CleanupUnreachableTimer clearing the unreachable entries.protected final RouterContextThe router context, which every subclass reads its configuration from.private final List<RouterAddress> The addresses currently published.private byte[]IP of the current IPv4 address, or null.Global router ident -> IP map.private HashThe last peer checked for reachability, a one-entry cache.private longWhen the pool statistics were last logged.private TransportEventListenerListener notified of the transport events.private final Set<InetAddress> Our local addresses, for loopback checks.private final LogLogger for the transport.private PrioritySendPoolPool of the messages waiting to be sent, used by NTCP only, see send() below.private intMessages dropped from the pool last pass.private intMessages evicted from the pool last pass.Map from routerIdentHash to timestamp (Long) when the peer was last unreachable.Peers recently marked unreachable, by hash.protected static final booleanDo we increase the advertised cost when approaching conn limits?private static final StringName of the failed send callback.private static final StringTimestamp labels forafterSend(OutNetMessage, boolean, boolean, long), constants so neither costs an allocation.private static final StringBundle holding the translated console strings.static final StringAdvertised reachability value for a working IPv4 address.static final StringAdvertised reachability value for both address families.static final StringAdvertised reachability value for a working IPv6 address.protected static final intAdjustment factor for congestion cost.private static final intDefault share of our capacity we offer.private static final int50/100/150/250/450/550/700 for BW Tiers K/L/M/N/O/P/X.protected static final StringProperty allowing a transport to lift its connection limit.protected static final StringProperty recording the result of the last IPv6 firewall test.private static final long[]Rate stat periods for the transport statistics.private static intMessages the send pool holds, sized in the constructor.private final longTime a peer counts as unreachable.private final longTime the unreachable mark is remembered.Fields inherited from interface Transport
DEFAULT_SOURCES, PROP_EXTERNAL_HOST, PROP_EXTERNAL_PORT, PROP_FIXED_PORT, PROP_FORCE_INTRODUCERS, PROP_I2NP_NTCP_AUTO_IP, PROP_I2NP_NTCP_AUTO_PORT, PROP_I2NP_NTCP_HOSTNAME, PROP_I2NP_NTCP_PORT, PROP_INTERNAL_PORT, PROP_INTRO_KEY, PROP_IP, PROP_IPV6, PROP_LAPTOP_MODE, PROP_NTCP2_IV, PROP_NTCP2_SP, PROP_SOURCES, PROP_SSU2_IKEY, PROP_SSU2_SP, RTT_TIME_CURRENT, RTT_TIME_UNKNOWN, STYLE_NTCP, STYLE_NTCP2, STYLE_SSU, STYLE_SSU2Modifier and TypeFieldDescriptionstatic final StringDefault value ofTransport.PROP_SOURCES: the local interface, UPnP, and SSU-learned addresses.static final StringConfig key to force advertising a fixed external IP address.static final StringConfig key to force advertising a fixed external port.static final StringConfig key to keep the SSU advertised port fixed regardless of peer feedback.static final StringConfig key to require SSU introducers regardless of our reachability status.static final StringConfig key controlling whether NTCP may auto-update its advertised IP based on peer feedback.static final StringConfig key controlling whether NTCP may auto-update its advertised port based on peer feedback.static final StringConfig key for an explicitly configured hostname the NTCP transport advertises.static final StringConfig key for the port the NTCP transport listens for inbound connections on.static final StringConfig key for the SSU internal port, the port the SSU transport binds.static final StringConfig key for the SSU introducer key published in hidden-mode RouterInfos.static final StringConfig key remembering the last IPv4 address so IP changes can be detected across restarts.static final StringConfig key remembering the last IPv6 address.static final StringConfig key enabling laptop power-saving mode, which reduces connection activity.static final StringConfig key for the NTCP2 static IV.static final StringConfig key for the NTCP2 static private key.static final StringConfig key naming the allowed sources of address updates, e.g.static final StringConfig key for the SSU2 static IV.static final StringConfig key for the SSU2 static private key.static final longSentinel forTransport.getEstimatedRTTTime(Hash)meaning the transport's reading is refreshed by live traffic and is never out of date.static final longSentinel forTransport.getEstimatedRTTTime(Hash)meaning the transport does not record when it measured.static final StringStyle identifier for the NTCP transport, used inRouterAddressstyle tags, transport map keys, and style comparisons.static final StringStyle identifier for the NTCP2 protocol variant of the NTCP transport.static final StringStyle identifier for the SSU transport, used in RouterAddress style tags, transport map keys, and style comparisons.static final StringStyle identifier for the SSU2 protocol variant of the SSU transport.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprotected StringLooks the string up in the web messages bundle, returning s itself if there is no translation.protected StringTranslate and substitute one parameter.private voidaddJobIfPresent(Job job) Runs the job if the context has a job queue.protected voidafterSend(OutNetMessage msg, boolean sendSuccessful) The transport is done sending this message.protected voidafterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue) The transport is done sending this message.protected voidafterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend) The transport is done sending this message.protected voidafterSend(OutNetMessage msg, boolean sendSuccessful, long msToSend) The transport is done sending this message.booleanAre we allowed to connect to local addresses?(package private) static voidDrop the cached router-hash to IP mapping, so the next lookup reads it again from the network database.abstract intHow many peers are we currently connected to, that we have sent a message to or received a message from in the last five minutes.abstract intHow many peers are we connected to?abstract voidexternalAddressReceived(Transport.AddressSource source, byte[] ip, int port) Notify a transport of an external address change.voidexternalAddressRemoved(Transport.AddressSource source, boolean ipv6) Notify a transport of an external address change.static StringformatIPPort(byte[] ip, int port) Format an IP byte array (4 or 16 bytes) as host:port, for logging.voidforwardPortStatus(byte[] ip, int port, int externalPort, boolean success, String reason) Notify a transport of the results of trying to forward a port.An alternate supported style, or null.Peer clock skews on a transport.The context this transport runs in.getCurrentAddress(boolean ipv6) What address are we currently listening to? Replaces getCurrentAddress()What addresses are we currently listening to? ReplacesgetCurrentAddress(boolean).protected byte[]IP of the current IPv4 address, from the cache maintained by the address mutators.static byte[]IP of the peer from the last connection (in or out, any transport).The IPv6 configuration for this transport.intPer-transport connection limit.Recent error messages from this transport.protected OutNetMessageNonblocking call to pull the next outbound message off the queue.abstract CommSystemFacade.StatusPreviously returned short, now enum as of 0.9.20.intWhat INTERNAL port would the transport like to have forwarded by UPnP.static StringgetRouterIPPort(RouterInfo router) Best IP:port for a router, for ban logging: the direct connection IP from the transport layer, else a compatible address, else any announced address.protected Collection<InetAddress> Return and then clear all saved local addresses.The send pool instance, for stat access.static intCapacity of the NTCP send pool.getTargetAddresses(RouterInfo target) All available addresses we can use, shuffled and then sorted by cost/preference.static intgetTransportMaxConnections(RouterContext ctx, String style) The transport max connections for the given context and style.booleanDo we have any current address?booleanCan we initiate or accept a connection to another peer, saving some margin.booleanhaveCapacity(int pct) Whether we are under the given capacity level.booleanisBacklogged(Hash peer) Whether the given peer is backlogged.booleanisConnecting(Hash peer) Check if a connection attempt is in progress for the given peer.booleanisCurrentIPv4(byte[] ip) Is the given IP the current external IPv4 address?booleanisEstablished(Hash peer) Whether the given peer is established.booleanThis returns true if the force-firewalled setting is configured, false otherwise.booleanThis returns true if the force-firewalled setting is configured, false otherwise.protected booleanisPubliclyRoutable(byte[] addr) Allows IPv6 only if the transport is configured for it.booleanisUnreachable(Hash peer) Whether the given peer is unreachable.voidmarkReachable(Hash peer, boolean isInbound) Called when we establish a peer connection (outbound or inbound).voidmarkUnreachable(Hash peer) Called when we can't reach a peer.private voidmarkWasUnreachable(Hash peer, boolean yes) Maintain the WasUnreachable list.voidmayDisconnect(Hash peer) Tell the transport that we may disconnect from this peer.voidmessageReceived(I2NPMessage inMsg, RouterIdentity remoteIdent, Hash remoteIdentHash, long msToReceive, int bytesReceived) Message received from the I2NPMessageReader - send it to the listener.protected StringTranslate, choosing between the singular and the plural form.protected abstract voidThis message is called whenever a new message is added to the send pool, and it should not blockprivate voidRecompute the cached IPv4 address.protected voidremoveAddress(boolean ipv6) Remove all existing addresses with the specified IP length (4 or 16).protected voidremoveAddress(RouterAddress address) Remove only this address.voidrenderStatusHTML(Writer out) Make this stuff pretty.voidrenderStatusHTML(Writer out, String urlBase, int sortFlags) Render the transport status HTML to the given writer.protected voidreplaceAddress(RouterAddress address) Replace any existing addresses for the current transport with the same IP length (4 or 16) with the given one.voidResize the NTCP send pool if needed.protected voidsaveLocalAddress(InetAddress address) Save a local address we were notified about before we started.voidsend(OutNetMessage msg) Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector).static intThe largest capacitysetSendPoolCapacity(int)accepts.static intThe smallest capacitysetSendPoolCapacity(int)accepts.voidIP of the peer from the last connection (in or out, any transport).voidsetListener(TransportEventListener listener) Who to notify on message availability.static voidsetSendPoolCapacity(int capacity) The NTCP send pool capacity (called by Tuner).voidCancel the unreachable-entry cleanup, if one is scheduled.private voidDrops a message from the send queue.Ask the transport to update its address based on current information and return it Transports should override.booleanwasFailsafeClosed(Hash peer, long withinMs) Whether this transport closed a session to the peer for idleness recently.booleanwasUnreachable(Hash peer) Was the peer unreachable (outbound only) the last time we tried it? This is NOT reset if the peer contacts us.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Transport
bid, countActiveSendPeers, forceDisconnect, forceDisconnect, getEstablished, getEstimatedRTT, getEstimatedRTTTime, getPeerCounts, getStyle, startListening, stopListeningModifier and TypeMethodDescriptionbid(RouterInfo toAddress, int dataSize) Request to send a message to the specified router.intNumber of active send peers.voidforceDisconnect(Hash peer) Force immediate disconnection from specified peer.voidforceDisconnect(Hash peer, String reason) Forcefully disconnect from a peer with a reason for logging.The list of peers this transport has established connections with.default intgetEstimatedRTT(Hash peer) The transport's own measured round trip time to a peer.default longgetEstimatedRTTTime(Hash peer) WhenTransport.getEstimatedRTT(Hash)last measured this peer, on the router clock.int[]Detailed peer count statistics by IP version and direction.getStyle()The unique style identifier for this transport.voidStart accepting connections.voidStop accepting connections.
Field Details
AFTER_SEND_SUCCESSFUL
Timestamp labels forafterSend(OutNetMessage, boolean, boolean, long), constants so neither costs an allocation.- See Also:
AFTER_SEND_FAILED
Name of the failed send callback.- See Also:
_log
Logger for the transport._listener
Listener notified of the transport events._currentAddresses
The addresses currently published._currentIPv4
private volatile byte[] _currentIPv4IP of the current IPv4 address, or null. Maintained by every mutation of _currentAddresses so the per-packet "is this us?" check need not take that list's monitor. Cloned on read and on write, so no array escapes._sendPool
Pool of the messages waiting to be sent, used by NTCP only, see send() below._context
The router context, which every subclass reads its configuration from._unreachableEntries
_wasUnreachableEntries
_lastReachablePeer
The last peer checked for reachability, a one-entry cache._localAddresses
Our local addresses, for loopback checks._sendPoolEvictedLast
private volatile int _sendPoolEvictedLastMessages evicted from the pool last pass._sendPoolDroppedLast
private volatile int _sendPoolDroppedLastMessages dropped from the pool last pass._lastSendPoolStatTime
private long _lastSendPoolStatTimeWhen the pool statistics were last logged._IPMap
UNREACHABLE_PERIOD
private final long UNREACHABLE_PERIODTime a peer counts as unreachable.WAS_UNREACHABLE_PERIOD
private final long WAS_UNREACHABLE_PERIODTime the unreachable mark is remembered._cleanupJob
Timer clearing the unreachable entries.CAP_IPV4
Advertised reachability value for a working IPv4 address. @since 0.9.50.- See Also:
CAP_IPV6
Advertised reachability value for a working IPv6 address. @since 0.9.50.- See Also:
CAP_IPV4_IPV6
Advertised reachability value for both address families. @since 0.9.50.- See Also:
PROP_IPV6_FIREWALLED
Property recording the result of the last IPv6 firewall test.- See Also:
PROP_BOOST_CONNECTION_LIMITS
Property allowing a transport to lift its connection limit.- See Also:
RATES
private static final long[] RATESRate stat periods for the transport statistics.MAX_CONNECTION_FACTOR
private static final int MAX_CONNECTION_FACTOR50/100/150/250/450/550/700 for BW Tiers K/L/M/N/O/P/X.- See Also:
SEND_POOL_CAPACITY
private static volatile int SEND_POOL_CAPACITYMessages the send pool holds, sized in the constructor.DEFAULT_CAPACITY_PCT
private static final int DEFAULT_CAPACITY_PCTDefault share of our capacity we offer.- See Also:
ADJUST_COST
protected static final boolean ADJUST_COSTDo we increase the advertised cost when approaching conn limits?- See Also:
CONGESTION_COST_ADJUSTMENT
protected static final int CONGESTION_COST_ADJUSTMENTAdjustment factor for congestion cost.- See Also:
BUNDLE_NAME
Bundle holding the translated console strings.- See Also:
Constructor Details
TransportImpl
Initialize the new transport.- Parameters:
context- the router context supplying the log, statistics and comm system
Method Details
getSendPoolCapacity
public static int getSendPoolCapacity()Capacity of the NTCP send pool.- Returns:
- the messages the pool holds
getSendPool
The send pool instance, for stat access.- Returns:
- the pool, null if this is not NTCP
setSendPoolCapacity
public static void setSendPoolCapacity(int capacity) The NTCP send pool capacity (called by Tuner). Resizes the pool on NTCP transports, draining old messages.- Parameters:
capacity- the number of messages the pool should hold
sendPoolCapacityMin
public static int sendPoolCapacityMin()The smallest capacitysetSendPoolCapacity(int)accepts.- Returns:
- half the platform default, in queued messages
sendPoolCapacityMax
public static int sendPoolCapacityMax()The largest capacitysetSendPoolCapacity(int)accepts.Public because the auto-tuner declares a range for this pool and must not propose a value the setter silently rewrites back — that reads as a param that will not take effect.
- Returns:
- the core-scaled ceiling, in queued messages
resizeSendPool
public void resizeSendPool()Resize the NTCP send pool if needed. Creates a new pool with the current capacity and drains old messages into it.countPeers
public abstract int countPeers()How many peers are we connected to?- Specified by:
countPeersin interfaceTransport- Returns:
- the number of peers this transport knows of, established or not
countActivePeers
public abstract 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:
countActivePeersin interfaceTransport- Returns:
- the number of such peers
getMaxConnections
public int getMaxConnections()Per-transport connection limit.- Returns:
- the maximum concurrent peer connections for this transport, 0 when the comm system is a test dummy
getContext
getTransportMaxConnections
The transport max connections for the given context and style.- Parameters:
ctx- the router context to read the configuration fromstyle- the transport style, e.g. "SSU" or "NTCP"- Returns:
- the transport max connections, 0 when the comm system is a test dummy
haveCapacity
public boolean haveCapacity()Can we initiate or accept a connection to another peer, saving some margin.- Specified by:
haveCapacityin interfaceTransport- Returns:
- true if capacity available
haveCapacity
public boolean haveCapacity(int pct) Whether we are under the given capacity level.- Specified by:
haveCapacityin interfaceTransport- Parameters:
pct- are we under x% 0-100- Returns:
- true if capacity available
getClockSkews
Peer clock skews on a transport. List composed of Long, each element representing a peer skew in seconds. Dummy version. Transports override it.- Specified by:
getClockSkewsin interfaceTransport- Returns:
- the clock skews
getMostRecentErrorMessages
Recent error messages from this transport.- Specified by:
getMostRecentErrorMessagesin interfaceTransport- Returns:
- the messages, empty if there are none
getNextMessage
Nonblocking call to pull the next outbound message off the queue.Only used by NTCP. SSU does not call.
- Returns:
- the next highest-priority message or null if none available
afterSend
The transport is done sending this message.- Parameters:
msg- message in questionsendSuccessful- true if the peer received it
afterSend
The transport is done sending this message.- Parameters:
msg- message in questionsendSuccessful- true if the peer received itallowRequeue- true if we should try other transports if available
afterSend
The transport is done sending this message.- Parameters:
msg- message in questionsendSuccessful- true if the peer received itmsToSend- how long it took to transfer the data to the peer
afterSend
protected void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend) The transport is done sending this message. This is the method that actually does all of the cleanup - firing off jobs, requeueing, updating stats, etc.- Parameters:
msg- message in questionsendSuccessful- true if the peer received itallowRequeue- true if we should try other transports if availablemsToSend- how long it took to transfer the data to the peer
addJobIfPresent
Runs the job if the context has a job queue.- Parameters:
job- the job to run
unregisterAndDiscard
Drops a message from the send queue.- Parameters:
msg- the message to discard
send
Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector). If the send fails, queue up any msg.getOnFailedSendJobOnly used by NTCP. SSU overrides.
Non-blocking: uses priority eviction when the pool is full. Higher-priority messages (client data) evict lower-priority (transit).
outboundMessageReady
protected abstract void outboundMessageReady()This message is called whenever a new message is added to the send pool, and it should not blockOnly used by NTCP. SSU throws UOE.
messageReceived
public void messageReceived(I2NPMessage inMsg, RouterIdentity remoteIdent, Hash remoteIdentHash, long msToReceive, int bytesReceived) Message received from the I2NPMessageReader - send it to the listener.- Parameters:
inMsg- non-nullremoteIdent- may be nullremoteIdentHash- may be null, calculated from remoteIdent if nullmsToReceive- milliseconds the read took, for the debug logbytesReceived- how many bytes of the message arrived, for the debug log
getCurrentAddresses
What addresses are we currently listening to? ReplacesgetCurrentAddress(boolean).- Specified by:
getCurrentAddressesin interfaceTransport- Returns:
- a copy of all addresses, non-null
getCurrentAddress
What address are we currently listening to? Replaces getCurrentAddress()Note: An address without a host is considered IPv4.
- Specified by:
getCurrentAddressin interfaceTransport- Parameters:
ipv6- true for IPv6 only; false for IPv4 only- Returns:
- first matching address or null
refreshCurrentIPv4
private void refreshCurrentIPv4()Recompute the cached IPv4 address. Must be called with _currentAddresses held, after every change to the list, so thatisCurrentIPv4(byte[])tracks exactly what getCurrentAddress(false) would return. Clones the IP so later mutation of the RouterAddress cannot be seen through the cache.isCurrentIPv4
public boolean isCurrentIPv4(byte[] ip) Is the given IP the current external IPv4 address?Equivalent to comparing against
getCurrentAddress(boolean)with ipv6 false, but without taking the address-list monitor. For the hot inbound path (per-packet "did this come from us?" check).- Parameters:
ip- the IP to test, may be null- Returns:
- true if we currently have an IPv4 address equal to ip
getCurrentIPv4
protected byte[] getCurrentIPv4()IP of the current IPv4 address, from the cache maintained by the address mutators. Does not take the address-list monitor.- Returns:
- a copy of the IP, or null if we have no IPv4 address
hasCurrentAddress
public boolean hasCurrentAddress()Do we have any current address?- Specified by:
hasCurrentAddressin interfaceTransport- Returns:
- whether current address is present
updateAddress
Ask the transport to update its address based on current information and return it Transports should override.- Specified by:
updateAddressin interfaceTransport- Returns:
- a copy of all addresses, non-null
replaceAddress
Replace any existing addresses for the current transport with the same IP length (4 or 16) with the given one. Note: Does not currently allow multiple addresses of the same length. Calls listener.transportAddressChanged() To remove all IPv4 or IPv6 addresses, use removeAddress(boolean).- Parameters:
address- null to remove all
removeAddress
Remove only this address. Calls listener.transportAddressChanged(). To remove all IPv4 or IPv6 addresses, use removeAddress(boolean). To remove all IPv4 and IPv6 addresses, use replaceAddress(null).- Parameters:
address- the address to remove from the transport's advertised list
removeAddress
protected void removeAddress(boolean ipv6) Remove all existing addresses with the specified IP length (4 or 16). Calls listener.transportAddressChanged(). To remove all IPv4 and IPv6 addresses, use replaceAddress(null).- Parameters:
ipv6- true to remove all IPv6 addresses, false to remove all IPv4 addresses
saveLocalAddress
Save a local address we were notified about before we started.- Parameters:
address- the local address we were notified about
getSavedLocalAddresses
Return and then clear all saved local addresses.- Returns:
- the saved local addresses
getTargetAddresses
All available addresses we can use, shuffled and then sorted by cost/preference. Lowest cost (most preferred) first.- Parameters:
target- the RouterInfo whose addresses are wanted- Returns:
- non-null, possibly empty
externalAddressReceived
Notify a transport of an external address change. This may be from a local interface, UPnP, a config change, etc. This should not be called if the ip didn't change (from that source's point of view), or is a local address. May be called multiple times for IPv4 or IPv6. The transport should also do its own checking on whether to accept notifications from this source.This can be called before startListening() to set an initial address, or after the transport is running.
- Specified by:
externalAddressReceivedin interfaceTransport- Parameters:
source- defined in Transport.javaip- typ. IPv4 or IPv6 non-local; may be null to indicate IPv4 failure or port info onlyport- 0 for unknown or unchanged
externalAddressRemoved
Notify a transport of an external address change. This may be from a local interface, UPnP, a config change, etc. This should not be called if the ip didn't change (from that source's point of view), or is a local address. May be called multiple times for IPv4 or IPv6. The transport should also do its own checking on whether to accept notifications from this source.This can be called after the transport is running.
This implementation does nothing. Transports should override if they want notification.
- Specified by:
externalAddressRemovedin interfaceTransport- Parameters:
source- defined in Transport.javaipv6- true for IPv6, false for IPv4
forwardPortStatus
public void forwardPortStatus(byte[] ip, int port, int externalPort, boolean success, String reason) Notify a transport of the results of trying to forward a port.This implementation does nothing. Transports should override if they want notification.
- Specified by:
forwardPortStatusin interfaceTransport- Parameters:
ip- may be nullport- the internal portexternalPort- the external port, which for now should always be the same as the internal port if the forwarding was successful.success- true if the router managed to establish the mappingreason- the text describing the outcome, for the console and the logs
getRequestedPort
public int getRequestedPort()What INTERNAL port would the transport like to have forwarded by UPnP. This can't be passed via getCurrentAddress(), as we have to open the port before we can publish the address, and that's the external port anyway.- Specified by:
getRequestedPortin interfaceTransport- Returns:
- port or -1 for none or 0 for any
setListener
Who to notify on message availability.- Specified by:
setListenerin interfaceTransport- Parameters:
listener- the event listener to receive transport notifications
renderStatusHTML
Make this stuff pretty.- Parameters:
out- the writer to render to- Throws:
IOException- if writing fails
renderStatusHTML
Render the transport status HTML to the given writer.- Specified by:
renderStatusHTMLin interfaceTransport- Parameters:
out- writer the status HTML is rendered intourlBase- base URL for the links embedded in the HTMLsortFlags- flags controlling sorting and display options- Throws:
IOException- if the status HTML cannot be written to the writer
getReachabilityStatus
Previously returned short, now enum as of 0.9.20.- Specified by:
getReachabilityStatusin interfaceTransport- Returns:
- the reachability status
isIPv4Firewalled
public boolean isIPv4Firewalled()This returns true if the force-firewalled setting is configured, false otherwise.- Specified by:
isIPv4Firewalledin interfaceTransport- Returns:
- whether i pv4 firewalled
isIPv6Firewalled
public boolean isIPv6Firewalled()This returns true if the force-firewalled setting is configured, false otherwise.- Specified by:
isIPv6Firewalledin interfaceTransport- Returns:
- whether IPv6 firewalled
isBacklogged
Whether the given peer is backlogged.- Specified by:
isBackloggedin interfaceTransport- Parameters:
peer- hash of the peer to check- Returns:
- false; this base class has no notion of backlogs
isEstablished
Whether the given peer is established.- Specified by:
isEstablishedin interfaceTransport- Parameters:
peer- hash of the peer to check- Returns:
- false; only a real transport reports established sessions
wasFailsafeClosed
Whether this transport closed a session to the peer for idleness recently.A peer whose session we closed ourselves is not a peer that went away: it is one we declined to keep talking to. Callers use the distinction to attribute a later loss of connectivity, where guessing is worse than not knowing, so the default is a false rather than an approximation.
- Specified by:
wasFailsafeClosedin interfaceTransport- Parameters:
peer- the peer to ask aboutwithinMs- how far back counts as recent; non-positive means nothing is recent- Returns:
- true when this transport closed a session to the peer that recently
isConnecting
Check if a connection attempt is in progress for the given peer. Default returns false. NTCP2 and SSU2 transports that have an async handshake phase should override to report in-progress connections.- Specified by:
isConnectingin interfaceTransport- Parameters:
peer- hash of the peer to check- Returns:
- true if a connection attempt is in progress but not yet established
mayDisconnect
Tell the transport that we may disconnect from this peer. This is advisory only.- Specified by:
mayDisconnectin interfaceTransport- Parameters:
peer- hash of the peer that may be disconnected
isUnreachable
Whether the given peer is unreachable.- Specified by:
isUnreachablein interfaceTransport- Parameters:
peer- hash of the peer to check- Returns:
- true if the peer is in the unreachable cache and was not the last peer reached, false if it is reachable
markUnreachable
Called when we can't reach a peer.- Parameters:
peer- the router hash that did not answer
markReachable
Called when we establish a peer connection (outbound or inbound).- Parameters:
peer- the router hash that just connectedisInbound- true if we accepted the connection, false if we dialled out
stopCleanupJob
public void stopCleanupJob()Cancel the unreachable-entry cleanup, if one is scheduled.wasUnreachable
Was the peer unreachable (outbound only) the last time we tried it? This is NOT reset if the peer contacts us.- Specified by:
wasUnreachablein interfaceTransport- Parameters:
peer- hash of the peer to check reachability for- Returns:
- true if peer was unreachable on last outbound attempt
markWasUnreachable
Maintain the WasUnreachable list.- Parameters:
peer- the peer to add or removeyes- true to add the peer to the list, false to remove it
allowLocal
public boolean allowLocal()Are we allowed to connect to local addresses?- Returns:
- true if
i2np.allowLocalis set, false otherwise
setIP
IP of the peer from the last connection (in or out, any transport).- Parameters:
peer- the router hash the address was last seen forip- IPv4 or IPv6, non-null
getIP
IP of the peer from the last connection (in or out, any transport).- Parameters:
peer- the router hash to look the IP up for- Returns:
- IPv4 or IPv6 or null
formatIPPort
Format an IP byte array (4 or 16 bytes) as host:port, for logging.- Parameters:
ip- 4 or 16 byte addressport- port number, may be 0- Returns:
- "host:port" or "[host]:port", "UNKNOWN" for other lengths
getRouterIPPort
Best IP:port for a router, for ban logging: the direct connection IP from the transport layer, else a compatible address, else any announced address.- Parameters:
router- may be null- Returns:
- "host:port" or "UNKNOWN"
getAltStyle
An alternate supported style, or null.- Returns:
- null, override to add support
clearCaches
static void clearCaches()Drop the cached router-hash to IP mapping, so the next lookup reads it again from the network database.getIPv6Config
The IPv6 configuration for this transport.- Specified by:
getIPv6Configin interfaceTransport- Returns:
- the IPv6 config
isPubliclyRoutable
protected boolean isPubliclyRoutable(byte[] addr) Allows IPv6 only if the transport is configured for it. Caller must check if we actually have a public IPv6 address.- Parameters:
addr- non-null- Returns:
- whether publicly routable
_t
_t
ngettext
Translate, choosing between the singular and the plural form.- Parameters:
s- the singular string, may contain {0} for the countp- the plural string, may contain {0} for the countn- the count, used to choose between s and p- Returns:
- the translated string for that count