Package net.i2p.router.transport.udp
Class PeerStateDestroyed
java.lang.Object
net.i2p.router.transport.udp.PeerStateDestroyed
- All Implemented Interfaces:
SSU2Payload.PayloadCallback
,SSU2Sender
Small, stub version of PeerState2, for handling destroy acks
with possible tokens in them.
This is the "closing state" as defined in QUIC RFC-9000 section 10.2.1.
Unlike in QUIC, we do increment the packet number for every sent
destroy packet. Also, we retain the header and body decryption keys,
and we do process any tokens received.
We only respond when receiving data or a termination with a non-ack reason.
Does not extend PeerState2 or PeerState.
- Since:
- 0.9.57
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPeerStateDestroyed
(RouterContext ctx, UDPTransport transport, PeerState2 peer) This must be called after the first termination or termination ack was sent from PeerState2, so the next packet number is correct.PeerStateDestroyed
(RouterContext ctx, UDPTransport transport, RemoteHostId id, long sendID, long rcvID, CipherState sendCha, CipherState rcvCha, byte[] sendKey1, byte[] sendKey2, byte[] rcvKey2, int reason) Direct from IES2, there was never a PS2. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fragmentsSent
(long pktNum, int length, List<PacketBuilder.Fragment> fragments) byte
getFlags()
int
getMTU()
long
(package private) long
int
long
byte[]
byte[]
void
gotACK
(long ackThru, int acks, byte[] ranges) void
gotAddress
(byte[] ip, int port) void
gotDateTime
(long time) void
gotFragment
(byte[] data, int off, int len, long messageId, int frag, boolean isLast) Data must be copied out in this method.void
gotI2NP
(I2NPMessage msg) void
gotOptions
(byte[] options, boolean isHandshake) void
gotPathChallenge
(RemoteHostId from, byte[] data) void
gotPathResponse
(RemoteHostId from, byte[] data) void
gotPeerTest
(int msg, int status, Hash h, byte[] data) void
gotRelayIntro
(Hash aliceHash, byte[] data) void
gotRelayRequest
(byte[] data) void
gotRelayResponse
(int status, byte[] data) void
gotRelayTag
(long tag) void
void
gotRI
(RouterInfo ri, boolean isHandshake, boolean flood) void
gotRIFragment
(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) void
gotTermination
(int reason, long count) void
gotToken
(long token, long expires) boolean
isIPv6()
void
kill()
Call at transport shutdown or cache eviction(package private) void
receivePacket
(RemoteHostId from, UDPPacket packet) (package private) void
receivePacket
(UDPPacket packet) void
setDestroyReason
(int reason) toString()
-
Field Details
-
_wantACKSendSince
protected volatile long _wantACKSendSince
-
-
Constructor Details
-
PeerStateDestroyed
This must be called after the first termination or termination ack was sent from PeerState2, so the next packet number is correct.- Parameters:
peer
- that just sent (or received and sent) a termination
-
PeerStateDestroyed
public PeerStateDestroyed(RouterContext ctx, UDPTransport transport, RemoteHostId id, long sendID, long rcvID, CipherState sendCha, CipherState rcvCha, byte[] sendKey1, byte[] sendKey2, byte[] rcvKey2, int reason) Direct from IES2, there was never a PS2. Caller must send termination after creating.
-
-
Method Details
-
kill
public void kill()Call at transport shutdown or cache eviction -
getRemoteHostId
- Specified by:
getRemoteHostId
in interfaceSSU2Sender
-
isIPv6
public boolean isIPv6()- Specified by:
isIPv6
in interfaceSSU2Sender
-
getRemoteIPAddress
- Specified by:
getRemoteIPAddress
in interfaceSSU2Sender
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePort
in interfaceSSU2Sender
-
getMTU
public int getMTU()- Specified by:
getMTU
in interfaceSSU2Sender
-
getNextPacketNumber
public long getNextPacketNumber()- Specified by:
getNextPacketNumber
in interfaceSSU2Sender
-
getSendConnID
public long getSendConnID()- Specified by:
getSendConnID
in interfaceSSU2Sender
-
getSendCipher
- Specified by:
getSendCipher
in interfaceSSU2Sender
-
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1()- Specified by:
getSendHeaderEncryptKey1
in interfaceSSU2Sender
-
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2()- Specified by:
getSendHeaderEncryptKey2
in interfaceSSU2Sender
-
setDestroyReason
public void setDestroyReason(int reason) - Specified by:
setDestroyReason
in interfaceSSU2Sender
-
getReceivedMessages
- Specified by:
getReceivedMessages
in interfaceSSU2Sender
-
getAckedMessages
- Specified by:
getAckedMessages
in interfaceSSU2Sender
- Returns:
- null always, we don't care what was acked
-
fragmentsSent
- Specified by:
fragmentsSent
in interfaceSSU2Sender
-
getFlags
public byte getFlags()- Specified by:
getFlags
in interfaceSSU2Sender
-
getRcvConnID
long getRcvConnID() -
receivePacket
- Parameters:
packet
- fully encrypted, header and body decryption will be done here
-
receivePacket
- Parameters:
from
- source addresspacket
- fully encrypted, header and body decryption will be done here- Since:
- 0.9.55
-
gotDateTime
public void gotDateTime(long time) - Specified by:
gotDateTime
in interfaceSSU2Payload.PayloadCallback
-
gotOptions
public void gotOptions(byte[] options, boolean isHandshake) - Specified by:
gotOptions
in interfaceSSU2Payload.PayloadCallback
- Parameters:
isHandshake
- true only for message 3 part 2
-
gotRI
- Specified by:
gotRI
in interfaceSSU2Payload.PayloadCallback
- Parameters:
ri
- will already be validatedisHandshake
- true only for message 3 part 2
-
gotRIFragment
public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) - Specified by:
gotRIFragment
in interfaceSSU2Payload.PayloadCallback
- Parameters:
data
- is first gzipped and then fragmentedisHandshake
- true only for message 3 part 2
-
gotAddress
public void gotAddress(byte[] ip, int port) - Specified by:
gotAddress
in interfaceSSU2Payload.PayloadCallback
-
gotRelayTagRequest
public void gotRelayTagRequest()- Specified by:
gotRelayTagRequest
in interfaceSSU2Payload.PayloadCallback
-
gotRelayTag
public void gotRelayTag(long tag) - Specified by:
gotRelayTag
in interfaceSSU2Payload.PayloadCallback
-
gotRelayRequest
public void gotRelayRequest(byte[] data) - Specified by:
gotRelayRequest
in interfaceSSU2Payload.PayloadCallback
- Parameters:
data
- excludes flag, includes signature
-
gotRelayResponse
public void gotRelayResponse(int status, byte[] data) - Specified by:
gotRelayResponse
in interfaceSSU2Payload.PayloadCallback
- Parameters:
status
- 0 = accept, 1-255 = rejectdata
- excludes flag, includes signature
-
gotRelayIntro
- Specified by:
gotRelayIntro
in interfaceSSU2Payload.PayloadCallback
- Parameters:
data
- excludes flag, includes signature
-
gotPeerTest
- Specified by:
gotPeerTest
in interfaceSSU2Payload.PayloadCallback
- Parameters:
msg
- 1-7status
- 0 = accept, 1-255 = rejecth
- Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7data
- excludes flag, includes signature
-
gotToken
public void gotToken(long token, long expires) - Specified by:
gotToken
in interfaceSSU2Payload.PayloadCallback
-
gotI2NP
- Specified by:
gotI2NP
in interfaceSSU2Payload.PayloadCallback
-
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageId, int frag, boolean isLast) Description copied from interface:SSU2Payload.PayloadCallback
Data must be copied out in this method. Data starts at the 9 byte header for fragment 0.- Specified by:
gotFragment
in interfaceSSU2Payload.PayloadCallback
- Parameters:
off
- offset in datalen
- length of data to copy
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges) - Specified by:
gotACK
in interfaceSSU2Payload.PayloadCallback
- Parameters:
ranges
- null if none
-
gotTermination
public void gotTermination(int reason, long count) - Specified by:
gotTermination
in interfaceSSU2Payload.PayloadCallback
- Parameters:
count
- in theory could wrap around to negative, but very unlikely
-
gotPathChallenge
- Specified by:
gotPathChallenge
in interfaceSSU2Payload.PayloadCallback
- Parameters:
from
- null if unknown
-
gotPathResponse
- Specified by:
gotPathResponse
in interfaceSSU2Payload.PayloadCallback
- Parameters:
from
- null if unknown
-
toString
-