net.i2p.router.transport.udp
Class UDPTransport

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

public class UDPTransport
extends TransportImpl
implements TimedWeightedPriorityMessageQueue.FailedListener


Field Summary
static java.lang.String PROP_ALLOW_DIRECT
          do we allow direct SSU connections, sans introducers?
static java.lang.String PROP_BIND_INTERFACE
           
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_FIXED_PORT
           
static java.lang.String PROP_FORCE_INTRODUCERS
          do we require introducers, regardless of our status?
static java.lang.String PROP_INTERNAL_PORT
           
static java.lang.String PROP_PREFER_UDP
          If i2np.udp.preferred is set to "always", the UDP bids will always be under the bid from the TCP transport - even if a TCP connection already exists.
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
 java.util.List _getActivePeers()
          internal, do not use** return the peers (Hash) of active peers.
static UDPTransport _instance()
          internal, do not use**
(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?
 int countActiveSendPeers()
          How many peers are we actively sending messages to (this minute)
(package private)  void dropPeer(Hash peer, boolean shouldShitlist, java.lang.String why)
           
(package private)  void externalAddressReceived(Hash from, byte[] ourIP, int ourPort)
          Someone we tried to contact gave us what they think our IP address is.
 void failed(OutboundMessageState msg)
           
(package private)  void failed(OutboundMessageState msg, boolean allowPeerFailure)
           
 void failed(OutNetMessage msg, java.lang.String reason)
           
 java.util.Vector getClockSkews()
          Return our peer clock skews on this transport.
 RouterAddress getCurrentAddress()
          What addresses are we currently listening to?
 int getExternalPort()
           
 SessionKey getIntroKey()
          Introduction key that people should use to contact us
 java.net.InetAddress getLocalAddress()
           
 int getLocalPort()
           
(package private)  java.lang.String getPacketHandlerStatus()
           
 PeerState getPeerState(Hash remotePeer)
          get the state for the peer with the given ident, or null if no state exists
 PeerState getPeerState(long relayTag)
          get the state for the peer being introduced, or null if we aren't offering to introduce anyone with that tag.
 PeerState getPeerState(RemoteHostId hostInfo)
          get the state for the peer at the given remote host/port, or null if no state exists
 short getReachabilityStatus()
           
 java.lang.String getStyle()
           
(package private)  void inboundConnectionReceived()
           
 boolean introducersRequired()
           
 boolean isInDropList(RemoteHostId peer)
           
 boolean isValid(byte[] addr)
           
static void main(java.lang.String[] args)
           
 void messageReceived(I2NPMessage inMsg, RouterIdentity remoteIdent, Hash remoteIdentHash, long msToReceive, int bytesReceived)
          Message received from the I2NPMessageReader - send it to the listener
protected  void outboundMessageReady()
          This message is called whenever a new message is added to the send pool, and it should not block
 PeerState pickTestPeer(RemoteHostId dontInclude)
           
(package private)  void rebuildExternalAddress()
           
(package private)  void rebuildExternalAddress(boolean allowRebuildRouterInfo)
           
 void recheckReachability()
           
 void renderStatusHTML(java.io.Writer out, int sortFlags)
           
 void renderStatusHTML(java.io.Writer out, java.lang.String urlBase, int sortFlags)
           
protected  void replaceAddress(RouterAddress address, RouterAddress oldAddress)
           
(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)
           
(package private)  void setReachabilityStatus(short status)
           
 void shutdown()
           
 RouterAddress startListening()
           
 void startup()
           
 void stopListening()
           
 void succeeded(OutboundMessageState msg)
           
 
Methods inherited from class net.i2p.router.transport.TransportImpl
afterSend, afterSend, afterSend, afterSend, getContext, getMostRecentErrorMessages, getNextMessage, isBacklogged, isPubliclyRoutable, isUnreachable, markReachable, markUnreachable, renderStatusHTML, 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

PROP_PREFER_UDP

public static final java.lang.String PROP_PREFER_UDP
If i2np.udp.preferred is set to "always", the UDP bids will always be under the bid from the TCP transport - even if a TCP connection already exists. If it is set to "true", it will prefer UDP unless no UDP session exists and a TCP connection already exists. If it is set to "false" (the default), it will prefer TCP unless no TCP session exists and a UDP connection already exists.

See Also:
Constant Field Values

PROP_FIXED_PORT

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

PROP_FORCE_INTRODUCERS

public static final java.lang.String PROP_FORCE_INTRODUCERS
do we require introducers, regardless of our status?

See Also:
Constant Field Values

PROP_ALLOW_DIRECT

public static final java.lang.String PROP_ALLOW_DIRECT
do we allow direct SSU connections, sans introducers?

See Also:
Constant Field Values

PROP_BIND_INTERFACE

public static final java.lang.String PROP_BIND_INTERFACE
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()

inboundConnectionReceived

void inboundConnectionReceived()

externalAddressReceived

void externalAddressReceived(Hash from,
                             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 ;)


isValid

public final boolean isValid(byte[] addr)

getPeerState

public PeerState getPeerState(RemoteHostId hostInfo)
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(long 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


getCurrentAddress

public RouterAddress getCurrentAddress()
Description copied from class: TransportImpl
What addresses are we currently listening to?

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

messageReceived

public void messageReceived(I2NPMessage inMsg,
                            RouterIdentity remoteIdent,
                            Hash remoteIdentHash,
                            long msToReceive,
                            int bytesReceived)
Description copied from class: TransportImpl
Message received from the I2NPMessageReader - send it to the listener

Overrides:
messageReceived in class TransportImpl

isInDropList

public boolean isInDropList(RemoteHostId peer)

dropPeer

void dropPeer(Hash peer,
              boolean shouldShitlist,
              java.lang.String why)

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)

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

rebuildExternalAddress

void rebuildExternalAddress()

rebuildExternalAddress

void rebuildExternalAddress(boolean allowRebuildRouterInfo)

replaceAddress

protected void replaceAddress(RouterAddress address,
                              RouterAddress oldAddress)

introducersRequired

public boolean introducersRequired()

getPacketHandlerStatus

java.lang.String getPacketHandlerStatus()

failed

public void failed(OutboundMessageState msg)

failed

void failed(OutboundMessageState msg,
            boolean allowPeerFailure)

failed

public void failed(OutNetMessage msg,
                   java.lang.String reason)
Specified by:
failed in interface TimedWeightedPriorityMessageQueue.FailedListener

succeeded

public void succeeded(OutboundMessageState 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

countActiveSendPeers

public int countActiveSendPeers()
Description copied from class: TransportImpl
How many peers are we actively sending messages to (this minute)

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

getClockSkews

public java.util.Vector getClockSkews()
Return our peer clock skews on this transport. Vector composed of Long, each element representing a peer skew in seconds.

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

_instance

public static final UDPTransport _instance()
internal, do not use**


_getActivePeers

public java.util.List _getActivePeers()
internal, do not use** return the peers (Hash) of active peers.


renderStatusHTML

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

renderStatusHTML

public void renderStatusHTML(java.io.Writer out,
                             java.lang.String urlBase,
                             int sortFlags)
                      throws java.io.IOException
Specified by:
renderStatusHTML in interface Transport
Overrides:
renderStatusHTML in class TransportImpl
Throws:
java.io.IOException

setReachabilityStatus

void setReachabilityStatus(short status)

getReachabilityStatus

public short getReachabilityStatus()
Specified by:
getReachabilityStatus in interface Transport
Overrides:
getReachabilityStatus in class TransportImpl

recheckReachability

public void recheckReachability()
Specified by:
recheckReachability in interface Transport
Overrides:
recheckReachability in class TransportImpl

pickTestPeer

public PeerState pickTestPeer(RemoteHostId dontInclude)

main

public static void main(java.lang.String[] args)