net.i2p.router.transport.tcp
Class TCPTransport

java.lang.Object
  extended by net.i2p.router.transport.TransportImpl
      extended by net.i2p.router.transport.tcp.TCPTransport
All Implemented Interfaces:
Transport

public class TCPTransport
extends TransportImpl

TCP Transport implementation, coordinating the connections between peers and the transmission of messages across those connections.


Field Summary
static java.lang.String BIND_ALL_INTERFACES
          Should the TCP listener bind to all interfaces?
static int DEFAULT_ESTABLISHERS
           
static int DEFAULT_LISTEN_PORT
          blah, people shouldnt use defaults...
static java.lang.String LISTEN_ADDRESS
          What host/ip should we be addressed as?
static java.lang.String LISTEN_ALLOW_LOCAL
          Should we allow the transport to listen on a non routable address?
static java.lang.String LISTEN_PORT
          What port number should we listen to?
static int MAX_ERR_MESSAGES
          Keep track of the last 10 error messages wrt establishing a connection
static java.lang.String PROP_ESTABLISHERS
           
static java.lang.String STYLE
          What is this transport's identifier?
static int[] SUPPORTED_PROTOCOLS
          Ordered list of supported I2NP protocols
 
Fields inherited from class net.i2p.router.transport.TransportImpl
_context
 
Constructor Summary
TCPTransport(RouterContext context)
          Creates a new instance of TCPTransport
 
Method Summary
(package private)  void addConnectionErrorMessage(java.lang.String msg)
          Add the given message to the list of most recent connection establishment error messages.
 void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend)
          The transport is done sending this message.
(package private)  boolean allowAddress(TCPAddress address)
          Is the given address a valid one that we could listen to or contact?
 TransportBid bid(RouterInfo toAddress, long dataSize)
           
(package private)  void connectionClosed(TCPConnection con)
           
(package private)  void connectionEstablished(TCPConnection con)
          The connection specified has been fully built
 int countActiveAgreeingPeers(java.lang.String address)
          How many peers that we are connected to think we are reachable at the given address?
 int countActivePeers()
          How many peers can we talk to right now?
(package private)  void establishmentComplete(RouterInfo info)
          Called after an establisher finished (or failed) connecting to the peer
 java.util.List getMostRecentErrorMessages()
           
(package private)  java.lang.String getMyHost()
           
(package private)  RouterInfo getNextPeer()
          Blocking call to retrieve the next peer that we want to establish a connection with.
(package private)  int getPort()
          What port should we be reachable on?
 java.lang.String getStyle()
           
(package private)  ConnectionTagManager getTagManager()
           
(package private)  void ourAddressReceived(java.lang.String address)
          Blocking call from when a remote peer tells us what they think our IP address is.
protected  void outboundMessageReady()
          Called whenever a new message is ready to be sent.
 void renderStatusHTML(java.io.Writer out)
          Make this stuff pretty (only used in the old console)
(package private)  boolean shouldListenToAllInterfaces()
          Should we listen to all interfaces, or just the one specified in our TCPAddress?
 RouterAddress startListening()
           
 void stopListening()
           
 
Methods inherited from class net.i2p.router.transport.TransportImpl
afterSend, afterSend, afterSend, countActiveSendPeers, getClockSkews, getContext, getCurrentAddress, getNextMessage, getReachabilityStatus, isBacklogged, isPubliclyRoutable, isUnreachable, markReachable, markUnreachable, messageReceived, recheckReachability, renderStatusHTML, replaceAddress, send, setListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE

public static final java.lang.String STYLE
What is this transport's identifier?

See Also:
Constant Field Values

BIND_ALL_INTERFACES

public static final java.lang.String BIND_ALL_INTERFACES
Should the TCP listener bind to all interfaces?

See Also:
Constant Field Values

LISTEN_ADDRESS

public static final java.lang.String LISTEN_ADDRESS
What host/ip should we be addressed as?

See Also:
Constant Field Values

LISTEN_PORT

public static final java.lang.String LISTEN_PORT
What port number should we listen to?

See Also:
Constant Field Values

LISTEN_ALLOW_LOCAL

public static final java.lang.String LISTEN_ALLOW_LOCAL
Should we allow the transport to listen on a non routable address?

See Also:
Constant Field Values

MAX_ERR_MESSAGES

public static final int MAX_ERR_MESSAGES
Keep track of the last 10 error messages wrt establishing a connection

See Also:
Constant Field Values

PROP_ESTABLISHERS

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

DEFAULT_ESTABLISHERS

public static final int DEFAULT_ESTABLISHERS
See Also:
Constant Field Values

SUPPORTED_PROTOCOLS

public static final int[] SUPPORTED_PROTOCOLS
Ordered list of supported I2NP protocols


DEFAULT_LISTEN_PORT

public static final int DEFAULT_LISTEN_PORT
blah, people shouldnt use defaults...

See Also:
Constant Field Values
Constructor Detail

TCPTransport

public TCPTransport(RouterContext context)
Creates a new instance of TCPTransport

Method Detail

bid

public TransportBid bid(RouterInfo toAddress,
                        long dataSize)

outboundMessageReady

protected void outboundMessageReady()
Called whenever a new message is ready to be sent. This should not block.

Specified by:
outboundMessageReady in class TransportImpl

connectionEstablished

void connectionEstablished(TCPConnection con)
The connection specified has been fully built


connectionClosed

void connectionClosed(TCPConnection con)

ourAddressReceived

void ourAddressReceived(java.lang.String address)
Blocking call from when a remote peer tells us what they think our IP address is. This may do absolutely nothing, or it may fire up a new socket listener after stopping an existing one.

Parameters:
address - address that the remote host said was ours

startListening

public RouterAddress startListening()

stopListening

public void stopListening()

shouldListenToAllInterfaces

boolean shouldListenToAllInterfaces()
Should we listen to all interfaces, or just the one specified in our TCPAddress?


addConnectionErrorMessage

void addConnectionErrorMessage(java.lang.String msg)
Add the given message to the list of most recent connection establishment error messages. A timestamp is prefixed to it before being rendered on the router console.


getMyHost

java.lang.String getMyHost()

getStyle

public java.lang.String getStyle()

getTagManager

ConnectionTagManager getTagManager()

allowAddress

boolean allowAddress(TCPAddress address)
Is the given address a valid one that we could listen to or contact?


getPort

int getPort()
What port should we be reachable on?

Returns:
the port number, or -1 if there is no valid port

getMostRecentErrorMessages

public java.util.List getMostRecentErrorMessages()
Specified by:
getMostRecentErrorMessages in interface Transport
Overrides:
getMostRecentErrorMessages in class TransportImpl

countActivePeers

public int countActivePeers()
How many peers can we talk to right now?

Specified by:
countActivePeers in interface Transport
Overrides:
countActivePeers in class TransportImpl

countActiveAgreeingPeers

public int countActiveAgreeingPeers(java.lang.String address)
How many peers that we are connected to think we are reachable at the given address?


afterSend

public void afterSend(OutNetMessage msg,
                      boolean sendSuccessful,
                      boolean allowRequeue,
                      long msToSend)
The transport is done sending this message. This exposes the superclass's protected method to the current package.

Overrides:
afterSend in class TransportImpl
Parameters:
msg - message in question
sendSuccessful - true if the peer received it
msToSend - how long it took to transfer the data to the peer
allowRequeue - true if we should try other transports if available

getNextPeer

RouterInfo getNextPeer()
Blocking call to retrieve the next peer that we want to establish a connection with.


establishmentComplete

void establishmentComplete(RouterInfo info)
Called after an establisher finished (or failed) connecting to the peer


renderStatusHTML

public void renderStatusHTML(java.io.Writer out)
                      throws java.io.IOException
Make this stuff pretty (only used in the old console)

Overrides:
renderStatusHTML in class TransportImpl
Throws:
java.io.IOException