vmess

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

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 (
	CmdTCP byte = 1
	CmdUDP byte = 2
)

CMD types

Variables

This section is empty.

Functions

func AEADReader

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

AEADReader returns a aead reader.

func AEADWriter

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

AEADWriter returns a aead writer.

func ChunkedReader

func ChunkedReader(r io.Reader) io.Reader

ChunkedReader returns a chunked reader.

func ChunkedWriter

func ChunkedWriter(w io.Writer) 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 GetWriteBuffer

func GetWriteBuffer() *bytes.Buffer

GetWriteBuffer returns a bytes.buffer from pool.

func NewVMessDialer

func NewVMessDialer(remote, uuid, sectp string, aid int, 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 PutWriteBuffer

func PutWriteBuffer(buf *bytes.Buffer)

PutWriteBuffer puts a bytes.buffer into pool.

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 Addr

type Addr []byte

Addr is vmess addr.

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 Client

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

Client is a vmess client.

func NewClient

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

NewClient returns a new vmess client.

func (*Client) NewConn

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

NewConn returns a new vmess conn.

type Conn

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

Conn is a connection to vmess server.

func (*Conn) Auth

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

func (c *Conn) Request() error

Request sends request to server.

func (*Conn) Write

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

type Port

type Port uint16

Port is vmess addr port.

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(remote, uuid, sectp string, aid int, 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, net.Addr, 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