SSU2 fixes

Fix NPE in PS2
Fix Token Request message type
This commit is contained in:
zzz
2022-02-28 10:01:05 -05:00
parent ec63f41b27
commit 44c30e78fc
2 changed files with 5 additions and 5 deletions

View File

@@ -124,11 +124,11 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
public synchronized void restart(long token) {
_token = token;
HandshakeState old = _handshakeState;
byte[] pub = new byte[32];
old.getRemotePublicKey().getPublicKey(pub, 0);
createNewState(_routerAddress);
if (old != null)
if (old != null) {
// TODO pass the old keys over to createNewState()
old.destroy();
}
createNewState(_routerAddress);
//_rcvHeaderEncryptKey2 will be set after the Session Request message is created
_rcvHeaderEncryptKey2 = null;
}

View File

@@ -283,7 +283,7 @@ class PacketBuilder2 {
*/
public UDPPacket buildTokenRequestPacket(OutboundEstablishState2 state) {
long n = _context.random().signedNextInt() & 0xFFFFFFFFL;
UDPPacket packet = buildLongPacketHeader(state.getSendConnID(), n, SESSION_REQUEST_FLAG_BYTE,
UDPPacket packet = buildLongPacketHeader(state.getSendConnID(), n, TOKEN_REQUEST_FLAG_BYTE,
state.getRcvConnID(), 0);
DatagramPacket pkt = packet.getPacket();