vmess

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

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"
)
View Source
const (
	OptionChunkStream        = 1
	OptionChunkLengthMasking = 4
	OptionGlobalPadding      = 8
)
View Source
const (
	MaxChunkSize = 1 << 14
	MaxUDPSize   = 1 << 11
)
View Source
const (
	IDBytesLen = 16
)

Variables

View Source
var (
	ErrInvalidMetadata = errors.Errorf("invalid metadata")
)
View Source
var (
	NewCipherMapper = map[Cipher]func(key []byte) (cipher.AEAD, error){
		CipherC20P1305:  NewC20P1305,
		CipherAES128GCM: NewAesGcm,
	}
)

Functions

func AuthEAuthID

func AuthEAuthID(blk cipher.Block, eAuthID []byte, doubleCuckoo *ReplayFilter, startTimestamp int64) error

func ContainOption

func ContainOption(options byte, option byte) bool

func DefaultIDHash

func DefaultIDHash(key []byte) hash.Hash

func EncryptReqHeaderFromPool

func EncryptReqHeaderFromPool(instruction []byte, cmdKey []byte) ([]byte, error)

func GenerateChacha20Poly1305KeyFromPool

func GenerateChacha20Poly1305KeyFromPool(b []byte) []byte

GenerateChacha20Poly1305Key generates a 32-byte key from a given 16-byte array.

func KDF

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

func MetadataTypeToByte added in v1.1.3

func MetadataTypeToByte(typ protocol.MetadataType) byte

func NetworkToByte added in v1.1.3

func NetworkToByte(network string) byte

func NewAesGcm

func NewAesGcm(key []byte) (cipher.AEAD, error)

func NewC20P1305

func NewC20P1305(key []byte) (cipher.AEAD, error)

func NewDialer added in v1.1.3

func NewDialer(nextDialer proxy.Dialer, header protocol.Header) (proxy.Dialer, error)

func ParseMetadataType added in v1.1.3

func ParseMetadataType(t byte) protocol.MetadataType

func ParseNetwork added in v1.1.3

func ParseNetwork(n byte) string

func PutEAuthID

func PutEAuthID(dst []byte, cmdKey []byte) []byte

func ReqInstructionDataFromPool

func ReqInstructionDataFromPool(metadata Metadata) []byte

func RespHeaderFromPool

func RespHeaderFromPool(V byte) []byte

Types

type BytesGenerator

type BytesGenerator func() []byte

func GenerateChunkNonce

func GenerateChunkNonce(nonce []byte, size uint32) BytesGenerator

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 Cipher

type Cipher string
const (
	CipherC20P1305  Cipher = "chacha20-poly1305"
	CipherAES128GCM Cipher = "aes-128-gcm"
)

func ParseCipherFromSecurity added in v1.1.3

func ParseCipherFromSecurity(security byte) (Cipher, error)

func (Cipher) ToSecurity

func (c Cipher) ToSecurity() byte

type Conn

type Conn struct {
	net.Conn

	NewAEAD func(key []byte) (cipher.AEAD, error)
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn net.Conn, metadata Metadata, cmdKey []byte) (c *Conn, err error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) EncryptRespHeaderFromPool

func (c *Conn) EncryptRespHeaderFromPool(header []byte) (b []byte, err error)

func (*Conn) InitContext

func (c *Conn) InitContext(instructionData []byte) error

func (*Conn) LocalAddr added in v1.1.3

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

func (*Conn) Metadata

func (c *Conn) Metadata() Metadata

func (*Conn) Read

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

func (*Conn) ReadFrom added in v1.1.3

func (c *Conn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*Conn) RemoteAddr added in v1.1.3

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

func (*Conn) Write

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

Write writes data to the connection. Empty b should be written before closing the connection to indicate the terminal.

func (*Conn) WriteReqHeader added in v1.1.8

func (c *Conn) WriteReqHeader() (err error)

func (*Conn) WriteTo added in v1.1.3

func (c *Conn) WriteTo(p []byte, addr net.Addr) (n int, err error)

type Dialer added in v1.1.3

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

func (*Dialer) Dial added in v1.1.3

func (d *Dialer) Dial(network string, addr string) (c net.Conn, err error)

type ID

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

The ID of en entity, in the form of a UUID.

func NewAlterIDs

func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID

func NewID

func NewID(uuid uuid.UUID) *ID

NewID returns an ID with given UUID.

func (*ID) Bytes

func (id *ID) Bytes() []byte

func (ID) CmdKey

func (id ID) CmdKey() []byte

func (*ID) Equals

func (id *ID) Equals(another *ID) bool

Equals returns true if this ID equals to the other one.

func (*ID) String

func (id *ID) String() string

func (*ID) UUID

func (id *ID) UUID() uuid.UUID

type IDHash

type IDHash func(key []byte) hash.Hash

type Metadata

type Metadata struct {
	protocol.Metadata

	Network string
	// contains filtered or unexported fields
}

func NewServerMetadata

func NewServerMetadata(cmdKey, eAuthID []byte) *Metadata

func (*Metadata) AddrLen

func (m *Metadata) AddrLen() int

func (*Metadata) CompleteFromInstructionData

func (m *Metadata) CompleteFromInstructionData(instructionData []byte) (err error)

func (*Metadata) PutAddr

func (m *Metadata) PutAddr(dst []byte) (n int)

type PaddingLengthGenerator

type PaddingLengthGenerator interface {
	MaxPaddingLen() uint16
	NextPaddingLen() uint16
}

type PlainChunkSizeParser

type PlainChunkSizeParser struct{}

func (PlainChunkSizeParser) Decode

func (PlainChunkSizeParser) Decode(b []byte) (uint16, error)

func (PlainChunkSizeParser) Encode

func (PlainChunkSizeParser) Encode(size uint16, b []byte) []byte

func (PlainChunkSizeParser) SizeBytes

func (PlainChunkSizeParser) SizeBytes() int32

type PlainPaddingGenerator

type PlainPaddingGenerator struct {
	PaddingLengthGenerator
}

func (PlainPaddingGenerator) MaxPaddingLen

func (PlainPaddingGenerator) MaxPaddingLen() uint16

func (PlainPaddingGenerator) NextPaddingLen

func (PlainPaddingGenerator) NextPaddingLen() uint16

type ReplayFilter

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

ReplayFilter check for replay attacks.

func NewReplayFilter

func NewReplayFilter(interval int64) *ReplayFilter

NewReplayFilter create a new filter with specifying the expiration time interval in seconds.

func (*ReplayFilter) Check

func (filter *ReplayFilter) Check(sum []byte) bool

Check determine if there are duplicate records.

func (*ReplayFilter) Interval

func (filter *ReplayFilter) Interval() int64

Interval in second for expiration time for duplicate records.

type ShakeSizeParser

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

func NewShakeSizeParser

func NewShakeSizeParser(nonce []byte) *ShakeSizeParser

func (*ShakeSizeParser) Decode

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

func (*ShakeSizeParser) Encode

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

func (*ShakeSizeParser) MaxPaddingLen

func (s *ShakeSizeParser) MaxPaddingLen() uint16

func (*ShakeSizeParser) NextPaddingLen

func (s *ShakeSizeParser) NextPaddingLen() uint16

func (*ShakeSizeParser) SizeBytes

func (*ShakeSizeParser) SizeBytes() int32

Jump to

Keyboard shortcuts

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