vmess

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT, GPL-3.0 Imports: 30 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	OptBasicFormat byte = 0
	OptChunkStream byte = 1
)

Request Options

View Source
const (
	SecurityAES128GCM        byte = 3
	SecurityChacha20Poly1305 byte = 4
	SecurityNone             byte = 5
)

Security types

View Source
const (
	KDFSaltConstAuthIDEncryptionKey             = "AES Auth ID Encryption"
	KDFSaltConstAEADRespHeaderLenKey            = "AEAD Resp Header Len Key"
	KDFSaltConstAEADRespHeaderLenIV             = "AEAD Resp Header Len IV"
	KDFSaltConstAEADRespHeaderPayloadKey        = "AEAD Resp Header Key"
	KDFSaltConstAEADRespHeaderPayloadIV         = "AEAD Resp Header IV"
	KDFSaltConstVMessAEADKDF                    = "VMess AEAD KDF"
	KDFSaltConstVMessHeaderPayloadAEADKey       = "VMess Header AEAD Key"
	KDFSaltConstVMessHeaderPayloadAEADIV        = "VMess Header AEAD Nonce"
	KDFSaltConstVMessHeaderPayloadLengthAEADKey = "VMess Header AEAD Key_Length"
	KDFSaltConstVMessHeaderPayloadLengthAEADIV  = "VMess Header AEAD Nonce_Length"
)

copy from https://github.com/v2fly/v2ray-core/tree/054e6679830885c94cc37d27ab2aa96b5b37e019/proxy/vmess/aead

Variables

This section is empty.

Functions

func AEADReader

func AEADReader(r io.Reader, aead cipher.AEAD, iv []byte) io.ReadCloser

AEADReader returns a aead reader

func AEADWriter

func AEADWriter(w io.Writer, aead cipher.AEAD, iv []byte) writer

AEADWriter returns a aead writer

func ChunkedReader

func ChunkedReader(r io.Reader) io.ReadCloser

ChunkedReader returns a chunked reader

func ChunkedWriter

func ChunkedWriter(w io.Writer) writer

ChunkedWriter returns a chunked writer

func CreateAuthID

func CreateAuthID(cmdKey []byte, time int64) [16]byte

func GetKey

func GetKey(uuid [16]byte) []byte

GetKey returns the key of AES-128-CFB encrypter Key:MD5(UUID + []byte('c48619fe-8f02-49e0-b9e9-edf763e17e21'))

func KDF

func KDF(key []byte, path ...string) []byte

func KDF16

func KDF16(key []byte, path ...string) []byte

func NewCipherFromKey

func NewCipherFromKey(cmdKey []byte) cipher.Block

func NewClient

func NewClient(config *protocol.Protocol_Vmess) point.WrapProxy

func OpenVMessAEADHeader

func OpenVMessAEADHeader(key [16]byte, authid [16]byte, data io.Reader) ([]byte, bool, int, error)

func ParseAddr

func ParseAddr(s netapi.Address) (address, error)

ParseAddr parses the address in string s

func SealVMessAEADHeader

func SealVMessAEADHeader(key [16]byte, data []byte) []byte

func StrToUUID

func StrToUUID(s string) (uuid [16]byte, err error)

StrToUUID converts string to uuid. s fomat: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"

func TimestampHash

func TimestampHash(t time.Time) []byte

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 Atyp

type Atyp byte

Atyp is vmess addr type

const (
	AtypErr    Atyp = 0
	AtypIP4    Atyp = 1
	AtypDomain Atyp = 2
	AtypIP6    Atyp = 3
)

Atyp

type CMD

type CMD byte
const (
	CmdTCP CMD = 1
	CmdUDP CMD = 2
)

CMD types

func (CMD) Byte

func (c CMD) Byte() byte

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client vmess client

func (*Client) NewConn

func (c *Client) NewConn(rc net.Conn, dst netapi.Address) (net.Conn, error)

func (*Client) NewPacketConn

func (c *Client) NewPacketConn(rc net.Conn, dst netapi.Address) (net.PacketConn, error)

type Conn

type Conn struct {
	net.Conn

	CMD CMD
	// contains filtered or unexported fields
}

Conn is a connection to vmess server

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) DecodeRespHeader

func (c *Conn) DecodeRespHeader() error

DecodeRespHeader .

func (*Conn) EncodeRequest

func (c *Conn) EncodeRequest() ([]byte, error)

EncodeRequest encodes requests to network bytes

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) ReadFrom

func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

func (*Conn) WriteTo

func (c *Conn) WriteTo(b []byte, target net.Addr) (int, error)

type User

type User struct {
	UUID   [16]byte
	CmdKey [16]byte
}

User of vmess client

func NewUser

func NewUser(uuid [16]byte) *User

NewUser .

func (*User) GenAlterIDUsers

func (u *User) GenAlterIDUsers(alterID int) []*User

GenAlterIDUsers generates users according to primary user's id and alterID

type Vmess

type Vmess struct {
	netapi.Proxy
	// contains filtered or unexported fields
}

Vmess client

func (*Vmess) Conn

func (v *Vmess) Conn(ctx context.Context, host netapi.Address) (conn net.Conn, err error)

Conn create a connection for host

func (*Vmess) PacketConn

func (v *Vmess) PacketConn(ctx context.Context, host netapi.Address) (conn net.PacketConn, err error)

PacketConn packet transport connection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL