Package net.i2p.router.transport
Class TransportManager
- java.lang.Object
-
- net.i2p.router.transport.TransportManager
-
- All Implemented Interfaces:
TransportEventListener
public class TransportManager extends Object implements 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 Modifier and Type Class Description (package private) static class
TransportManager.Port
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_ENABLE_UPNP_IPV6
static String
PROP_ENABLE_NTCP
default truestatic String
PROP_ENABLE_UDP
default truestatic String
PROP_ENABLE_UPNP
default truestatic String
PROP_ENABLE_UPNP_IPV6
-
Constructor Summary
Constructors Constructor Description TransportManager(RouterContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) 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.(package private) int
countActiveSendPeers()
How many peers are we currently connected to, that we have sent a message to in the last minute.(package private) void
externalAddressReceived(Transport.AddressSource source, byte[] ip, int port)
Initialize from interfaces, and callback from UPnP or SSU.(package private) void
externalAddressRemoved(Transport.AddressSource source, boolean ipv6)
Remove all ipv4 or ipv6 addresses.(package private) void
forceDisconnect(Hash peer)
Tell the transports to disconnect from this peer.(package private) void
forwardPortStatus(String style, byte[] ip, int port, int externalPort, boolean success, String reason)
callback from UPnP(package private) List<RouterAddress>
getAddresses()
This forces a rebuild(package private) TransportBid
getBid(OutNetMessage msg)
(package private) List<TransportBid>
getBids(OutNetMessage msg)
(package private) List<Long>
getClockSkews()
Return our peer clock skews on all transports.(package private) DHSessionKeyBuilder.Factory
getDHFactory()
Hook for pluggable transport creation.Set<Hash>
getEstablished()
(package private) byte[]
getIP(Hash peer)
IP of the peer from the last connection (in or out, any transport).(package private) List<String>
getMostRecentErrorMessages()
(package private) TransportBid
getNextBid(OutNetMessage msg)
(package private) CommSystemFacade.Status
getReachabilityStatus()
Previously returned short, now enum as of 0.9.20(package private) Transport
getTransport(String style)
(package private) int
getTransportCount()
(package private) SortedMap<String,Transport>
getTransports()
(package private) X25519KeyFactory
getXDHFactory()
Factory for making X25519 key pairs.(package private) boolean
haveHighOutboundCapacity()
Are all transports well below their outbound connection limit Use for throttling in the router.(package private) boolean
haveInboundCapacity(int pct)
Is at least one transport below its inbound connection limit + some margin Use for throttling in the router.(package private) boolean
haveOutboundCapacity(int pct)
Is at least one transport below its outbound connection limit + some margin Use for throttling in the router.(package private) void
initializeAddress()
Notify all transports of ALL routable interface addresses, including IPv6.(package private) boolean
isBacklogged(Hash peer)
(package private) boolean
isEstablished(Hash peer)
static boolean
isNTCPEnabled(RouterContext ctx)
(package private) void
mayDisconnect(Hash peer)
Tell the transports that we may disconnect from this peer.void
messageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash fromRouterHash)
Message received(package private) void
recheckReachability()
Deprecated.unused(package private) void
registerAndStart(Transport t)
Pluggable transports.void
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.(package private) void
restart()
(package private) void
shutdown()
Cannot be restarted.(package private) void
startListening()
(package private) void
stopAndUnregister(Transport t)
Pluggable transports.(package private) void
stopListening()
Can be restarted.void
transportAddressChanged()
TransportEventListener calls UPnPManager rescan() and update()(package private) boolean
wasUnreachable(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 Detail
-
PROP_ENABLE_UDP
public static final String PROP_ENABLE_UDP
default true- See Also:
- Constant Field Values
-
PROP_ENABLE_NTCP
public static final String PROP_ENABLE_NTCP
default true- See Also:
- Constant Field Values
-
PROP_ENABLE_UPNP
public static final String PROP_ENABLE_UPNP
default true- See Also:
- Constant Field Values
-
PROP_ENABLE_UPNP_IPV6
public static final String PROP_ENABLE_UPNP_IPV6
- See Also:
- Constant Field Values
-
DEFAULT_ENABLE_UPNP_IPV6
public static final boolean DEFAULT_ENABLE_UPNP_IPV6
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TransportManager
public TransportManager(RouterContext context)
-
-
Method Detail
-
registerAndStart
void registerAndStart(Transport t)
Pluggable transports. Not for NTCP or SSU.- Since:
- 0.9.16
-
stopAndUnregister
void stopAndUnregister(Transport t)
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
public static boolean isNTCPEnabled(RouterContext ctx)
-
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
void externalAddressReceived(Transport.AddressSource source, byte[] ip, int port)
Initialize from interfaces, and callback from UPnP or SSU. See CSFI.notifyReplaceAddress(). Tell all transports... but don't loop.
-
externalAddressRemoved
void externalAddressRemoved(Transport.AddressSource source, boolean ipv6)
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
-
getTransportCount
int getTransportCount()
-
getTransports
SortedMap<String,Transport> 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
List<Long> 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 void recheckReachability()
Deprecated.unused
-
isBacklogged
boolean isBacklogged(Hash peer)
-
isEstablished
boolean isEstablished(Hash peer)
-
mayDisconnect
void mayDisconnect(Hash peer)
Tell the transports that we may disconnect from this peer. This is advisory only.- Since:
- 0.9.24
-
forceDisconnect
void forceDisconnect(Hash peer)
Tell the transports to disconnect from this peer.- Since:
- 0.9.38
-
wasUnreachable
boolean wasUnreachable(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.
-
getIP
byte[] getIP(Hash peer)
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
TransportBid getBid(OutNetMessage msg)
-
getBids
List<TransportBid> getBids(OutNetMessage msg)
-
getNextBid
TransportBid getNextBid(OutNetMessage msg)
-
messageReceived
public void messageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash fromRouterHash)
Message received- Specified by:
messageReceived
in 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:
transportAddressChanged
in interfaceTransportEventListener
-
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.- Throws:
IOException
-
-