From cc3f374623ca4a2c47935286df87d3428cb20712 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Wed, 16 Sep 2015 12:26:50 +0200 Subject: [PATCH] Remove restriction of padding length --- io/vmess/vmess.go | 5 +---- spec/vmess.md | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/io/vmess/vmess.go b/io/vmess/vmess.go index 2f5ff895..ca02f3db 100644 --- a/io/vmess/vmess.go +++ b/io/vmess/vmess.go @@ -226,10 +226,7 @@ func (w *VMessRequestWriter) Write(writer io.Writer, request *VMessRequest) erro buffer = append(buffer, []byte(request.Address.Domain)...) } - paddingLength := blockSize - 1 - (len(buffer)-encryptionBegin)%blockSize - if paddingLength == 0 { - paddingLength = blockSize - } + paddingLength := mrand.Intn(32) + 1 paddingBuffer := make([]byte, paddingLength) _, err = rand.Read(paddingBuffer) if err != nil { diff --git a/spec/vmess.md b/spec/vmess.md index bc17ec12..e432249e 100644 --- a/spec/vmess.md +++ b/spec/vmess.md @@ -26,7 +26,7 @@ * 4 字节:IPv4 * 1 字节长度 + 域名 * 16 字节:IPv6 -* 1 字节:随机填充长度 M2 (0 < M2 <= 32),使得指令部分长度为 16 的倍数字节 +* 1 字节:随机填充长度 M2 (0 < M2 <= 32) * M2 字节:随机填充内容 数据部分