Browse Source

Modified antireplay

tags/1.0^2
9seconds 6 years ago
parent
commit
82ec3871a4
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      client/direct.go

+ 4
- 2
client/direct.go View File

@@ -45,10 +45,12 @@ func DirectInit(ctx context.Context, cancel context.CancelFunc, socket net.Conn,
45 45
 		return nil, nil, errors.Annotate(err, "Cannot parse obfuscated frame")
46 46
 	}
47 47
 
48
-	if antiReplayCache.Has([]byte(frame)) {
48
+	var replayPart = []byte(frame)
49
+
50
+	if antiReplayCache.Has(replayPart[4:60]) {
49 51
 		return nil, nil, errors.New("Replay attack is detected")
50 52
 	}
51
-	antiReplayCache.Add([]byte(frame))
53
+	antiReplayCache.Add(replayPart[4:60])
52 54
 
53 55
 	connOpts.ConnectionProto = mtproto.ConnectionProtocolAny
54 56
 	connOpts.ClientAddr = conn.RemoteAddr()

Loading…
Cancel
Save