Success path for fake tls is implemented

This commit is contained in:
9seconds
2019-11-07 13:04:38 +03:00
parent fd8506c82a
commit 038b2b200d
21 changed files with 777 additions and 111 deletions
+4 -2
View File
@@ -13,6 +13,7 @@ import (
"github.com/9seconds/mtg/config"
"github.com/9seconds/mtg/conntypes"
"github.com/9seconds/mtg/protocol"
"github.com/9seconds/mtg/stats"
"github.com/9seconds/mtg/utils"
"github.com/9seconds/mtg/wrappers/stream"
)
@@ -81,11 +82,12 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
}
antiReplayKey := decryptedFrame.Unique()
if antireplay.Cache.Has(antiReplayKey) {
if antireplay.Cache.HasObfuscated2(antiReplayKey) {
stats.Stats.AntiReplayDetected()
return nil, errors.New("replay attack is detected")
}
antireplay.Cache.Add(antiReplayKey)
antireplay.Cache.AddObfuscated2(antiReplayKey)
return stream.NewObfuscated2(socket, encryptor, decryptor), nil
}