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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPeerStateDestroyed(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 TypeMethodDescriptionvoidfragmentsSent(long pktNum, int length, List<PacketBuilder.Fragment> fragments) bytegetFlags()intgetMTU()long(package private) longintlongbyte[]byte[]voidgotACK(long ackThru, int acks, byte[] ranges) voidgotAddress(byte[] ip, int port) voidgotDateTime(long time) voidgotFragment(byte[] data, int off, int len, long messageId, int frag, boolean isLast) Data must be copied out in this method.voidgotI2NP(I2NPMessage msg) voidgotOptions(byte[] options, boolean isHandshake) voidgotPathChallenge(RemoteHostId from, byte[] data) voidgotPathResponse(RemoteHostId from, byte[] data) voidgotPeerTest(int msg, int status, Hash h, byte[] data) voidgotRelayIntro(Hash aliceHash, byte[] data) voidgotRelayRequest(byte[] data) voidgotRelayResponse(int status, byte[] data) voidgotRelayTag(long tag) voidvoidgotRI(RouterInfo ri, boolean isHandshake, boolean flood) voidgotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) voidgotTermination(int reason, long count) voidgotToken(long token, long expires) booleanisIPv6()voidkill()Call at transport shutdown or cache eviction(package private) voidreceivePacket(RemoteHostId from, UDPPacket packet) (package private) voidreceivePacket(UDPPacket packet) voidsetDestroyReason(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:
getRemoteHostIdin interfaceSSU2Sender
-
isIPv6
public boolean isIPv6()- Specified by:
isIPv6in interfaceSSU2Sender
-
getRemoteIPAddress
- Specified by:
getRemoteIPAddressin interfaceSSU2Sender
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin interfaceSSU2Sender
-
getMTU
public int getMTU()- Specified by:
getMTUin interfaceSSU2Sender
-
getNextPacketNumber
public long getNextPacketNumber()- Specified by:
getNextPacketNumberin interfaceSSU2Sender
-
getSendConnID
public long getSendConnID()- Specified by:
getSendConnIDin interfaceSSU2Sender
-
getSendCipher
- Specified by:
getSendCipherin interfaceSSU2Sender
-
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1()- Specified by:
getSendHeaderEncryptKey1in interfaceSSU2Sender
-
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2()- Specified by:
getSendHeaderEncryptKey2in interfaceSSU2Sender
-
setDestroyReason
public void setDestroyReason(int reason) - Specified by:
setDestroyReasonin interfaceSSU2Sender
-
getReceivedMessages
- Specified by:
getReceivedMessagesin interfaceSSU2Sender
-
getAckedMessages
- Specified by:
getAckedMessagesin interfaceSSU2Sender- Returns:
- null always, we don't care what was acked
-
fragmentsSent
- Specified by:
fragmentsSentin interfaceSSU2Sender
-
getFlags
public byte getFlags()- Specified by:
getFlagsin 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:
gotDateTimein interfaceSSU2Payload.PayloadCallback
-
gotOptions
public void gotOptions(byte[] options, boolean isHandshake) - Specified by:
gotOptionsin interfaceSSU2Payload.PayloadCallback- Parameters:
isHandshake- true only for message 3 part 2
-
gotRI
- Specified by:
gotRIin 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:
gotRIFragmentin 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:
gotAddressin interfaceSSU2Payload.PayloadCallback
-
gotRelayTagRequest
public void gotRelayTagRequest()- Specified by:
gotRelayTagRequestin interfaceSSU2Payload.PayloadCallback
-
gotRelayTag
public void gotRelayTag(long tag) - Specified by:
gotRelayTagin interfaceSSU2Payload.PayloadCallback
-
gotRelayRequest
public void gotRelayRequest(byte[] data) - Specified by:
gotRelayRequestin interfaceSSU2Payload.PayloadCallback- Parameters:
data- excludes flag, includes signature
-
gotRelayResponse
public void gotRelayResponse(int status, byte[] data) - Specified by:
gotRelayResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
status- 0 = accept, 1-255 = rejectdata- excludes flag, includes signature
-
gotRelayIntro
- Specified by:
gotRelayIntroin interfaceSSU2Payload.PayloadCallback- Parameters:
data- excludes flag, includes signature
-
gotPeerTest
- Specified by:
gotPeerTestin 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:
gotTokenin interfaceSSU2Payload.PayloadCallback
-
gotI2NP
- Specified by:
gotI2NPin interfaceSSU2Payload.PayloadCallback
-
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageId, int frag, boolean isLast) Description copied from interface:SSU2Payload.PayloadCallbackData must be copied out in this method. Data starts at the 9 byte header for fragment 0.- Specified by:
gotFragmentin interfaceSSU2Payload.PayloadCallback- Parameters:
off- offset in datalen- length of data to copy
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges) - Specified by:
gotACKin interfaceSSU2Payload.PayloadCallback- Parameters:
ranges- null if none
-
gotTermination
public void gotTermination(int reason, long count) - Specified by:
gotTerminationin interfaceSSU2Payload.PayloadCallback- Parameters:
count- in theory could wrap around to negative, but very unlikely
-
gotPathChallenge
- Specified by:
gotPathChallengein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
gotPathResponse
- Specified by:
gotPathResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
toString
-