Package net.i2p.router.transport
Class TransportManager
java.lang.Object
net.i2p.router.transport.TransportManager
- All Implemented Interfaces:
TransportEventListener
Keeps track of the enabled transports.
Starts UPnP.
Pluggable transport support incomplete.
Public only for a couple things in the console and Android.
To be made package private.
Everything external should go through CommSystemFacadeImpl.
Not a public API, not for external use.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) 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.(package private) intHow many peers are we currently connected to, that we have sent a message to in the last minute.(package private) voidexternalAddressReceived(Transport.AddressSource source, byte[] ip, int port) Initialize from interfaces, and callback from UPnP or SSU.(package private) voidexternalAddressRemoved(Transport.AddressSource source, boolean ipv6) Remove all ipv4 or ipv6 addresses.(package private) voidforceDisconnect(Hash peer) Tell the transports to disconnect from this peer.(package private) voidforwardPortStatus(String style, byte[] ip, int port, int externalPort, boolean success, String reason) callback from UPnP(package private) List<RouterAddress>This forces a rebuild(package private) TransportBidgetBid(OutNetMessage msg) (package private) List<TransportBid>getBids(OutNetMessage msg) Return our peer clock skews on all transports.(package private) DHSessionKeyBuilder.FactoryHook for pluggable transport creation.(package private) byte[]IP of the peer from the last connection (in or out, any transport).(package private) TransportBidgetNextBid(OutNetMessage msg) (package private) CommSystemFacade.StatusPreviously returned short, now enum as of 0.9.20(package private) TransportgetTransport(String style) (package private) int(package private) X25519KeyFactoryFactory for making X25519 key pairs.(package private) booleanAre all transports well below their outbound connection limit Use for throttling in the router.(package private) booleanhaveInboundCapacity(int pct) Is at least one transport below its inbound connection limit + some margin Use for throttling in the router.(package private) booleanhaveOutboundCapacity(int pct) Is at least one transport below its outbound connection limit + some margin Use for throttling in the router.(package private) voidNotify all transports of ALL routable interface addresses, including IPv6.(package private) booleanisBacklogged(Hash peer) (package private) booleanisEstablished(Hash peer) static boolean(package private) voidmayDisconnect(Hash peer) Tell the transports that we may disconnect from this peer.voidmessageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash fromRouterHash) Message received(package private) voidDeprecated.unused(package private) voidPluggable transports.voidrenderStatusHTML(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.(package private) voidrestart()(package private) voidshutdown()Cannot be restarted.(package private) void(package private) voidPluggable transports.(package private) voidCan be restarted.voidTransportEventListener calls UPnPManager rescan() and update()(package private) booleanwasUnreachable(Hash peer) Was the peer UNreachable (outbound only) on any transport, based on the last time we tried it for each transport? This is NOT reset if the peer contacts us.
-
Field Details
-
PROP_ENABLE_UDP
default true- See Also:
-
PROP_ENABLE_SSU2
Default true as of 0.9.56- Since:
- 0.9.54
- See Also:
-
PROP_ENABLE_NTCP
default true- See Also:
-
PROP_ENABLE_UPNP
default true- See Also:
-
PROP_ENABLE_UPNP_IPV6
- See Also:
-
DEFAULT_ENABLE_UPNP_IPV6
public static final boolean DEFAULT_ENABLE_UPNP_IPV6- See Also:
-
-
Constructor Details
-
TransportManager
-
-
Method Details
-
registerAndStart
Pluggable transports. Not for NTCP or SSU.- Since:
- 0.9.16
-
stopAndUnregister
Pluggable transports. Not for NTCP or SSU.- Since:
- 0.9.16
-
getDHFactory
DHSessionKeyBuilder.Factory getDHFactory()Hook for pluggable transport creation.- Returns:
- null if both NTCP1 and SSU are disabled
- Since:
- 0.9.16
-
getXDHFactory
X25519KeyFactory getXDHFactory()Factory for making X25519 key pairs.- Since:
- 0.9.46
-
isNTCPEnabled
-
initializeAddress
void initializeAddress()Notify all transports of ALL routable interface addresses, including IPv6. It's the transport's job to ignore what it can't handle.- Since:
- 0.9.34
-
externalAddressReceived
Initialize from interfaces, and callback from UPnP or SSU. See CSFI.notifyReplaceAddress(). Tell all transports... but don't loop. -
externalAddressRemoved
Remove all ipv4 or ipv6 addresses. See CSFI.notifyRemoveAddress(). Tell all transports... but don't loop.- Since:
- 0.9.20
-
forwardPortStatus
void forwardPortStatus(String style, byte[] ip, int port, int externalPort, boolean success, String reason) callback from UPnP -
startListening
void startListening() -
restart
void restart() -
stopListening
void stopListening()Can be restarted. -
shutdown
void shutdown()Cannot be restarted.- Since:
- 0.9
-
getTransport
-
getTransportCount
int getTransportCount() -
getTransports
- Returns:
- SortedMap of style to Transport (a copy)
- Since:
- 0.9.31
-
countActivePeers
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. -
countActiveSendPeers
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. -
haveOutboundCapacity
boolean haveOutboundCapacity(int pct) Is at least one transport below its outbound connection limit + some margin Use for throttling in the router.- Parameters:
pct- percent of limit 0-100
-
haveHighOutboundCapacity
boolean haveHighOutboundCapacity()Are all transports well below their outbound connection limit Use for throttling in the router. -
haveInboundCapacity
boolean haveInboundCapacity(int pct) Is at least one transport below its inbound connection limit + some margin Use for throttling in the router.- Parameters:
pct- percent of limit 0-100
-
getClockSkews
Return our peer clock skews on all transports. List composed of Long, each element representing a peer skew in seconds. A positive number means our clock is ahead of theirs. Note: this method returns them in whimsical order. -
getReachabilityStatus
CommSystemFacade.Status getReachabilityStatus()Previously returned short, now enum as of 0.9.20- Returns:
- the best status of any transport
-
recheckReachability
Deprecated.unused -
isBacklogged
-
isEstablished
-
getEstablished
- Returns:
- a new set, may be modified
- Since:
- 0.9.34
-
mayDisconnect
Tell the transports that we may disconnect from this peer. This is advisory only.- Since:
- 0.9.24
-
forceDisconnect
Tell the transports to disconnect from this peer.- Since:
- 0.9.38
-
wasUnreachable
Was the peer UNreachable (outbound only) on any transport, based on the last time we tried it for each transport? This is NOT reset if the peer contacts us. -
getIP
IP of the peer from the last connection (in or out, any transport). This may be different from that advertised in the netDb, as the peer may be hidden, or connect from a different IP, or change his netDb later, in an attempt to avoid restrictions. For blocking purposes, etc. it's worth checking both the netDb addresses and this address.- Returns:
- IPv4 or IPv6 or null
-
getAddresses
List<RouterAddress> getAddresses()This forces a rebuild -
getBid
-
getBids
-
getNextBid
-
messageReceived
Message received- Specified by:
messageReceivedin interfaceTransportEventListener- Parameters:
message- non-nullfromRouter- may be nullfromRouterHash- may be null, calculated from fromRouter if null
-
transportAddressChanged
public void transportAddressChanged()TransportEventListener calls UPnPManager rescan() and update()- Specified by:
transportAddressChangedin interfaceTransportEventListener
-
getMostRecentErrorMessages
-
renderStatusHTML
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.- Throws:
IOException
-