Package net.i2p.router.transport.udp
Class InboundEstablishState
- java.lang.Object
-
- net.i2p.router.transport.udp.InboundEstablishState
-
- Direct Known Subclasses:
InboundEstablishState2
class InboundEstablishState extends Object
Data for a new connection being established, where the remote peer has initiated the connection with us. In other words, they are Alice and we are Bob. TODO do all these methods need to be synchronized?
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInboundEstablishState.InboundState
-
Field Summary
Fields Modifier and Type Field Description protected byte[]_aliceIPprotected int_alicePortprotected byte[]_bobIPprotected int_bobPortprotected RouterContext_contextprotected int_createdSentCountprotected InboundEstablishState.InboundState_currentStateprotected long_establishBeginprotected boolean_introductionRequestedprotected long_lastSendprotected Log_logprotected long_nextSendprotected RouterIdentity_receivedConfirmedIdentityprotected RouterIdentity_receivedUnconfirmedIdentityprotected RemoteHostId_remoteHostIdprotected int_rttprotected long_sentRelayTagprotected static longMAX_DELAYmax delay including backoff This should be a little shorter than for outbound.protected static longRETRANSMIT_DELAYbasic delay before backoff Transmissions at 0, 1, 3, 7 sec This should be a little shorter than for outbound.
-
Constructor Summary
Constructors Modifier Constructor Description InboundEstablishState(RouterContext ctx, byte[] remoteIP, int remotePort, int localPort, DHSessionKeyBuilder dh, UDPPacketReader.SessionRequestReader req)protectedInboundEstablishState(RouterContext ctx, InetSocketAddress addr)For SSU2
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessage(OutNetMessage msg)Queue a message to be sent after the session is established.voidcomplete()Notify successful completionprotected booleanconfirmedFullyReceived()Have we fully received the SessionConfirmed messages from Alice? Caller must synch on this.voidcreatedPacketSent()note that we just sent a SessionCreated packetvoidfail()voidgenerateSessionKey()Generates session key and mac key.SessionKeygetCipherKey()RouterIdentitygetConfirmedIdentity()Who is Alice (null if forged/unknown) Note that this isn't really confirmed - see below.longgetEstablishBeginTime()longgetLifetime()how long have we been trying to establish this session?longgetLifetime(long now)how long have we been trying to establish this session?SessionKeygetMACKey()OutNetMessagegetNextQueuedMessage()Pull from the message queuelonggetNextSendTime()byte[]getReceivedOurIP()byte[]getReceivedX()(package private) RemoteHostIdgetRemoteHostId()RemoteHostId, uniquely identifies an attempt(package private) intgetRTT()byte[]getSentIP()what IP do they appear to be on?intgetSentPort()what port number do they appear to be coming from?longgetSentRelayTag()SignaturegetSentSignature()longgetSentSignedOnTime()byte[]getSentY()InboundEstablishState.InboundStategetState()intgetVersion()booleanisComplete()booleanisIntroductionRequested()True (default) if no extended options in session request, or value of flag bit in the extended options.protected voidpacketReceived()Call from synchronized method onlyvoidprepareSessionCreated()voidreceiveSessionConfirmed(UDPPacketReader.SessionConfirmedReader conf)Note that while a SessionConfirmed could in theory be fragmented, in practice a RouterIdentity is 387 bytes and a single fragment is 512 bytes max, so it will never be fragmented.voidreceiveSessionRequest(UDPPacketReader.SessionRequestReader req)booleansessionRequestReceived()voidsetSentRelayTag(long tag)StringtoString()
-
-
-
Field Detail
-
_context
protected final RouterContext _context
-
_log
protected final Log _log
-
_bobIP
protected byte[] _bobIP
-
_bobPort
protected final int _bobPort
-
_aliceIP
protected final byte[] _aliceIP
-
_alicePort
protected final int _alicePort
-
_sentRelayTag
protected long _sentRelayTag
-
_receivedUnconfirmedIdentity
protected RouterIdentity _receivedUnconfirmedIdentity
-
_receivedConfirmedIdentity
protected RouterIdentity _receivedConfirmedIdentity
-
_establishBegin
protected final long _establishBegin
-
_lastSend
protected long _lastSend
-
_nextSend
protected long _nextSend
-
_remoteHostId
protected final RemoteHostId _remoteHostId
-
_currentState
protected InboundEstablishState.InboundState _currentState
-
_createdSentCount
protected int _createdSentCount
-
_introductionRequested
protected boolean _introductionRequested
-
_rtt
protected int _rtt
-
RETRANSMIT_DELAY
protected static final long RETRANSMIT_DELAY
basic delay before backoff Transmissions at 0, 1, 3, 7 sec This should be a little shorter than for outbound.- See Also:
- Constant Field Values
-
MAX_DELAY
protected static final long MAX_DELAY
max delay including backoff This should be a little shorter than for outbound.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InboundEstablishState
public InboundEstablishState(RouterContext ctx, byte[] remoteIP, int remotePort, int localPort, DHSessionKeyBuilder dh, UDPPacketReader.SessionRequestReader req)
- Parameters:
localPort- Must be our external port, otherwise the signature of the SessionCreated message will be bad if the external port != the internal port.
-
InboundEstablishState
protected InboundEstablishState(RouterContext ctx, InetSocketAddress addr)
For SSU2- Since:
- 0.9.54
-
-
Method Detail
-
getVersion
public int getVersion()
- Since:
- 0.9.54
-
getState
public InboundEstablishState.InboundState getState()
-
isComplete
public boolean isComplete()
- Returns:
- if previously complete
-
complete
public void complete()
Notify successful completion
-
addMessage
public void addMessage(OutNetMessage msg)
Queue a message to be sent after the session is established. This will only happen if we decide to send something during establishment- Since:
- 0.9.2
-
getNextQueuedMessage
public OutNetMessage getNextQueuedMessage()
Pull from the message queue- Returns:
- null if none
- Since:
- 0.9.2
-
receiveSessionRequest
public void receiveSessionRequest(UDPPacketReader.SessionRequestReader req)
-
sessionRequestReceived
public boolean sessionRequestReceived()
-
getReceivedX
public byte[] getReceivedX()
-
getReceivedOurIP
public byte[] getReceivedOurIP()
-
isIntroductionRequested
public boolean isIntroductionRequested()
True (default) if no extended options in session request, or value of flag bit in the extended options.- Since:
- 0.9.24
-
generateSessionKey
public void generateSessionKey() throws DHSessionKeyBuilder.InvalidPublicParameterExceptionGenerates session key and mac key.
-
getCipherKey
public SessionKey getCipherKey()
-
getMACKey
public SessionKey getMACKey()
-
getSentIP
public byte[] getSentIP()
what IP do they appear to be on?
-
getSentPort
public int getSentPort()
what port number do they appear to be coming from?
-
getSentY
public byte[] getSentY()
-
fail
public void fail()
-
getSentRelayTag
public long getSentRelayTag()
-
setSentRelayTag
public void setSentRelayTag(long tag)
-
getSentSignedOnTime
public long getSentSignedOnTime()
-
prepareSessionCreated
public void prepareSessionCreated()
-
getSentSignature
public Signature getSentSignature()
-
createdPacketSent
public void createdPacketSent()
note that we just sent a SessionCreated packet
-
getLifetime
public long getLifetime()
how long have we been trying to establish this session?
-
getLifetime
public long getLifetime(long now)
how long have we been trying to establish this session?- Since:
- 0.9.57
-
getEstablishBeginTime
public long getEstablishBeginTime()
-
getNextSendTime
public long getNextSendTime()
- Returns:
- rcv time after receiving a packet (including after constructor), send time + delay after sending a packet
-
getRTT
int getRTT()
-
getRemoteHostId
RemoteHostId getRemoteHostId()
RemoteHostId, uniquely identifies an attempt
-
receiveSessionConfirmed
public void receiveSessionConfirmed(UDPPacketReader.SessionConfirmedReader conf)
Note that while a SessionConfirmed could in theory be fragmented, in practice a RouterIdentity is 387 bytes and a single fragment is 512 bytes max, so it will never be fragmented.
-
confirmedFullyReceived
protected boolean confirmedFullyReceived()
Have we fully received the SessionConfirmed messages from Alice? Caller must synch on this.
-
getConfirmedIdentity
public RouterIdentity getConfirmedIdentity()
Who is Alice (null if forged/unknown) Note that this isn't really confirmed - see below.
-
packetReceived
protected void packetReceived()
Call from synchronized method only
-
-