v2ray-core/io/vmess/vmess.go

38 lines
861 B
Go
Raw Normal View History

2015-09-07 15:12:31 +00:00
// Package vmess contains protocol definition, io lib for VMess.
package vmess
2015-09-05 15:48:38 +00:00
import (
2015-09-06 20:10:42 +00:00
"net"
2015-09-05 15:48:38 +00:00
)
2015-09-07 13:10:37 +00:00
// VMessInput implements the input message of VMess protocol. It only contains
// the header of a input message. The data part will be handled by conection
// handler directly, in favor of data streaming.
2015-09-05 15:48:38 +00:00
type VMessInput struct {
2015-09-06 20:10:42 +00:00
version byte
userHash [16]byte
randHash [256]byte
respKey [32]byte
iv [16]byte
command byte
port uint16
target [256]byte
2015-09-05 15:48:38 +00:00
}
type VMessReader struct {
2015-09-06 20:10:42 +00:00
conn *net.Conn
2015-09-05 15:48:38 +00:00
}
2015-09-07 13:10:37 +00:00
// NewVMessReader creates a new VMessReader
2015-09-05 15:48:38 +00:00
func NewVMessReader(conn *net.Conn) (VMessReader, error) {
2015-09-06 20:10:42 +00:00
var reader VMessReader
reader.conn = conn
return reader, nil
2015-09-05 15:48:38 +00:00
}
2015-09-07 13:10:37 +00:00
// Read reads data from current connection and form a VMessInput if possible.
2015-09-05 15:48:38 +00:00
func (*VMessReader) Read() (VMessInput, error) {
2015-09-06 20:10:42 +00:00
var input VMessInput
return input, nil
}