Documentation ¶
Index ¶
- Constants
- func AEADReader(r io.Reader, aead cipher.AEAD, iv []byte) io.Reader
- func AEADWriter(w io.Writer, aead cipher.AEAD, iv []byte) io.Writer
- func ChunkedReader(r io.Reader) io.Reader
- func ChunkedWriter(w io.Writer) io.Writer
- func GetKey(uuid [16]byte) []byte
- func NewVmessClient(ctx context.Context, url *url.URL) (proxy.Client, error)
- func NewVmessServer(ctx context.Context, url *url.URL) (proxy.Server, error)
- func ParseAddr(s string) (byte, []byte, uint16, error)
- func StrToUUID(s string) (uuid [16]byte, err error)
- func TimestampHash(unixSec int64) []byte
- type Client
- type ClientConn
- type Server
- type ServerConn
- type SessionId
- type User
- type UserAtTime
- type UserManager
- func (um *UserManager) AddUser(hash string, more ...string) error
- func (um *UserManager) AuthUser(hash string) (bool, user.User)
- func (um *UserManager) CheckAuth(auth [16]byte) (*User, int64, error)
- func (um *UserManager) CheckSession(auth, uuid, reqBodyKey, reqBodyIV [16]byte) (*SessionId, error)
- func (um *UserManager) DelUser(hash string) error
- func (um *UserManager) ListUsers() []user.User
- func (um *UserManager) Refresh()
Constants ¶
const ( OptBasicFormat byte = 0 // 不加密传输 OptChunkStream byte = 1 // 分块传输,每个分块使用如下Security方法加密 )
Request Options
const ( SecurityAES128GCM byte = 3 SecurityChacha20Poly1305 byte = 4 SecurityNone byte = 5 )
Security types
const ( CmdTCP byte = 1 CmdUDP byte = 2 )
CMD types
const ( AtypIP4 byte = 1 AtypDomain byte = 2 AtypIP6 byte = 3 )
Atyp
const Name = "vmess"
Variables ¶
This section is empty.
Functions ¶
func AEADReader ¶
AEADReader returns a aead reader
func AEADWriter ¶
AEADWriter returns a aead writer
func ChunkedReader ¶
ChunkedReader returns a chunked reader
func ChunkedWriter ¶
ChunkedWriter returns a chunked writer
func GetKey ¶
GetKey returns the key of AES-128-CFB encrypter Key:MD5(UUID + []byte('c48619fe-8f02-49e0-b9e9-edf763e17e21'))
func TimestampHash ¶
TimestampHash returns the iv of AES-128-CFB encrypter IV:MD5(X + X + X + X),X = []byte(timestamp.now) (8 bytes, Big Endian)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a vmess client
type ClientConn ¶
ClientConn is a connection to vmess server
func (*ClientConn) Auth ¶
func (c *ClientConn) Auth() error
Auth send auth info: HMAC("md5", UUID, UTC)
func (*ClientConn) Close ¶
func (c *ClientConn) Close() error
func (*ClientConn) DecodeRespHeader ¶
func (c *ClientConn) DecodeRespHeader() error
DecodeRespHeader decodes response header.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Handshake ¶
func (s *Server) Handshake(underlay net.Conn) (proxy.StreamConn, *proxy.TargetAddr, error)
type ServerConn ¶
ServerConn wrapper a net.Conn with vmess protocol
func (*ServerConn) Close ¶
func (c *ServerConn) Close() error
type User ¶
type User struct { *user.Meter UUID [16]byte // VMess协议会使用用户的UUID生成AlterId个新的UUID,随机的使用不同的UUID进行传输这个用户的流量 // https://www.v2fly.org/config/protocols/vmess.html AlterId int UUIDs [][16]byte // AES-128-CFB加密算法的Key,用于指令部分的加密 // https://www.v2fly.org/developer/protocols/vmess.html#%E6%8C%87%E4%BB%A4%E9%83%A8%E5%88%86 CmdKey [16]byte }
VMess user
type UserAtTime ¶
type UserAtTime struct {
// contains filtered or unexported fields
}
type UserManager ¶
type UserManager struct {
// contains filtered or unexported fields
}
VMess user manager
func NewUserManager ¶
func NewUserManager(ctx context.Context, uuidStr, alterId string) *UserManager
Create a user manager with init user uuid and its alter id
func (*UserManager) AddUser ¶
func (um *UserManager) AddUser(hash string, more ...string) error
添加用户后,平均30秒会刷新
func (*UserManager) CheckAuth ¶
func (um *UserManager) CheckAuth(auth [16]byte) (*User, int64, error)
处理VMess请求的认证信息
func (*UserManager) CheckSession ¶
func (um *UserManager) CheckSession(auth, uuid, reqBodyKey, reqBodyIV [16]byte) (*SessionId, error)
从VMess请求的指令部分中提取出reqBodyKey和reqBodyIV,来判断某个UUID是否已经发送过同样的值
func (*UserManager) DelUser ¶
func (um *UserManager) DelUser(hash string) error
func (*UserManager) ListUsers ¶
func (um *UserManager) ListUsers() []user.User