From d785fa01567467775cc2e000d9bb0abe38693a7c Mon Sep 17 00:00:00 2001 From: V2Ray Date: Mon, 7 Sep 2015 23:21:47 +0200 Subject: [PATCH] Update protocol for better decription --- io/vmess/vmess.go | 25 ++++++++++++------------- spec/vmess.md | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/io/vmess/vmess.go b/io/vmess/vmess.go index 18a51a516..2f795299c 100644 --- a/io/vmess/vmess.go +++ b/io/vmess/vmess.go @@ -2,7 +2,7 @@ package vmess import ( - "fmt" + "fmt" "io" ) @@ -21,18 +21,17 @@ type VMessInput struct { } func Read(reader io.Reader) (input *VMessInput, err error) { - buffer := make([]byte, 17 /* version + user hash */) - nBytes, err := reader.Read(buffer) - if err != nil { - return - } - if nBytes != len(buffer) { - err = fmt.Errorf("Unexpected length of header %d", nBytes) - return - } - - return + buffer := make([]byte, 17 /* version + user hash */) + nBytes, err := reader.Read(buffer) + if err != nil { + return + } + if nBytes != len(buffer) { + err = fmt.Errorf("Unexpected length of header %d", nBytes) + return + } + + return } type VMessOutput [4]byte - diff --git a/spec/vmess.md b/spec/vmess.md index 91192dc19..9e51f8d02 100644 --- a/spec/vmess.md +++ b/spec/vmess.md @@ -10,7 +10,7 @@ * 16 字节:md5(用户 VID + 'ASK') 指令部分: -* 1 字节:随机填充长度 M (M <= 32) +* 1 字节:随机填充长度 M (0 < M <= 32) * M 字节:随机填充内容 * 1 字节:保留,总是 0x00 * 16 字节:请求数据 IV @@ -29,7 +29,7 @@ * 4 字节:IPv4 * 1 字节长度 + 域名 * 16 字节:IPv6 -* 1 字节:随机填充长度 M2 (M2 <= 32) +* 1 字节:随机填充长度 M2 (0 < M2 <= 32),使得指令部分长度为 16 的倍数字节 * M2 字节:随机填充内容 数据部分