1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

test case for anti reply attack

This commit is contained in:
Darien Raymond 2017-02-12 14:00:17 +01:00
parent 3e10f3ae69
commit 10d26f2d7f
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -41,6 +41,9 @@ func TestRequestSerialization(t *testing.T) {
client := NewClientSession(protocol.DefaultIDHash)
client.EncodeRequestHeader(expectedRequest, buffer)
buffer2 := buf.New()
buffer2.Append(buffer.Bytes())
ctx, cancel := context.WithCancel(context.Background())
userValidator := vmess.NewTimedUserValidator(ctx, protocol.DefaultIDHash)
userValidator.Add(user)
@ -55,5 +58,10 @@ func TestRequestSerialization(t *testing.T) {
assert.Address(expectedRequest.Address).Equals(actualRequest.Address)
assert.Port(expectedRequest.Port).Equals(actualRequest.Port)
assert.Byte(byte(expectedRequest.Security)).Equals(byte(actualRequest.Security))
_, err = server.DecodeRequestHeader(buffer2)
// anti reply attack
assert.Error(err).IsNotNil()
cancel()
}