Transport
NTCPTransport
, UDPTransport
public abstract class TransportImpl extends java.lang.Object implements Transport
Transport.AddressSource
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected RouterContext |
_context |
|
protected java.util.List<RouterAddress> |
_currentAddresses |
|
protected static boolean |
ADJUST_COST |
Do we increase the advertised cost when approaching conn limits?
|
protected static int |
CONGESTION_COST_ADJUSTMENT |
TODO change to 2
|
コンストラクタ | 説明 |
---|---|
TransportImpl(RouterContext context) |
Initialize the new transport
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
protected java.lang.String |
_t(java.lang.String s) |
Translate
|
protected java.lang.String |
_t(java.lang.String s,
java.lang.Object o) |
Translate
|
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
|
boolean |
allowLocal() |
Are we allowed to connect to local addresses?
|
(package private) static void |
clearCaches() |
|
abstract int |
countActivePeers() |
How many peers are we currently connected to, that we have
sent a message to or received a message from in the last five minutes.
|
abstract int |
countActiveSendPeers() |
How many peers are we currently connected to, that we have
sent a message to in the last minute.
|
abstract int |
countPeers() |
How many peers are we connected to?
|
abstract void |
externalAddressReceived(Transport.AddressSource source,
byte[] ip,
int port) |
Notify a transport of an external address change.
|
void |
externalAddressRemoved(Transport.AddressSource source,
boolean ipv6) |
Notify a transport of an external address change.
|
void |
forwardPortStatus(byte[] ip,
int port,
int externalPort,
boolean success,
java.lang.String reason) |
Notify a transport of the results of trying to forward a port.
|
java.util.Vector<java.lang.Long> |
getClockSkews() |
Return our peer clock skews on a transport.
|
RouterAddress |
getCurrentAddress(boolean ipv6) |
What address are we currently listening to?
Replaces getCurrentAddress()
|
java.util.List<RouterAddress> |
getCurrentAddresses() |
What addresses are we currently listening to?
Replaces getCurrentAddress()
|
static byte[] |
getIP(Hash peer) |
IP of the peer from the last connection (in or out, any transport).
|
TransportUtil.IPv6Config |
getIPv6Config() |
|
int |
getMaxConnections() |
Per-transport connection limit
|
java.util.List<java.lang.String> |
getMostRecentErrorMessages() |
|
protected OutNetMessage |
getNextMessage() |
Nonblocking call to pull the next outbound message
off the queue.
|
abstract CommSystemFacade.Status |
getReachabilityStatus() |
Previously returned short, now enum as of 0.9.20
|
int |
getRequestedPort() |
What INTERNAL port would the transport like to have forwarded by UPnP.
|
protected java.util.Collection<java.net.InetAddress> |
getSavedLocalAddresses() |
Return and then clear all saved local addresses.
|
protected java.util.List<RouterAddress> |
getTargetAddresses(RouterInfo target) |
Get all available address we can use,
shuffled and then sorted by cost/preference.
|
boolean |
hasCurrentAddress() |
Do we have any current address?
|
boolean |
haveCapacity() |
Can we initiate or accept a connection to another peer, saving some margin
|
boolean |
haveCapacity(int pct) |
|
boolean |
isBacklogged(Hash peer) |
|
boolean |
isEstablished(Hash peer) |
|
boolean |
isIPv4Firewalled() |
This returns true if the force-firewalled setting is configured, false otherwise.
|
boolean |
isIPv6Firewalled() |
This returns true if the force-firewalled setting is configured, false otherwise.
|
protected boolean |
isPubliclyRoutable(byte[] addr) |
Allows IPv6 only if the transport is configured for it.
|
boolean |
isUnreachable(Hash peer) |
|
void |
markReachable(Hash peer,
boolean isInbound) |
called when we establish a peer connection (outbound or inbound)
|
void |
markUnreachable(Hash peer) |
called when we can't reach a peer
|
void |
mayDisconnect(Hash peer) |
Tell the transport that we may disconnect from this peer.
|
void |
messageReceived(I2NPMessage inMsg,
RouterIdentity remoteIdent,
Hash remoteIdentHash,
long msToReceive,
int bytesReceived) |
Message received from the I2NPMessageReader - send it to the listener
|
protected java.lang.String |
ngettext(java.lang.String s,
java.lang.String p,
int n) |
Translate
|
protected abstract void |
outboundMessageReady() |
This message is called whenever a new message is added to the send pool,
and it should not block
Only used by NTCP.
|
void |
recheckReachability() |
推奨されていません。
unused
|
protected void |
removeAddress(boolean ipv6) |
Remove all existing addresses with the specified IP length (4 or 16).
|
protected void |
removeAddress(RouterAddress address) |
Remove only this address.
|
void |
renderStatusHTML(java.io.Writer out) |
Make this stuff pretty (only used in the old console)
|
void |
renderStatusHTML(java.io.Writer out,
java.lang.String urlBase,
int sortFlags) |
|
protected void |
replaceAddress(RouterAddress address) |
Replace any existing addresses for the current transport
with the same IP length (4 or 16) with the given one.
|
protected void |
saveLocalAddress(java.net.InetAddress address) |
Save a local address we were notified about before we started.
|
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) |
IP of the peer from the last connection (in or out, any transport).
|
void |
setListener(TransportEventListener listener) |
Who to notify on message availability
|
java.util.List<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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bid, getEstablished, getStyle, startListening, stopListening
protected final java.util.List<RouterAddress> _currentAddresses
protected final RouterContext _context
protected static final boolean ADJUST_COST
protected static final int CONGESTION_COST_ADJUSTMENT
public TransportImpl(RouterContext context)
public abstract int countPeers()
countPeers
インタフェース内 Transport
public abstract int countActivePeers()
countActivePeers
インタフェース内 Transport
public abstract int countActiveSendPeers()
countActiveSendPeers
インタフェース内 Transport
public int getMaxConnections()
public boolean haveCapacity()
haveCapacity
インタフェース内 Transport
public boolean haveCapacity(int pct)
haveCapacity
インタフェース内 Transport
pct
- are we under x% 0-100public java.util.Vector<java.lang.Long> getClockSkews()
getClockSkews
インタフェース内 Transport
public java.util.List<java.lang.String> getMostRecentErrorMessages()
getMostRecentErrorMessages
インタフェース内 Transport
protected 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)
protected abstract void outboundMessageReady()
public void messageReceived(I2NPMessage inMsg, RouterIdentity remoteIdent, Hash remoteIdentHash, long msToReceive, int bytesReceived)
inMsg
- non-nullremoteIdent
- may be nullremoteIdentHash
- may be null, calculated from remoteIdent if nullpublic java.util.List<RouterAddress> getCurrentAddresses()
getCurrentAddresses
インタフェース内 Transport
public RouterAddress getCurrentAddress(boolean ipv6)
ipv6
- true for IPv6 only; false for IPv4 onlypublic boolean hasCurrentAddress()
hasCurrentAddress
インタフェース内 Transport
public java.util.List<RouterAddress> updateAddress()
updateAddress
インタフェース内 Transport
protected void replaceAddress(RouterAddress address)
address
- null to remove allprotected void removeAddress(RouterAddress address)
protected void removeAddress(boolean ipv6)
ipv6
- true to remove all IPv6 addresses, false to remove all IPv4 addressesprotected void saveLocalAddress(java.net.InetAddress address)
protected java.util.Collection<java.net.InetAddress> getSavedLocalAddresses()
protected java.util.List<RouterAddress> getTargetAddresses(RouterInfo target)
public abstract void externalAddressReceived(Transport.AddressSource source, byte[] ip, int port)
externalAddressReceived
インタフェース内 Transport
source
- defined in Transport.javaip
- typ. IPv4 or IPv6 non-local; may be null to indicate IPv4 failure or port info onlyport
- 0 for unknown or unchangedpublic void externalAddressRemoved(Transport.AddressSource source, boolean ipv6)
externalAddressRemoved
インタフェース内 Transport
source
- defined in Transport.javapublic void forwardPortStatus(byte[] ip, int port, int externalPort, boolean success, java.lang.String reason)
forwardPortStatus
インタフェース内 Transport
ip
- may be nullport
- 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
インタフェース内 Transport
public void setListener(TransportEventListener listener)
setListener
インタフェース内 Transport
public void renderStatusHTML(java.io.Writer out) throws java.io.IOException
java.io.IOException
public void renderStatusHTML(java.io.Writer out, java.lang.String urlBase, int sortFlags) throws java.io.IOException
renderStatusHTML
インタフェース内 Transport
java.io.IOException
public abstract CommSystemFacade.Status getReachabilityStatus()
getReachabilityStatus
インタフェース内 Transport
@Deprecated public void recheckReachability()
recheckReachability
インタフェース内 Transport
public boolean isIPv4Firewalled()
public boolean isIPv6Firewalled()
public boolean isBacklogged(Hash peer)
isBacklogged
インタフェース内 Transport
public boolean isEstablished(Hash peer)
isEstablished
インタフェース内 Transport
public void mayDisconnect(Hash peer)
mayDisconnect
インタフェース内 Transport
public boolean isUnreachable(Hash peer)
isUnreachable
インタフェース内 Transport
public void markUnreachable(Hash peer)
public void markReachable(Hash peer, boolean isInbound)
public boolean wasUnreachable(Hash peer)
wasUnreachable
インタフェース内 Transport
public boolean allowLocal()
public void setIP(Hash peer, byte[] ip)
ip
- IPv4 or IPv6, non-nullpublic static byte[] getIP(Hash peer)
static void clearCaches()
public TransportUtil.IPv6Config getIPv6Config()
protected boolean isPubliclyRoutable(byte[] addr)
addr
- non-nullprotected java.lang.String _t(java.lang.String s)
protected java.lang.String _t(java.lang.String s, java.lang.Object o)
protected java.lang.String ngettext(java.lang.String s, java.lang.String p, int n)