Package net.i2p.router.transport.udp
Class PeerStateDestroyed
- java.lang.Object
-
- net.i2p.router.transport.udp.PeerStateDestroyed
-
- All Implemented Interfaces:
SSU2Payload.PayloadCallback,SSU2Sender
class PeerStateDestroyed extends Object implements 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 Modifier and Type Field Description protected long_wantACKSendSince
-
Constructor Summary
Constructors Constructor Description PeerStateDestroyed(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfragmentsSent(long pktNum, int length, List<PacketBuilder.Fragment> fragments)SSU2BitfieldgetAckedMessages()bytegetFlags()intgetMTU()longgetNextPacketNumber()(package private) longgetRcvConnID()SSU2BitfieldgetReceivedMessages()RemoteHostIdgetRemoteHostId()InetAddressgetRemoteIPAddress()intgetRemotePort()CipherStategetSendCipher()longgetSendConnID()byte[]getSendHeaderEncryptKey1()byte[]getSendHeaderEncryptKey2()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)voidgotRelayTagRequest()voidgotRI(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)StringtoString()
-
-
-
Constructor Detail
-
PeerStateDestroyed
public PeerStateDestroyed(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.- 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 Detail
-
kill
public void kill()
Call at transport shutdown or cache eviction
-
getRemoteHostId
public RemoteHostId getRemoteHostId()
- Specified by:
getRemoteHostIdin interfaceSSU2Sender
-
isIPv6
public boolean isIPv6()
- Specified by:
isIPv6in interfaceSSU2Sender
-
getRemoteIPAddress
public InetAddress 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
public CipherState 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
public SSU2Bitfield getReceivedMessages()
- Specified by:
getReceivedMessagesin interfaceSSU2Sender
-
getAckedMessages
public SSU2Bitfield getAckedMessages()
- Specified by:
getAckedMessagesin interfaceSSU2Sender- Returns:
- null always, we don't care what was acked
-
fragmentsSent
public void fragmentsSent(long pktNum, int length, List<PacketBuilder.Fragment> fragments)- Specified by:
fragmentsSentin interfaceSSU2Sender
-
getFlags
public byte getFlags()
- Specified by:
getFlagsin interfaceSSU2Sender
-
getRcvConnID
long getRcvConnID()
-
receivePacket
void receivePacket(UDPPacket packet)
- Parameters:
packet- fully encrypted, header and body decryption will be done here
-
receivePacket
void receivePacket(RemoteHostId from, UDPPacket packet)
- 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.PayloadCallbackisHandshake- true only for message 3 part 2
-
gotRI
public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood)
- 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
public void gotRelayIntro(Hash aliceHash, byte[] data)
- Specified by:
gotRelayIntroin interfaceSSU2Payload.PayloadCallbackdata- excludes flag, includes signature
-
gotPeerTest
public void gotPeerTest(int msg, int status, Hash h, byte[] data)- 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
public void gotI2NP(I2NPMessage msg)
- 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.PayloadCallbackoff- offset in datalen- length of data to copy
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges)- Specified by:
gotACKin interfaceSSU2Payload.PayloadCallbackranges- null if none
-
gotTermination
public void gotTermination(int reason, long count)- Specified by:
gotTerminationin interfaceSSU2Payload.PayloadCallbackcount- in theory could wrap around to negative, but very unlikely
-
gotPathChallenge
public void gotPathChallenge(RemoteHostId from, byte[] data)
- Specified by:
gotPathChallengein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
gotPathResponse
public void gotPathResponse(RemoteHostId from, byte[] data)
- Specified by:
gotPathResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
-