Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticate(b []byte) uint32
- func GenerateChacha20Poly1305Key(b []byte) []byte
- func GenerateChunkNonce(nonce []byte, size uint32) crypto.BytesGenerator
- func MarshalCommand(command interface{}, writer io.Writer) error
- func UnmarshalCommand(cmdID byte, data []byte) (protocol.ResponseCommand, error)
- type AEADSizeParser
- type ClientSession
- func (c *ClientSession) DecodeResponseBody(request *protocol.RequestHeader, reader io.Reader) (buf.Reader, error)
- func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.ResponseHeader, error)
- func (c *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)
- func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writer io.Writer) error
- type CommandFactory
- type CommandSwitchAccountFactory
- type NoOpAuthenticator
- type ServerSession
- func (s *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reader io.Reader) (buf.Reader, error)
- func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*protocol.RequestHeader, error)
- func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)
- func (s *ServerSession) EncodeResponseHeader(header *protocol.ResponseHeader, writer io.Writer)
- type SessionHistory
- type ShakeSizeParser
Constants ¶
const (
Version = byte(1)
)
Variables ¶
Functions ¶
func Authenticate ¶
Authenticate authenticates a byte array using Fnv hash.
func GenerateChacha20Poly1305Key ¶
GenerateChacha20Poly1305Key generates a 32-byte key from a given 16-byte array.
func GenerateChunkNonce ¶
func GenerateChunkNonce(nonce []byte, size uint32) crypto.BytesGenerator
func MarshalCommand ¶
func UnmarshalCommand ¶
func UnmarshalCommand(cmdID byte, data []byte) (protocol.ResponseCommand, error)
Types ¶
type AEADSizeParser ¶
type AEADSizeParser struct {
crypto.AEADChunkSizeParser
}
func NewAEADSizeParser ¶
func NewAEADSizeParser(auth *crypto.AEADAuthenticator) *AEADSizeParser
type ClientSession ¶
type ClientSession struct {
// contains filtered or unexported fields
}
ClientSession stores connection session info for VMess client.
func NewClientSession ¶
func NewClientSession(ctx context.Context, behaviorSeed int64) *ClientSession
NewClientSession creates a new ClientSession.
func (*ClientSession) DecodeResponseBody ¶
func (c *ClientSession) DecodeResponseBody(request *protocol.RequestHeader, reader io.Reader) (buf.Reader, error)
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, error)
func (*ClientSession) EncodeRequestHeader ¶
func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writer io.Writer) error
type CommandFactory ¶
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 NoOpAuthenticator ¶
type NoOpAuthenticator struct{}
[DEPRECATED 2023-06]
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
}
ServerSession keeps information for a session in VMess server.
func NewServerSession ¶
func NewServerSession(validator *vmess.TimedUserValidator, 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, error)
DecodeRequestBody returns Reader from which caller can fetch decrypted body.
func (*ServerSession) DecodeRequestHeader ¶
func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*protocol.RequestHeader, error)
DecodeRequestHeader decodes and returns (if successful) a RequestHeader from an input stream.
func (*ServerSession) EncodeResponseBody ¶
func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)
EncodeResponseBody returns a Writer that auto-encrypt content written by caller.
func (*ServerSession) EncodeResponseHeader ¶
func (s *ServerSession) EncodeResponseHeader(header *protocol.ResponseHeader, writer io.Writer)
EncodeResponseHeader writes encoded response header into the given writer.
type SessionHistory ¶
SessionHistory keeps track of historical session ids, to prevent replay attacks.
func NewSessionHistory ¶
func NewSessionHistory() *SessionHistory
NewSessionHistory creates a new SessionHistory object.
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) MaxPaddingLen ¶
func (s *ShakeSizeParser) MaxPaddingLen() uint16
func (*ShakeSizeParser) NextPaddingLen ¶
func (s *ShakeSizeParser) NextPaddingLen() uint16
func (*ShakeSizeParser) SizeBytes ¶
func (*ShakeSizeParser) SizeBytes() int32