encoding

package
v3.17.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Version = byte(1)
)

Variables

View Source
var (
	ErrCommandTypeMismatch = newError("Command type mismatch.")
	ErrUnknownCommand      = newError("Unknown command.")
	ErrCommandTooLarge     = newError("Command too large.")
)

Functions

func Authenticate

func Authenticate(b []byte) uint32

Authenticate authenticates a byte array using Fnv hash.

func GenerateChacha20Poly1305Key

func GenerateChacha20Poly1305Key(b []byte) []byte

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

func MarshalCommand

func MarshalCommand(command interface{}, writer io.Writer) error

func UnmarshalCommand

func UnmarshalCommand(cmdID byte, data []byte) (protocol.ResponseCommand, error)

Types

type ChunkNonceGenerator

type ChunkNonceGenerator struct {
	Nonce []byte
	Size  int
	// contains filtered or unexported fields
}

func (*ChunkNonceGenerator) Next

func (g *ChunkNonceGenerator) Next() []byte

type ClientSession

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

ClientSession stores connection session info for VMess client.

func NewClientSession

func NewClientSession(idHash protocol.IDHash) *ClientSession

NewClientSession creates a new ClientSession.

func (*ClientSession) DecodeResponseBody

func (c *ClientSession) DecodeResponseBody(request *protocol.RequestHeader, reader io.Reader) buf.Reader

func (*ClientSession) DecodeResponseHeader

func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.ResponseHeader, error)

func (*ClientSession) EncodeRequestBody

func (c *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, writer io.Writer) buf.Writer

func (*ClientSession) EncodeRequestHeader

func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writer io.Writer) error

type CommandFactory

type CommandFactory interface {
	Marshal(command interface{}, writer io.Writer) error
	Unmarshal(data []byte) (interface{}, error)
}

type CommandSwitchAccountFactory

type CommandSwitchAccountFactory struct {
}

func (*CommandSwitchAccountFactory) Marshal

func (f *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.Writer) error

func (*CommandSwitchAccountFactory) Unmarshal

func (f *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, error)

type FnvAuthenticator

type FnvAuthenticator struct {
}

FnvAuthenticator is an AEAD based on Fnv hash.

func (*FnvAuthenticator) NonceSize

func (*FnvAuthenticator) NonceSize() int

NonceSize implements AEAD.NonceSize().

func (*FnvAuthenticator) Open

func (*FnvAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error)

Open implements AEAD.Open().

func (*FnvAuthenticator) Overhead

func (*FnvAuthenticator) Overhead() int

Overhead impelements AEAD.Overhead().

func (*FnvAuthenticator) Seal

func (*FnvAuthenticator) Seal(dst, nonce, plaintext, additionalData []byte) []byte

Seal implements AEAD.Seal().

type NoOpAuthenticator

type NoOpAuthenticator struct{}

func (NoOpAuthenticator) NonceSize

func (NoOpAuthenticator) NonceSize() int

func (NoOpAuthenticator) Open

func (NoOpAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error)

Open implements AEAD.Open().

func (NoOpAuthenticator) Overhead

func (NoOpAuthenticator) Overhead() int

func (NoOpAuthenticator) Seal

func (NoOpAuthenticator) Seal(dst, nonce, plaintext, additionalData []byte) []byte

Seal implements AEAD.Seal().

type ServerSession

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

func NewServerSession

func NewServerSession(validator protocol.UserValidator, sessionHistory *SessionHistory) *ServerSession

NewServerSession creates a new ServerSession, using the given UserValidator. The ServerSession instance doesn't take ownership of the validator.

func (*ServerSession) DecodeRequestBody

func (s *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reader io.Reader) buf.Reader

func (*ServerSession) DecodeRequestHeader

func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.RequestHeader, error)

func (*ServerSession) EncodeResponseBody

func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writer io.Writer) buf.Writer

func (*ServerSession) EncodeResponseHeader

func (s *ServerSession) EncodeResponseHeader(header *protocol.ResponseHeader, writer io.Writer)

type SessionHistory

type SessionHistory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSessionHistory

func NewSessionHistory() *SessionHistory

func (*SessionHistory) Close

func (h *SessionHistory) Close() error

Close implements common.Closable.

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) SizeBytes

func (*ShakeSizeParser) SizeBytes() int32

Jump to

Keyboard shortcuts

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