mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
update format
This commit is contained in:
parent
b5416c9f42
commit
b0849dd23b
@ -2,7 +2,8 @@
|
||||
package vmess
|
||||
|
||||
import (
|
||||
"net"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// VMessInput implements the input message of VMess protocol. It only contains
|
||||
@ -19,19 +20,19 @@ type VMessInput struct {
|
||||
target [256]byte
|
||||
}
|
||||
|
||||
type VMessReader struct {
|
||||
conn *net.Conn
|
||||
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
|
||||
}
|
||||
|
||||
// NewVMessReader creates a new VMessReader
|
||||
func NewVMessReader(conn *net.Conn) (VMessReader, error) {
|
||||
var reader VMessReader
|
||||
reader.conn = conn
|
||||
return reader, nil
|
||||
}
|
||||
type VMessOutput [4]byte
|
||||
|
||||
// Read reads data from current connection and form a VMessInput if possible.
|
||||
func (*VMessReader) Read() (VMessInput, error) {
|
||||
var input VMessInput
|
||||
return input, nil
|
||||
}
|
||||
|
@ -5,8 +5,10 @@
|
||||
## 数据请求
|
||||
版本部分:
|
||||
* 1 字节:版本号,目前为 0x1
|
||||
|
||||
认证部分:
|
||||
* 16 字节:md5(用户 VID + 'ASK')
|
||||
|
||||
指令部分:
|
||||
* 1 字节:随机填充长度 M (M <= 32)
|
||||
* M 字节:随机填充内容
|
||||
@ -29,14 +31,16 @@
|
||||
* 16 字节:IPv6
|
||||
* 1 字节:随机填充长度 M2 (M2 <= 32)
|
||||
* M2 字节:随机填充内容
|
||||
|
||||
数据部分
|
||||
* N 字节:请求数据
|
||||
* N 字节:请求数据
|
||||
|
||||
其中指令部分经过 AES-128 加密,Key 为用户 VID;数据部分使用 AES-128-CBC 加密
|
||||
|
||||
## 数据应答
|
||||
认证部分:
|
||||
* 4 字节:认证信息 V
|
||||
|
||||
数据部分
|
||||
* N 字节:应答数据
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user