Package net.i2p.router.transport.ntcp
Class EstablishBase
java.lang.Object
net.i2p.router.transport.ntcp.EstablishBase
- All Implemented Interfaces:
EstablishState
- Direct Known Subclasses:
InboundEstablishState
abstract class EstablishBase extends Object implements EstablishState
Inbound NTCP 2 only.
OutboundNTCP2State does not extend this.
- Since:
- 0.9.35 pulled out of EstablishState
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
EstablishBase.State
-
Field Summary
Fields Modifier and Type Field Description protected NTCPConnection
_con
protected RouterContext
_context
protected byte[]
_curDecrypted
decryption bufferprotected byte[]
_e_bobSig
protected byte[]
_e_hXY_tsB
protected byte[]
_hX_xor_bobIdentHash
protected Log
_log
protected long
_peerSkew
OUR clock minus HIS clock, in seconds Inbound: tsB - tsA - rtt/2 Outbound: tsA - tsB - rtt/2protected byte[]
_prevEncrypted
previously received encrypted block (or the IV)protected int
_received
bytes received so farprotected EstablishBase.State
_state
protected Object
_stateLock
protected NTCPTransport
_transport
protected long
_tsA
Alice's timestamp in seconds, this is in message #3, *after* _tsB Only saved for outbound.protected long
_tsB
Bob's timestamp in seconds, this is in message #2, *before* _tsAprotected byte[]
_X
protected byte[]
_Y
protected static int
AES_SIZE
static net.i2p.router.transport.ntcp.EstablishBase.FailedEstablishState
FAILED
protected static int
HXY_SIZE
protected static int
HXY_TSB_PAD_SIZE
protected static int
MAX_RI_SIZE
protected static int
MIN_RI_SIZE
protected static Set<EstablishBase.State>
STATES_DONE
static net.i2p.router.transport.ntcp.EstablishBase.VerifiedEstablishState
VERIFIED
protected static int
XY_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description protected
EstablishBase(RouterContext ctx, NTCPTransport transport, NTCPConnection con)
-
Method Summary
Modifier and Type Method Description protected static String
_x(String s)
Mark a string for extraction by xgettext and translation.protected void
changeState(EstablishBase.State state)
void
close(String reason, Exception e)
Release resources on timeout.protected void
fail(String reason)
Caller must synch.protected void
fail(String reason, Exception e)
Caller must synch.protected void
fail(String reason, Exception e, boolean bySkew)
Caller must synch.abstract int
getVersion()
Get the NTCP versionboolean
isComplete()
If synchronized on this, fails with deadlocks from all over via CSFI.isEstablished().boolean
isCorrupt()
did the handshake fail for some reason?protected String
prefix()
void
prepareOutbound()
Does nothing.void
receive(ByteBuffer src)
Parse the contents of the buffer as part of the handshake.protected void
releaseBufs(boolean isVerified)
Only call once.String
toString()
protected static void
xor32(byte[] a, byte[] b)
XOR a into b.
-
Field Details
-
VERIFIED
public static final net.i2p.router.transport.ntcp.EstablishBase.VerifiedEstablishState VERIFIED -
FAILED
public static final net.i2p.router.transport.ntcp.EstablishBase.FailedEstablishState FAILED -
_context
-
_log
-
_X
protected final byte[] _X -
_hX_xor_bobIdentHash
protected final byte[] _hX_xor_bobIdentHash -
_Y
protected final byte[] _Y -
_e_hXY_tsB
protected final byte[] _e_hXY_tsB -
_tsB
protected transient long _tsBBob's timestamp in seconds, this is in message #2, *before* _tsA -
_tsA
protected transient long _tsAAlice's timestamp in seconds, this is in message #3, *after* _tsB Only saved for outbound. For inbound, see verifyInbound(). -
_peerSkew
protected transient long _peerSkewOUR clock minus HIS clock, in seconds Inbound: tsB - tsA - rtt/2 Outbound: tsA - tsB - rtt/2 -
_e_bobSig
protected transient byte[] _e_bobSig -
_prevEncrypted
protected byte[] _prevEncryptedpreviously received encrypted block (or the IV) -
_curDecrypted
protected final byte[] _curDecrypteddecryption buffer -
_received
protected int _receivedbytes received so far -
_transport
-
_con
-
MIN_RI_SIZE
protected static final int MIN_RI_SIZE- See Also:
- Constant Field Values
-
MAX_RI_SIZE
protected static final int MAX_RI_SIZE- See Also:
- Constant Field Values
-
AES_SIZE
protected static final int AES_SIZE- See Also:
- Constant Field Values
-
XY_SIZE
protected static final int XY_SIZE- See Also:
- Constant Field Values
-
HXY_SIZE
protected static final int HXY_SIZE- See Also:
- Constant Field Values
-
HXY_TSB_PAD_SIZE
protected static final int HXY_TSB_PAD_SIZE- See Also:
- Constant Field Values
-
_stateLock
-
_state
-
STATES_DONE
-
-
Constructor Details
-
Method Details
-
changeState
- Since:
- 0.9.16
-
receive
Parse the contents of the buffer as part of the handshake. All data must be copied out of the buffer as Reader.processRead() will return it to the pool. If there are additional data in the buffer after the handshake is complete, the EstablishState is responsible for passing it to NTCPConnection.- Specified by:
receive
in interfaceEstablishState
-
prepareOutbound
public void prepareOutbound()Does nothing. Outbound (Alice) must override. We are establishing an outbound connection, so prepare ourselves by queueing up the write of the first part of the handshake- Specified by:
prepareOutbound
in interfaceEstablishState
-
isCorrupt
public boolean isCorrupt()did the handshake fail for some reason?- Specified by:
isCorrupt
in interfaceEstablishState
-
isComplete
public boolean isComplete()If synchronized on this, fails with deadlocks from all over via CSFI.isEstablished(). Also CSFI.getFramedAveragePeerClockSkew().- Specified by:
isComplete
in interfaceEstablishState
- Returns:
- is the handshake complete and valid?
-
getVersion
public abstract int getVersion()Get the NTCP version- Specified by:
getVersion
in interfaceEstablishState
- Returns:
- 1, 2, or 0 if unknown
- Since:
- 0.9.35
-
close
Release resources on timeout.- Specified by:
close
in interfaceEstablishState
- Parameters:
e
- may be null- Since:
- 0.9.16
-
fail
Caller must synch. -
fail
Caller must synch. -
fail
Caller must synch. -
releaseBufs
protected void releaseBufs(boolean isVerified)Only call once. Caller must synch.- Since:
- 0.9.16
-
xor32
protected static void xor32(byte[] a, byte[] b)XOR a into b. Modifies b. a is unmodified.- Parameters:
a
- 32 bytesb
- 32 bytes- Since:
- 0.9.12
-
prefix
-
toString
-
_x
Mark a string for extraction by xgettext and translation. Use this only in static initializers. It does not translate!- Returns:
- s
-