net.i2p.router.transport.ntcp
public class NTCPTransport extends TransportImpl
Modifier and Type | Field and Description |
---|---|
static int |
ESTABLISH_TIMEOUT
how long from initial connection attempt (accept() or connect()) until
the con must be established to avoid premature close()ing
|
static String |
PROP_BIND_INTERFACE
this is rarely if ever used, default is to bind to wildcard address
|
static String |
STYLE |
_context, ADJUST_COST
SOURCE_CONFIG, SOURCE_INTERFACE, SOURCE_UPNP
Constructor and Description |
---|
NTCPTransport(RouterContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
afterSend(OutNetMessage msg,
boolean sendSuccessful,
boolean allowRequeue,
long msToSend)
The transport is done sending this message.
|
boolean |
allowConnection() |
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 |
establishing(NTCPConnection con)
add us to the establishment timeout process
|
(package private) void |
expireTimedOut()
called in the EventPumper no more than once a second or so, closing
any unconnected/unestablished connections
|
void |
forwardPortStatus(int port,
boolean success,
String reason)
If we didn't used to be forwarded, and we have an address,
and we are configured to use UPnP, update our RouterAddress
Don't do anything now.
|
Vector<Long> |
getClockSkews()
Return our peer clock skews on this transport.
|
(package private) EventPumper |
getPumper() |
short |
getReachabilityStatus()
Maybe we should trust UPnP here and report OK if it opened the port, but
for now we don't.
|
(package private) Reader |
getReader() |
int |
getRequestedPort()
What port would the transport like to have forwarded by UPnP.
|
String |
getStyle() |
(package private) Writer |
getWriter() |
(package private) void |
inboundEstablished(NTCPConnection con) |
boolean |
isAlive() |
boolean |
isBacklogged(Hash dest) |
boolean |
isEstablished(Hash dest) |
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 |
removeCon(NTCPConnection con) |
void |
renderStatusHTML(Writer out,
int sortFlags) |
void |
renderStatusHTML(Writer out,
String urlBase,
int sortFlags) |
RouterAddress |
restartListening(RouterAddress addr)
Only called by CSFI.
|
(package private) void |
sendComplete(OutNetMessage msg)
queue up afterSend call, which can take some time w/ jobs, etc
|
(package private) void |
setLastBadSkew(long skew) |
RouterAddress |
startListening()
Called by TransportManager.
|
void |
stopListening()
This doesn't (completely) block, caller should check isAlive()
before calling startListening() or restartListening()
|
afterSend, afterSend, afterSend, countPeers, externalAddressReceived, getContext, getCurrentAddress, getIP, getMaxConnections, getMostRecentErrorMessages, getNextMessage, haveCapacity, haveCapacity, isPubliclyRoutable, isUnreachable, markReachable, markUnreachable, markWasUnreachable, messageReceived, recheckReachability, renderStatusHTML, replaceAddress, send, setIP, setListener, updateAddress, wasUnreachable
public static final String PROP_BIND_INTERFACE
public static final int ESTABLISH_TIMEOUT
public static final String STYLE
public NTCPTransport(RouterContext ctx)
void inboundEstablished(NTCPConnection con)
protected void outboundMessageReady()
TransportImpl
outboundMessageReady
in class TransportImpl
public void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend)
TransportImpl
afterSend
in class TransportImpl
msg
- message in questionsendSuccessful
- true if the peer received itallowRequeue
- true if we should try other transports if availablemsToSend
- how long it took to transfer the data to the peerpublic TransportBid bid(RouterInfo toAddress, long dataSize)
public boolean allowConnection()
void sendComplete(OutNetMessage msg)
public boolean isEstablished(Hash dest)
isEstablished
in interface Transport
isEstablished
in class TransportImpl
public boolean isBacklogged(Hash dest)
isBacklogged
in interface Transport
isBacklogged
in class TransportImpl
void removeCon(NTCPConnection con)
public int countActivePeers()
countActivePeers
in interface Transport
countActivePeers
in class TransportImpl
public int countActiveSendPeers()
countActiveSendPeers
in interface Transport
countActiveSendPeers
in class TransportImpl
void setLastBadSkew(long skew)
skew
- in secondspublic Vector<Long> getClockSkews()
getClockSkews
in interface Transport
getClockSkews
in class TransportImpl
public RouterAddress startListening()
public RouterAddress restartListening(RouterAddress addr)
public boolean isAlive()
Reader getReader()
Writer getWriter()
public String getStyle()
EventPumper getPumper()
void establishing(NTCPConnection con)
void expireTimedOut()
public void forwardPortStatus(int port, boolean success, String reason)
forwardPortStatus
in interface Transport
forwardPortStatus
in class TransportImpl
public int getRequestedPort()
TransportImpl
getRequestedPort
in interface Transport
getRequestedPort
in class TransportImpl
public short getReachabilityStatus()
getReachabilityStatus
in interface Transport
getReachabilityStatus
in class TransportImpl
public void stopListening()
public void renderStatusHTML(Writer out, int sortFlags) throws IOException
IOException
public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException
renderStatusHTML
in interface Transport
renderStatusHTML
in class TransportImpl
IOException