public class NTCPTransport extends TransportImpl
Transport.AddressSource| 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 |
MIN_SIGTYPE_VERSION
RI sigtypes supported in 0.9.16
|
(package private) static int |
NTCP2_INT_VERSION |
(package private) static String |
NTCP2_VERSION
"2"
|
(package private) static String |
NTCP2_VERSION_ALT
"2,"
|
static String |
PROP_BIND_INTERFACE
this is rarely if ever used, default is to bind to wildcard address
|
static String |
PROP_I2NP_NTCP_AUTO_IP |
static String |
PROP_I2NP_NTCP_AUTO_PORT |
static String |
PROP_I2NP_NTCP_HOSTNAME |
static String |
PROP_I2NP_NTCP_PORT |
static String |
PROP_NTCP2_IV
b64 static IV
|
static String |
PROP_NTCP2_SP
b64 static private key
|
static String |
STYLE |
static String |
STYLE2 |
_context, _currentAddresses, ADJUST_COST, CONGESTION_COST_ADJUSTMENT, PROP_IPV6_FIREWALLED| Constructor and Description |
|---|
NTCPTransport(RouterContext ctx,
DHSessionKeyBuilder.Factory dh,
X25519KeyFactory xdh) |
| 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,
int dataSize) |
int |
countActivePeers()
How many peers have we talked to in the last 5 minutes?
As of 0.9.20, actually returns active peer count, not total.
|
int |
countActiveSendPeers()
How many peers are we actively sending messages to (this minute)
|
int |
countPeers()
How many peers are we connected to?
|
(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 |
externalAddressReceived(Transport.AddressSource source,
byte[] ip,
int port)
UDP changed addresses, tell NTCP and (possibly) restart
|
void |
externalAddressRemoved(Transport.AddressSource source,
boolean ipv6)
Notify a transport of an external address change.
|
void |
forceDisconnect(net.i2p.data.Hash peer)
Tell the transport to disconnect from this peer.
|
void |
forwardPortStatus(byte[] ip,
int port,
int externalPort,
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.
|
String |
getAltStyle()
An alternate supported style, or null.
|
List<Long> |
getClockSkews()
Return our peer clock skews on this transport.
|
(package private) DHSessionKeyBuilder |
getDHBuilder() |
Set<net.i2p.data.Hash> |
getEstablished()
Connected peers.
|
(package private) byte[] |
getNTCP2StaticIV()
The static IV
|
(package private) byte[] |
getNTCP2StaticPrivkey()
The static priv key
|
(package private) byte[] |
getNTCP2StaticPubkey()
The static priv key
|
Collection<NTCPConnection> |
getPeers()
For /peers UI only.
|
(package private) EventPumper |
getPumper()
Hook for NTCPConnection
|
CommSystemFacade.Status |
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()
Hook for NTCPConnection
|
int |
getRequestedPort()
What INTERNAL port would the transport like to have forwarded by UPnP.
|
String |
getStyle()
The unique identity of this Transport
|
(package private) Writer |
getWriter()
Hook for NTCPConnection
|
(package private) X25519KeyFactory |
getXDHFactory() |
(package private) NTCPConnection |
inboundEstablished(NTCPConnection con) |
boolean |
isAlive() |
boolean |
isBacklogged(net.i2p.data.Hash dest) |
boolean |
isEstablished(net.i2p.data.Hash dest) |
(package private) boolean |
isHXHIValid(byte[] hxhi)
Incoming connection replay detection.
|
(package private) boolean |
isNTCP1Enabled()
Is NTCP1 enabled?
|
(package private) boolean |
isNTCP2Enabled()
Is NTCP2 enabled?
|
void |
mayDisconnect(net.i2p.data.Hash peer)
Tell the transport that we may disconnect from this peer.
|
protected 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.
|
(package private) NTCPConnection |
removeCon(NTCPConnection con) |
void |
renderStatusHTML(Writer out,
int sortFlags) |
void |
renderStatusHTML(Writer out,
String urlBase,
int sortFlags)
Deprecated.
as of 0.9.31
|
(package private) void |
returnUnused(DHSessionKeyBuilder builder)
Return an unused DH key builder
to be put back onto the queue for reuse.
|
(package private) void |
sendComplete(OutNetMessage msg)
queue up afterSend call, which can take some time w/ jobs, etc
|
(package private) void |
setLastBadSkew(long skew)
A positive number means our clock is ahead of theirs.
|
void |
startListening()
Called by TransportManager.
|
void |
stopListening()
This doesn't (completely) block, caller should check isAlive()
before calling startListening() or restartListening()
|
_t, _t, afterSend, afterSend, afterSend, allowLocal, getCurrentAddress, getCurrentAddresses, getIP, getIPv6Config, getMaxConnections, getMostRecentErrorMessages, getNextMessage, getSavedLocalAddresses, getTargetAddresses, hasCurrentAddress, haveCapacity, haveCapacity, isIPv4Firewalled, isIPv6Firewalled, isPubliclyRoutable, isUnreachable, markReachable, markUnreachable, messageReceived, ngettext, recheckReachability, removeAddress, removeAddress, renderStatusHTML, replaceAddress, saveLocalAddress, send, setIP, setListener, updateAddress, wasUnreachablepublic static final String PROP_I2NP_NTCP_HOSTNAME
public static final String PROP_I2NP_NTCP_PORT
public static final String PROP_I2NP_NTCP_AUTO_PORT
public static final String PROP_I2NP_NTCP_AUTO_IP
public static final String PROP_BIND_INTERFACE
public static final String MIN_SIGTYPE_VERSION
public static final String STYLE
public static final String STYLE2
static final int NTCP2_INT_VERSION
static final String NTCP2_VERSION
static final String NTCP2_VERSION_ALT
public static final String PROP_NTCP2_SP
public static final String PROP_NTCP2_IV
public static final int ESTABLISH_TIMEOUT
public NTCPTransport(RouterContext ctx, DHSessionKeyBuilder.Factory dh, X25519KeyFactory xdh)
dh - null to disable NTCP1xdh - null to disable NTCP2NTCPConnection inboundEstablished(NTCPConnection con)
con - that is establishedprotected void outboundMessageReady()
TransportImploutboundMessageReady in class TransportImplpublic void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend)
TransportImplafterSend in class TransportImplmsg - 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, int dataSize)
dataSize - assumes full 16-byte header, transports should
adjust as necessarypublic boolean allowConnection()
void sendComplete(OutNetMessage msg)
public boolean isEstablished(net.i2p.data.Hash dest)
isEstablished in interface TransportisEstablished in class TransportImplpublic boolean isBacklogged(net.i2p.data.Hash dest)
isBacklogged in interface TransportisBacklogged in class TransportImplpublic void mayDisconnect(net.i2p.data.Hash peer)
mayDisconnect in interface TransportmayDisconnect in class TransportImplpublic void forceDisconnect(net.i2p.data.Hash peer)
NTCPConnection removeCon(NTCPConnection con)
public int countPeers()
TransportImplcountPeers in interface TransportcountPeers in class TransportImplpublic Collection<NTCPConnection> getPeers()
public Set<net.i2p.data.Hash> getEstablished()
public int countActivePeers()
countActivePeers in interface TransportcountActivePeers in class TransportImplpublic int countActiveSendPeers()
countActiveSendPeers in interface TransportcountActiveSendPeers in class TransportImplvoid setLastBadSkew(long skew)
skew - in secondspublic List<Long> getClockSkews()
getClockSkews in interface TransportgetClockSkews in class TransportImplboolean isHXHIValid(byte[] hxhi)
hxhi - using first 8 bytes onlypublic void startListening()
public boolean isAlive()
Reader getReader()
Writer getWriter()
public String getStyle()
Transportpublic String getAltStyle()
getAltStyle in class TransportImplEventPumper getPumper()
DHSessionKeyBuilder getDHBuilder()
X25519KeyFactory getXDHFactory()
void returnUnused(DHSessionKeyBuilder builder)
builder - must not have a peerPublicValue setvoid establishing(NTCPConnection con)
void expireTimedOut()
boolean isNTCP1Enabled()
boolean isNTCP2Enabled()
byte[] getNTCP2StaticPubkey()
byte[] getNTCP2StaticPrivkey()
byte[] getNTCP2StaticIV()
public void externalAddressReceived(Transport.AddressSource source, byte[] ip, int port)
externalAddressReceived in interface TransportexternalAddressReceived in class TransportImplip - typ. IPv4 or IPv6 non-local; may be null to indicate IPv4 failure or port info onlysource - defined in Transport.javaport - 0 for unknown or unchangedpublic void externalAddressRemoved(Transport.AddressSource source, boolean ipv6)
externalAddressRemoved in interface TransportexternalAddressRemoved in class TransportImplsource - defined in Transport.javapublic void forwardPortStatus(byte[] ip,
int port,
int externalPort,
boolean success,
String reason)
forwardPortStatus in interface TransportforwardPortStatus in class TransportImplip - 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()
TransportImplgetRequestedPort in interface TransportgetRequestedPort in class TransportImplpublic CommSystemFacade.Status getReachabilityStatus()
getReachabilityStatus in interface TransportgetReachabilityStatus in class TransportImplpublic void stopListening()
public void renderStatusHTML(Writer out, int sortFlags) throws IOException
IOException@Deprecated public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException
renderStatusHTML in interface TransportrenderStatusHTML in class TransportImplIOException