vmess

package
v0.0.0-...-5ab0ef6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: GPL-3.0 Imports: 31 Imported by: 0

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

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

AEADReader returns a aead reader.

func AEADWriter

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

AEADWriter returns a aead writer.

func ChunkedReader

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

ChunkedReader returns a chunked reader.

func ChunkedWriter

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

type Atyp byte

Atyp is vmess addr type.

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

Atyp

type ChunkSizeDecoder

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

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

type ChunkSizeEncoder

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

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

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(cmd CmdType) error

Request sends request to server.

func (*Conn) Write

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

type PktConn

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

PktConn is a udp Packet.Conn.

func NewPktConn

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

NewPktConn returns a PktConn.

func (*PktConn) ReadFrom

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

ReadFrom implements the necessary function of net.PacketConn.

func (*PktConn) WriteTo

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

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

ShakeSizeParser implements ChunkSizeEncoder & ChunkSizeDecoder.

func NewShakeSizeParser

func NewShakeSizeParser(nonce []byte) *ShakeSizeParser

NewShakeSizeParser returns a new ShakeSizeParser.

func (*ShakeSizeParser) Decode

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

Decode implements ChunkSizeDecoder method.

func (*ShakeSizeParser) Encode

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

Encode implements ChunkSizeEncoder method.

func (*ShakeSizeParser) SizeBytes

func (*ShakeSizeParser) SizeBytes() int32

SizeBytes implements ChunkSizeEncoder method.

type StringOrNumber

type StringOrNumber string

func (*StringOrNumber) UnmarshalJSON

func (sn *StringOrNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON 是 StringOrNumber 的自定义解码函数

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.

type VMessJson

type VMessJson struct {
	V    string         `json:"v"`
	Ps   string         `json:"ps"`
	Add  string         `json:"add"`
	Port string         `json:"port"`
	ID   string         `json:"id"`
	Aid  StringOrNumber `json:"aid"`
	Net  string         `json:"net"`
	Type string         `json:"type"`
	Host string         `json:"host"`
	Path string         `json:"path"`
	TLS  string         `json:"tls"`
}

Jump to

Keyboard shortcuts

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