net.i2p.router.transport.udp
Class UDPTransport

java.lang.Object
  extended bynet.i2p.router.transport.TransportImpl
      extended bynet.i2p.router.transport.udp.UDPTransport
All Implemented Interfaces:
TimedWeightedPriorityMessageQueue.FailedListener, Transport

public class UDPTransport
extends TransportImpl
implements TimedWeightedPriorityMessageQueue.FailedListener


Field Summary
static java.lang.String PROP_EXTERNAL_HOST
          define this to explicitly set an external IP address
static java.lang.String PROP_EXTERNAL_PORT
          define this to explicitly set an external port
static java.lang.String PROP_INTERNAL_PORT
           
static int PUBLIC_RELAY_COUNT
          how many relays offered to us will we use at a time?
static java.lang.String STYLE
           
 
Constructor Summary
UDPTransport(RouterContext ctx)
           
 
Method Summary
(package private)  void addRelayPeer(java.lang.String host, int port, byte[] tag, SessionKey relayIntroKey)
           
(package private)  boolean addRemotePeerState(PeerState peer)
          add the peer info, returning true if it went in properly, false if it was rejected (causes include peer ident already connected, or no remote host info known
 TransportBid bid(RouterInfo toAddress, long dataSize)
           
 int countActivePeers()
          How many peers can we talk to right now?
(package private)  void externalAddressReceived(byte[] ourIP, int ourPort)
          Someone we tried to contact gave us what they think our IP address is.
 void failed(OutNetMessage msg)
           
 int getExternalPort()
           
 SessionKey getIntroKey()
          Introduction key that people should use to contact us
 java.net.InetAddress getLocalAddress()
           
 int getLocalPort()
           
 OutNetMessage getNextMessage()
          Nonblocking call to pull the next outbound message off the queue.
 OutNetMessage getNextMessage(long blockUntil)
          Get the next message, blocking until one is found or the expiration reached.
 PeerState getPeerState(Hash remotePeer)
          get the state for the peer with the given ident, or null if no state exists
 PeerState getPeerState(java.net.InetAddress remoteHost, int remotePort)
          get the state for the peer at the given remote host/port, or null if no state exists
 PeerState getPeerState(java.lang.String relayTag)
          get the state for the peer being introduced, or null if we aren't offering to introduce anyone with that tag.
 java.lang.String getStyle()
           
protected  void outboundMessageReady()
          This message is called whenever a new message is added to the send pool, and it should not block
(package private)  void rebuildExternalAddress()
           
 void renderStatusHTML(java.io.Writer out)
          Make this stuff pretty (only used in the old console)
(package private)  void send(I2NPMessage msg, PeerState peer)
           
 void send(OutNetMessage msg)
          Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector).
(package private)  int send(UDPPacket packet)
           
(package private)  void setExternalListenHost(byte[] addr)
           
(package private)  void setExternalListenHost(java.net.InetAddress addr)
           
(package private)  void setExternalListenPort(int port)
           
 void shutdown()
           
 RouterAddress startListening()
           
 void startup()
           
 void stopListening()
           
 void succeeded(OutNetMessage msg)
           
 
Methods inherited from class net.i2p.router.transport.TransportImpl
afterSend, afterSend, afterSend, afterSend, getContext, getCurrentAddresses, getMostRecentErrorMessages, messageReceived, replaceAddress, 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
See Also:
Constant Field Values

PROP_INTERNAL_PORT

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

PROP_EXTERNAL_HOST

public static final java.lang.String PROP_EXTERNAL_HOST
define this to explicitly set an external IP address

See Also:
Constant Field Values

PROP_EXTERNAL_PORT

public static final java.lang.String PROP_EXTERNAL_PORT
define this to explicitly set an external port

See Also:
Constant Field Values

PUBLIC_RELAY_COUNT

public static final int PUBLIC_RELAY_COUNT
how many relays offered to us will we use at a time?

See Also:
Constant Field Values
Constructor Detail

UDPTransport

public UDPTransport(RouterContext ctx)
Method Detail

startup

public void startup()

shutdown

public void shutdown()

getIntroKey

public SessionKey getIntroKey()
Introduction key that people should use to contact us


getLocalPort

public int getLocalPort()

getLocalAddress

public java.net.InetAddress getLocalAddress()

getExternalPort

public int getExternalPort()

externalAddressReceived

void externalAddressReceived(byte[] ourIP,
                             int ourPort)
Someone we tried to contact gave us what they think our IP address is. Right now, we just blindly trust them, changing our IP and port on a whim. this is not good ;)


getPeerState

public PeerState getPeerState(java.net.InetAddress remoteHost,
                              int remotePort)
get the state for the peer at the given remote host/port, or null if no state exists


getPeerState

public PeerState getPeerState(Hash remotePeer)
get the state for the peer with the given ident, or null if no state exists


getPeerState

public PeerState getPeerState(java.lang.String relayTag)
get the state for the peer being introduced, or null if we aren't offering to introduce anyone with that tag.


addRemotePeerState

boolean addRemotePeerState(PeerState peer)
add the peer info, returning true if it went in properly, false if it was rejected (causes include peer ident already connected, or no remote host info known


send

int send(UDPPacket packet)

bid

public TransportBid bid(RouterInfo toAddress,
                        long dataSize)
Specified by:
bid in interface Transport

getStyle

public java.lang.String getStyle()
Specified by:
getStyle in interface Transport

send

public void send(OutNetMessage msg)
Description copied from class: TransportImpl
Asynchronously send the message as requested in the message and, if the send is successful, queue up any msg.getOnSendJob job, and register it with the OutboundMessageRegistry (if it has a reply selector). If the send fails, queue up any msg.getOnFailedSendJob

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

send

void send(I2NPMessage msg,
          PeerState peer)

getNextMessage

public OutNetMessage getNextMessage()
Description copied from class: TransportImpl
Nonblocking call to pull the next outbound message off the queue.

Overrides:
getNextMessage in class TransportImpl
Returns:
the next message or null if none are available

getNextMessage

public OutNetMessage getNextMessage(long blockUntil)
Get the next message, blocking until one is found or the expiration reached.

Parameters:
blockUntil - expiration, or -1 if indefinite

outboundMessageReady

protected void outboundMessageReady()
Description copied from class: TransportImpl
This message is called whenever a new message is added to the send pool, and it should not block

Specified by:
outboundMessageReady in class TransportImpl

startListening

public RouterAddress startListening()
Specified by:
startListening in interface Transport

stopListening

public void stopListening()
Specified by:
stopListening in interface Transport

setExternalListenPort

void setExternalListenPort(int port)

setExternalListenHost

void setExternalListenHost(java.net.InetAddress addr)

setExternalListenHost

void setExternalListenHost(byte[] addr)
                     throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

addRelayPeer

void addRelayPeer(java.lang.String host,
                  int port,
                  byte[] tag,
                  SessionKey relayIntroKey)

rebuildExternalAddress

void rebuildExternalAddress()

failed

public void failed(OutNetMessage msg)
Specified by:
failed in interface TimedWeightedPriorityMessageQueue.FailedListener

succeeded

public void succeeded(OutNetMessage msg)

countActivePeers

public int countActivePeers()
Description copied from class: TransportImpl
How many peers can we talk to right now?

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

renderStatusHTML

public void renderStatusHTML(java.io.Writer out)
                      throws java.io.IOException
Description copied from class: TransportImpl
Make this stuff pretty (only used in the old console)

Specified by:
renderStatusHTML in interface Transport
Overrides:
renderStatusHTML in class TransportImpl
Throws:
java.io.IOException