Package net.i2p.router.transport.udp
Class OutboundEstablishState
java.lang.Object
net.i2p.router.transport.udp.OutboundEstablishState
- Direct Known Subclasses:
OutboundEstablishState2
Data for a new connection being established, where we initiated the
connection with a remote peer. In other words, we are Alice and
they are Bob.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[]
protected int
protected byte[]
protected int
protected final RouterContext
protected OutboundEstablishState.OutboundState
protected final long
protected long
protected final Log
protected long
protected long
protected RemoteHostId
protected final RouterIdentity
protected int
protected long
protected int
protected static final long
basic delay before backoff Transmissions at 0, 1.25, 3.75, 8.75 sec This should be a little longer than for inbound. -
Constructor Summary
ModifierConstructorDescriptionOutboundEstablishState
(RouterContext ctx, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean allowExtendedOptions, boolean needIntroduction, SessionKey introKey, UDPAddress addr, DHSessionKeyBuilder.Factory dh) protected
OutboundEstablishState
(RouterContext ctx, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean needIntroduction, SessionKey introKey, UDPAddress addr) For SSU2 -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(OutNetMessage msg) Queue a message to be sent after the session is established.boolean
complete()
void
note that we just sent the SessionConfirmed packetvoid
we have received a real data packet, so we're done establishingvoid
fail()
The SessionCreated validation failed(package private) RemoteHostId
This will never be a hash-based address.long
long
Bob's introduction key, as published in the netdblong
long
long
how long have we been trying to establish this session?long
byte[]
int
long
long
(package private) RemoteHostId
This should be what the state is currently indexed by in the _outboundStates table.long
(package private) int
getRTT()
byte[]
The remote side (Bob) - note that in some places he's called Charlie.int
The remote side (Bob) - note that in some places he's called Charlie.long
byte[]
getSentX()
getState()
int
void
introduced
(byte[] bobIP, int bobPort) This changes the remoteHostId from a hash-based one or possibly incorrect IP/port to what the introducer told us.void
void
note that we just sent the RelayRequest packetboolean
Are we allowed to send extended options to this peer?boolean
Is the first message queued our own DatabaseStoreMessage?boolean
Should we ask this peer to be an introducer for us? Ignored unless allowExtendedOptions is trueprotected void
Call from synchronized method onlyvoid
Let's sign everything so we can fragment properly.(package private) boolean
Accelerate response to RelayResponse if we haven't sent it yet.void
void
note that we just sent the SessionRequest packetvoid
setIntroNonce
(long nonce) toString()
boolean
Blocking call (run in the establisher thread) to determine if the session was created properly.
-
Field Details
-
_context
-
_log
-
_bobIP
protected byte[] _bobIP -
_bobPort
protected int _bobPort -
_aliceIP
protected byte[] _aliceIP -
_alicePort
protected int _alicePort -
_receivedRelayTag
protected long _receivedRelayTag -
_establishBegin
protected final long _establishBegin -
_lastSend
protected long _lastSend -
_nextSend
protected long _nextSend -
_remoteHostId
-
_remotePeer
-
_currentState
-
_requestSentCount
protected int _requestSentCount -
_requestSentTime
protected long _requestSentTime -
_rtt
protected int _rtt -
RETRANSMIT_DELAY
protected static final long RETRANSMIT_DELAYbasic delay before backoff Transmissions at 0, 1.25, 3.75, 8.75 sec This should be a little longer than for inbound.- See Also:
-
-
Constructor Details
-
OutboundEstablishState
public OutboundEstablishState(RouterContext ctx, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean allowExtendedOptions, boolean needIntroduction, SessionKey introKey, UDPAddress addr, DHSessionKeyBuilder.Factory dh) - Parameters:
claimedAddress
- an IP/port based RemoteHostId, or null if unknownremoteHostId
- non-null, == claimedAddress if direct, or a hash-based one if indirectremotePeer
- must have supported sig typeallowExtendedOptions
- are we allowed to send extended options to Bob?needIntroduction
- should we ask Bob to be an introducer for us? ignored unless allowExtendedOptions is trueintroKey
- Bob's introduction key, as published in the netdbaddr
- non-null
-
OutboundEstablishState
protected OutboundEstablishState(RouterContext ctx, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean needIntroduction, SessionKey introKey, UDPAddress addr) For SSU2- Since:
- 0.9.54
-
-
Method Details
-
getVersion
public int getVersion()- Since:
- 0.9.54
-
getState
-
complete
public boolean complete()- Returns:
- if previously complete
-
getRemoteAddress
- Returns:
- non-null
-
setIntroNonce
public void setIntroNonce(long nonce) -
getIntroNonce
public long getIntroNonce()- Returns:
- -1 if unset
-
isExtendedOptionsAllowed
public boolean isExtendedOptionsAllowed()Are we allowed to send extended options to this peer?- Since:
- 0.9.24
-
needIntroduction
public boolean needIntroduction()Should we ask this peer to be an introducer for us? Ignored unless allowExtendedOptions is true- Since:
- 0.9.24
-
getRTT
int getRTT() -
addMessage
Queue a message to be sent after the session is established. -
isFirstMessageOurDSM
public boolean isFirstMessageOurDSM()Is the first message queued our own DatabaseStoreMessage?- Since:
- 0.9.12
-
getNextQueuedMessage
- Returns:
- null if none
-
getRemoteIdentity
-
getIntroKey
Bob's introduction key, as published in the netdb -
getSentX
public byte[] getSentX() -
getSentIP
public byte[] getSentIP()The remote side (Bob) - note that in some places he's called Charlie. Warning - may change after introduction. May be null before introduction. -
getSentPort
public int getSentPort()The remote side (Bob) - note that in some places he's called Charlie. Warning - may change after introduction. May be -1 before introduction. -
receiveSessionCreated
-
validateSessionCreated
public boolean validateSessionCreated()Blocking call (run in the establisher thread) to determine if the session was created properly. If it wasn't, all the SessionCreated remnants are dropped (perhaps they were spoofed, etc) so that we can receive another one Generates session key and mac key.- Returns:
- true if valid
-
fail
public void fail()The SessionCreated validation failed -
getCipherKey
-
getMACKey
-
getReceivedRelayTag
public long getReceivedRelayTag() -
getSentSignedOnTime
public long getSentSignedOnTime() -
getReceivedSignedOnTime
public long getReceivedSignedOnTime() -
getReceivedIP
public byte[] getReceivedIP() -
getReceivedPort
public int getReceivedPort() -
prepareSessionConfirmed
public void prepareSessionConfirmed()Let's sign everything so we can fragment properly. 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. -
getSentSignature
-
confirmedPacketsSent
public void confirmedPacketsSent()note that we just sent the SessionConfirmed packet -
getConfirmedSentTime
public long getConfirmedSentTime()- Returns:
- when we sent the first SessionConfirmed packet, or 0
- Since:
- 0.9.2
-
requestSent
public void requestSent()note that we just sent the SessionRequest packet -
getRequestSentTime
public long getRequestSentTime()- Returns:
- when we sent the first SessionRequest packet, or 0
- Since:
- 0.9.2
-
introSent
public void introSent()note that we just sent the RelayRequest packet -
getIntroSentTime
public long getIntroSentTime()- Returns:
- when we sent the first RelayRequest packet, or 0
- Since:
- 0.9.2
-
introductionFailed
public void introductionFailed() -
introduced
public void introduced(byte[] bobIP, int bobPort) This changes the remoteHostId from a hash-based one or possibly incorrect IP/port to what the introducer told us. All params are for the remote end (NOT the introducer) and must have been validated already. -
receiveHolePunch
boolean receiveHolePunch()Accelerate response to RelayResponse if we haven't sent it yet.- Returns:
- true if we should send the SessionRequest now
- Since:
- 0.9.15
-
getLifetime
public long getLifetime()how long have we been trying to establish this session? -
getEstablishBeginTime
public long getEstablishBeginTime() -
getNextSendTime
public long getNextSendTime()- Returns:
- 0 at initialization (to force sending session request), rcv time after receiving a packet, send time + delay after sending a packet (including session request)
-
getRemoteHostId
RemoteHostId getRemoteHostId()This should be what the state is currently indexed by in the _outboundStates table. Beware - During introduction, this is a router hash. After introduced() is called, this is set to the IP/port the introducer told us.- Returns:
- non-null
-
getClaimedAddress
RemoteHostId getClaimedAddress()This will never be a hash-based address. This is the 'claimed' (unverified) address from the netdb, or null. It is not changed after introduction. Use getRemoteHostId() for the verified address.- Returns:
- may be null
-
dataReceived
public void dataReceived()we have received a real data packet, so we're done establishing -
packetReceived
protected void packetReceived()Call from synchronized method only -
toString
-