2015-09-07 11:12:31 -04:00
|
|
|
// Package vmess contains protocol definition, io lib for VMess.
|
|
|
|
package vmess
|
2015-09-05 11:48:38 -04:00
|
|
|
|
|
|
|
import (
|
2015-09-06 16:10:42 -04:00
|
|
|
"net"
|
2015-09-05 11:48:38 -04:00
|
|
|
)
|
|
|
|
|
2015-09-07 09:10:37 -04: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 11:48:38 -04:00
|
|
|
type VMessInput struct {
|
2015-09-06 16:10:42 -04: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 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type VMessReader struct {
|
2015-09-06 16:10:42 -04:00
|
|
|
conn *net.Conn
|
2015-09-05 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
2015-09-07 09:10:37 -04:00
|
|
|
// NewVMessReader creates a new VMessReader
|
2015-09-05 11:48:38 -04:00
|
|
|
func NewVMessReader(conn *net.Conn) (VMessReader, error) {
|
2015-09-06 16:10:42 -04:00
|
|
|
var reader VMessReader
|
|
|
|
reader.conn = conn
|
|
|
|
return reader, nil
|
2015-09-05 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
2015-09-07 09:10:37 -04:00
|
|
|
// Read reads data from current connection and form a VMessInput if possible.
|
2015-09-05 11:48:38 -04:00
|
|
|
func (*VMessReader) Read() (VMessInput, error) {
|
2015-09-06 16:10:42 -04:00
|
|
|
var input VMessInput
|
|
|
|
return input, nil
|
|
|
|
}
|