net.i2p.router.transport
Class TransportManager

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

public class TransportManager
extends Object
implements TransportEventListener


Field Summary
static String PROP_ENABLE_NTCP
          default true
static String PROP_ENABLE_UDP
          default true
static String PROP_ENABLE_UPNP
          default true
 
Constructor Summary
TransportManager(RouterContext context)
           
 
Method Summary
 void addTransport(Transport transport)
           
 int countActivePeers()
           
 int countActiveSendPeers()
           
 void externalAddressReceived(String source, byte[] ip, int port)
          callback from UPnP Only tell SSU, it will tell NTCP
 void forwardPortStatus(String style, int port, int externalPort, boolean success, String reason)
          callback from UPnP
 Map<String,RouterAddress> getAddresses()
          This forces a rebuild
 TransportBid getBid(OutNetMessage msg)
           
 List<TransportBid> getBids(OutNetMessage msg)
           
 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).
 List getMostRecentErrorMessages()
           
 TransportBid getNextBid(OutNetMessage msg)
           
 short getReachabilityStatus()
           
 Transport getTransport(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)
           
static boolean isNTCPEnabled(RouterContext ctx)
           
 void messageReceived(I2NPMessage message, RouterIdentity fromRouter, Hash fromRouterHash)
           
 void recheckReachability()
           
 void removeTransport(Transport transport)
           
 void renderStatusHTML(Writer out, String urlBase, int sortFlags)
           
 void restart()
           
 void shutdown()
          Cannot be restarted.
 void startListening()
           
 void stopListening()
          Can be restarted.
 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? This is NOT reset if the peer contacts us.
 
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 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
Constructor Detail

TransportManager

public TransportManager(RouterContext context)
Method Detail

addTransport

public void addTransport(Transport transport)

removeTransport

public void removeTransport(Transport transport)

isNTCPEnabled

public static boolean isNTCPEnabled(RouterContext ctx)

externalAddressReceived

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


forwardPortStatus

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


startListening

public void startListening()

restart

public void restart()

stopListening

public void stopListening()
Can be restarted.


shutdown

public void shutdown()
Cannot be restarted.

Since:
0.9

getTransport

public Transport getTransport(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 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 Map<String,RouterAddress> getAddresses()
This forces a rebuild


getBid

public TransportBid getBid(OutNetMessage msg)

getBids

public 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 List getMostRecentErrorMessages()

renderStatusHTML

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