net.i2p.router.transport
Class TransportManager

java.lang.Object
  extended by net.i2p.router.transport.TransportManager
All Implemented Interfaces:
TransportEventListener

public class TransportManager
extends java.lang.Object
implements TransportEventListener


Field Summary
static java.lang.String DEFAULT_ENABLE_NTCP
           
static java.lang.String DEFAULT_ENABLE_UDP
           
static java.lang.String PROP_ENABLE_NTCP
           
static java.lang.String PROP_ENABLE_UDP
           
static java.lang.String PROP_ENABLE_UPNP
          default true
 
Constructor Summary
TransportManager(RouterContext context)
           
 
Method Summary
 void addTransport(Transport transport)
           
 int countActivePeers()
           
 int countActiveSendPeers()
           
static boolean enableNTCP(RouterContext ctx)
           
 void externalAddressReceived(java.lang.String source, byte[] ip, int port)
          callback from UPnP Only tell SSU, it will tell NTCP
 void forwardPortStatus(java.lang.String style, int port, boolean success, java.lang.String reason)
          callback from UPnP
 java.util.Map<java.lang.String,RouterAddress> getAddresses()
          This forces a rebuild
 TransportBid getBid(OutNetMessage msg)
           
 java.util.List<TransportBid> getBids(OutNetMessage msg)
           
 java.util.Vector getClockSkews()
          Return our peer clock skews on all transports.
 byte[] getIP(Hash dest)
          IP of the peer from the last connection (in or out, any transport).
 java.util.List getMostRecentErrorMessages()
           
 TransportBid getNextBid(OutNetMessage msg)
           
 short getReachabilityStatus()
           
 Transport getTransport(java.lang.String style)
           
(package private)  int getTransportCount()
           
 boolean haveHighOutboundCapacity()
          Are all transports well below their outbound connection limit Use for throttling in the router.
 boolean haveInboundCapacity(int pct)
          Is at least one transport below its inbound connection limit + some margin Use for throttling in the router.
 boolean haveOutboundCapacity(int pct)
          Is at least one transport below its outbound connection limit + some margin Use for throttling in the router.
 boolean isBacklogged(Hash dest)
           
 boolean isEstablished(Hash dest)
           
 void messageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash fromRouterHash)
           
 void recheckReachability()
           
 void removeTransport(Transport transport)
           
 void renderStatusHTML(java.io.Writer out, java.lang.String urlBase, int sortFlags)
           
 void restart()
           
 void startListening()
           
 void stopListening()
           
 void transportAddressChanged()
           
 boolean wasUnreachable(Hash dest)
          Was the peer UNreachable (outbound only) on any transport, based on the last time we tried it for each transport?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_ENABLE_UDP

public static final java.lang.String PROP_ENABLE_UDP
See Also:
Constant Field Values

PROP_ENABLE_NTCP

public static final java.lang.String PROP_ENABLE_NTCP
See Also:
Constant Field Values

DEFAULT_ENABLE_NTCP

public static final java.lang.String DEFAULT_ENABLE_NTCP
See Also:
Constant Field Values

DEFAULT_ENABLE_UDP

public static final java.lang.String DEFAULT_ENABLE_UDP
See Also:
Constant Field Values

PROP_ENABLE_UPNP

public static final java.lang.String PROP_ENABLE_UPNP
default true

See Also:
Constant Field Values
Constructor Detail

TransportManager

public TransportManager(RouterContext context)
Method Detail

addTransport

public void addTransport(Transport transport)

removeTransport

public void removeTransport(Transport transport)

enableNTCP

public static boolean enableNTCP(RouterContext ctx)

externalAddressReceived

public void externalAddressReceived(java.lang.String source,
                                    byte[] ip,
                                    int port)
callback from UPnP Only tell SSU, it will tell NTCP


forwardPortStatus

public void forwardPortStatus(java.lang.String style,
                              int port,
                              boolean success,
                              java.lang.String reason)
callback from UPnP


startListening

public void startListening()

restart

public void restart()

stopListening

public void stopListening()

getTransport

public Transport getTransport(java.lang.String style)

getTransportCount

int getTransportCount()

countActivePeers

public int countActivePeers()

countActiveSendPeers

public int countActiveSendPeers()

haveOutboundCapacity

public 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

public boolean haveHighOutboundCapacity()
Are all transports well below their outbound connection limit Use for throttling in the router.


haveInboundCapacity

public 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

public java.util.Vector getClockSkews()
Return our peer clock skews on all transports. Vector composed of Long, each element representing a peer skew in seconds. Note: this method returns them in whimsical order.


getReachabilityStatus

public short getReachabilityStatus()
Returns:
the best status of any transport

recheckReachability

public void recheckReachability()

isBacklogged

public boolean isBacklogged(Hash dest)

isEstablished

public boolean isEstablished(Hash dest)

wasUnreachable

public boolean wasUnreachable(Hash dest)
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

public byte[] getIP(Hash dest)
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.


getAddresses

public java.util.Map<java.lang.String,RouterAddress> getAddresses()
This forces a rebuild


getBid

public TransportBid getBid(OutNetMessage msg)

getBids

public java.util.List<TransportBid> getBids(OutNetMessage msg)

getNextBid

public TransportBid getNextBid(OutNetMessage msg)

messageReceived

public void messageReceived(I2NPMessage message,
                            RouterIdentity fromRouter,
                            Hash fromRouterHash)
Specified by:
messageReceived in interface TransportEventListener

transportAddressChanged

public void transportAddressChanged()
Specified by:
transportAddressChanged in interface TransportEventListener

getMostRecentErrorMessages

public java.util.List getMostRecentErrorMessages()

renderStatusHTML

public void renderStatusHTML(java.io.Writer out,
                             java.lang.String urlBase,
                             int sortFlags)
                      throws java.io.IOException
Throws:
java.io.IOException