vmess

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-3.0 Imports: 29 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OptBasicFormat byte = 0
	OptChunkStream byte = 1
	// OptReuseTCPConnection byte = 2
	OptChunkMasking byte = 4
)

Request Options

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

Security types

View Source
const MaxHostLen = 255

MaxHostLen is the maximum size of host in bytes.

Variables

This section is empty.

Functions

func AEADReader added in v0.6.2

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

AEADReader returns a aead reader.

func AEADWriter added in v0.6.2

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

AEADWriter returns a aead writer.

func ChunkedReader added in v0.6.2

func ChunkedReader(r io.Reader, chunkSizeDecoder ChunkSizeDecoder) io.Reader

ChunkedReader returns a chunked reader.

func ChunkedWriter added in v0.6.2

func ChunkedWriter(w io.Writer, chunkSizeEncoder ChunkSizeEncoder) io.Writer

ChunkedWriter returns a chunked writer.

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 NewVMessDialer

func NewVMessDialer(s string, dialer proxy.Dialer) (proxy.Dialer, error)

NewVMessDialer returns a vmess proxy dialer.

func ParseAddr

func ParseAddr(s string) (Atyp, Addr, Port, error)

ParseAddr parses the address in string s.

func StrToUUID

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

StrToUUID converts string to uuid.

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 Addr

type Addr []byte

Addr is vmess addr.

type Atyp added in v0.6.1

type Atyp byte

Atyp is vmess addr type.

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

Atyp

type ChunkSizeDecoder added in v0.15.1

type ChunkSizeDecoder interface {
	SizeBytes() int32
	Decode([]byte) (uint16, error)
}

ChunkSizeDecoder is a utility class to decode size value from bytes.

type ChunkSizeEncoder added in v0.15.1

type ChunkSizeEncoder interface {
	SizeBytes() int32
	Encode(uint16, []byte) []byte
}

ChunkSizeEncoder is a utility class to encode size value into bytes.

type Client

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

Client is a vmess client.

func NewClient

func NewClient(uuidStr, security string, alterID int, aead bool) (*Client, error)

NewClient returns a new vmess client.

func (*Client) NewConn

func (c *Client) NewConn(rc net.Conn, target string, cmd CmdType) (*Conn, error)

NewConn returns a new vmess conn.

type CmdType added in v0.13.0

type CmdType byte

CmdType is the type of vmess cmd

const (
	CmdTCP CmdType = 1
	CmdUDP CmdType = 2
)

Cmd Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a connection to vmess server.

func (*Conn) Auth added in v0.10.0

func (c *Conn) Auth() error

Auth send auth info: HMAC("md5", UUID, UTC).

func (*Conn) DecodeRespHeader

func (c *Conn) DecodeRespHeader() error

DecodeRespHeader decodes response header.

func (*Conn) Read

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

func (*Conn) Request added in v0.10.0

func (c *Conn) Request(cmd CmdType) error

Request sends request to server.

func (*Conn) Write

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

type PktConn added in v0.13.0

type PktConn struct {
	net.Conn
	// contains filtered or unexported fields
}

PktConn is a udp Packet.Conn.

func NewPktConn added in v0.13.0

func NewPktConn(c net.Conn, target *net.UDPAddr) *PktConn

NewPktConn returns a PktConn.

func (*PktConn) ReadFrom added in v0.13.0

func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom implements the necessary function of net.PacketConn.

func (*PktConn) WriteTo added in v0.13.0

func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo implements the necessary function of net.PacketConn.

type Port

type Port uint16

Port is vmess addr port.

type ShakeSizeParser added in v0.15.1

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

ShakeSizeParser implements ChunkSizeEncoder & ChunkSizeDecoder.

func NewShakeSizeParser added in v0.15.1

func NewShakeSizeParser(nonce []byte) *ShakeSizeParser

NewShakeSizeParser returns a new ShakeSizeParser.

func (*ShakeSizeParser) Decode added in v0.15.1

func (s *ShakeSizeParser) Decode(b []byte) (uint16, error)

Decode implements ChunkSizeDecoder method.

func (*ShakeSizeParser) Encode added in v0.15.1

func (s *ShakeSizeParser) Encode(size uint16, b []byte) []byte

Encode implements ChunkSizeEncoder method.

func (*ShakeSizeParser) SizeBytes added in v0.15.1

func (*ShakeSizeParser) SizeBytes() int32

SizeBytes implements ChunkSizeEncoder method.

type User

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

User of vmess client.

func NewUser

func NewUser(uuid [16]byte) *User

NewUser returns a new user.

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 {
	// contains filtered or unexported fields
}

VMess struct.

func NewVMess

func NewVMess(s string, d proxy.Dialer) (*VMess, error)

NewVMess returns a vmess proxy.

func (*VMess) Addr

func (s *VMess) Addr() string

Addr returns forwarder's address.

func (*VMess) Dial

func (s *VMess) Dial(network, addr string) (net.Conn, error)

Dial connects to the address addr on the network net via the proxy.

func (*VMess) DialUDP

func (s *VMess) DialUDP(network, addr string) (net.PacketConn, error)

DialUDP connects to the given address via the proxy.

Jump to

Keyboard shortcuts

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