Use ristretto instead of bigcache

This commit is contained in:
9seconds
2019-11-11 14:59:09 +03:00
parent 22905b2a25
commit 34ad883559
9 changed files with 55 additions and 72 deletions
+3 -3
View File
@@ -81,13 +81,13 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
c.dc = conntypes.DCDefaultIdx
}
replayKeys := decryptedFrame.Unique()
if antireplay.Cache.HasObfuscated2(replayKeys) {
replayKey := decryptedFrame.Unique()
if antireplay.Cache.HasObfuscated2(replayKey) {
stats.Stats.ReplayDetected()
return nil, errors.New("replay attack is detected")
}
antireplay.Cache.AddObfuscated2(replayKeys)
antireplay.Cache.AddObfuscated2(replayKey)
return stream.NewObfuscated2(socket, encryptor, decryptor), nil
}