|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.transport.TransportImpl
public abstract class TransportImpl
Defines a way to send a message to another peer and start listening for messages
Field Summary | |
---|---|
protected RouterContext |
_context
|
static boolean |
ADJUST_COST
Do we increase the advertised cost when approaching conn limits? |
Fields inherited from interface net.i2p.router.transport.Transport |
---|
SOURCE_CONFIG, SOURCE_INTERFACE, SOURCE_UPNP |
Constructor Summary | |
---|---|
TransportImpl(RouterContext context)
Initialize the new transport |
Method Summary | |
---|---|
protected void |
afterSend(OutNetMessage msg,
boolean sendSuccessful)
The transport is done sending this message |
protected void |
afterSend(OutNetMessage msg,
boolean sendSuccessful,
boolean allowRequeue)
The transport is done sending this message |
protected void |
afterSend(OutNetMessage msg,
boolean sendSuccessful,
boolean allowRequeue,
long msToSend)
The transport is done sending this message. |
protected void |
afterSend(OutNetMessage msg,
boolean sendSuccessful,
long msToSend)
The transport is done sending this message |
(package private) static void |
clearCaches()
|
int |
countActivePeers()
How many peers active in the last few minutes? |
int |
countActiveSendPeers()
How many peers are we actively sending messages to (this minute) |
int |
countPeers()
How many peers are we connected to? For NTCP, this is the same as active, but SSU actually looks at idle time for countActivePeers() |
void |
externalAddressReceived(String source,
byte[] ip,
int port)
Notify a transport of an external address change. |
void |
forwardPortStatus(int port,
int externalPort,
boolean success,
String reason)
Notify a transport of the results of trying to forward a port. |
Vector |
getClockSkews()
Return our peer clock skews on a transport. |
RouterContext |
getContext()
|
RouterAddress |
getCurrentAddress()
What addresses are we currently listening to? |
static byte[] |
getIP(Hash peer)
|
int |
getMaxConnections()
Per-transport connection limit |
List |
getMostRecentErrorMessages()
|
OutNetMessage |
getNextMessage()
Nonblocking call to pull the next outbound message off the queue. |
short |
getReachabilityStatus()
|
int |
getRequestedPort()
What port would the transport like to have forwarded by UPnP. |
boolean |
haveCapacity()
Can we initiate or accept a connection to another peer, saving some margin |
boolean |
haveCapacity(int pct)
|
boolean |
isBacklogged(Hash dest)
|
boolean |
isEstablished(Hash dest)
|
static boolean |
isPubliclyRoutable(byte[] addr)
|
boolean |
isUnreachable(Hash peer)
|
void |
markReachable(Hash peer,
boolean isInbound)
called when we establish a peer connection (outbound or inbound) |
void |
markUnreachable(Hash peer)
This isn't very useful since it is cleared when they contact us |
void |
markWasUnreachable(Hash peer,
boolean yes)
Maintain the WasUnreachable list |
void |
messageReceived(I2NPMessage inMsg,
RouterIdentity remoteIdent,
Hash remoteIdentHash,
long msToReceive,
int bytesReceived)
Message received from the I2NPMessageReader - send it to the listener |
protected abstract void |
outboundMessageReady()
This message is called whenever a new message is added to the send pool, and it should not block |
void |
recheckReachability()
|
void |
renderStatusHTML(Writer out)
Make this stuff pretty (only used in the old console) |
void |
renderStatusHTML(Writer out,
String urlBase,
int sortFlags)
|
protected void |
replaceAddress(RouterAddress address)
Replace any existing addresses for the current transport with the given one. |
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). |
void |
setIP(Hash peer,
byte[] ip)
|
void |
setListener(TransportEventListener listener)
Who to notify on message availability |
RouterAddress |
updateAddress()
Ask the transport to update its address based on current information and return it Transports should override. |
boolean |
wasUnreachable(Hash peer)
Was the peer UNreachable (outbound only) the last time we tried it? This is NOT reset if the peer contacts us and it is never expired. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.i2p.router.transport.Transport |
---|
bid, getStyle, startListening, stopListening |
Field Detail |
---|
protected final RouterContext _context
public static final boolean ADJUST_COST
Constructor Detail |
---|
public TransportImpl(RouterContext context)
Method Detail |
---|
public int countPeers()
countPeers
in interface Transport
public int countActivePeers()
countActivePeers
in interface Transport
public int countActiveSendPeers()
countActiveSendPeers
in interface Transport
public int getMaxConnections()
public boolean haveCapacity()
haveCapacity
in interface Transport
public boolean haveCapacity(int pct)
haveCapacity
in interface Transport
pct
- are we under x% 0-100public Vector getClockSkews()
getClockSkews
in interface Transport
public List getMostRecentErrorMessages()
getMostRecentErrorMessages
in interface Transport
public OutNetMessage getNextMessage()
protected void afterSend(OutNetMessage msg, boolean sendSuccessful)
msg
- message in questionsendSuccessful
- true if the peer received itprotected void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue)
msg
- message in questionsendSuccessful
- true if the peer received itallowRequeue
- true if we should try other transports if availableprotected void afterSend(OutNetMessage msg, boolean sendSuccessful, long msToSend)
msg
- message in questionsendSuccessful
- true if the peer received itmsToSend
- how long it took to transfer the data to the peerprotected void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend)
msg
- message in questionsendSuccessful
- true if the peer received itmsToSend
- how long it took to transfer the data to the peerallowRequeue
- true if we should try other transports if availablepublic void send(OutNetMessage msg)
send
in interface Transport
protected abstract void outboundMessageReady()
public void messageReceived(I2NPMessage inMsg, RouterIdentity remoteIdent, Hash remoteIdentHash, long msToReceive, int bytesReceived)
public RouterAddress getCurrentAddress()
getCurrentAddress
in interface Transport
public RouterAddress updateAddress()
updateAddress
in interface Transport
protected void replaceAddress(RouterAddress address)
public void externalAddressReceived(String source, byte[] ip, int port)
externalAddressReceived
in interface Transport
source
- defined in Transport.javaip
- typ. IPv4 non-localport
- 0 for unknown or unchangedpublic void forwardPortStatus(int port, int externalPort, boolean success, String reason)
forwardPortStatus
in interface Transport
port
- the internal portexternalPort
- the external port, which for now should always be the same as
the internal port if the forwarding was successful.public int getRequestedPort()
getRequestedPort
in interface Transport
public void setListener(TransportEventListener listener)
setListener
in interface Transport
public void renderStatusHTML(Writer out) throws IOException
IOException
public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException
renderStatusHTML
in interface Transport
IOException
public RouterContext getContext()
public short getReachabilityStatus()
getReachabilityStatus
in interface Transport
public void recheckReachability()
recheckReachability
in interface Transport
public boolean isBacklogged(Hash dest)
isBacklogged
in interface Transport
public boolean isEstablished(Hash dest)
isEstablished
in interface Transport
public boolean isUnreachable(Hash peer)
isUnreachable
in interface Transport
public void markUnreachable(Hash peer)
public void markReachable(Hash peer, boolean isInbound)
public boolean wasUnreachable(Hash peer)
wasUnreachable
in interface Transport
public void markWasUnreachable(Hash peer, boolean yes)
public void setIP(Hash peer, byte[] ip)
public static byte[] getIP(Hash peer)
static void clearCaches()
public static boolean isPubliclyRoutable(byte[] addr)
addr
- non-null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |