Merge pull request #1 from 9seconds/master

Modified antireplay
This commit is contained in:
Savely Krasovsky
2019-08-29 10:33:56 +03:00
committed by GitHub
+4 -2
View File
@@ -45,10 +45,12 @@ func DirectInit(ctx context.Context, cancel context.CancelFunc, socket net.Conn,
return nil, nil, errors.Annotate(err, "Cannot parse obfuscated frame")
}
if antiReplayCache.Has([]byte(frame)) {
var replayPart = []byte(frame)
if antiReplayCache.Has(replayPart[4:60]) {
return nil, nil, errors.New("Replay attack is detected")
}
antiReplayCache.Add([]byte(frame))
antiReplayCache.Add(replayPart[4:60])
connOpts.ConnectionProto = mtproto.ConnectionProtocolAny
connOpts.ClientAddr = conn.RemoteAddr()