protocol

package
v0.0.0-...-e368295 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP      = "http"
	DNS       = "dns"
	KAFKA     = "kafka"
	MYSQL     = "mysql"
	REDIS     = "redis"
	DUBBO     = "dubbo"
	ROCKETMQ  = "rocketmq"
	NOSUPPORT = "NOSUPPORT"
)
View Source
const (
	PARSE_FAIL     = 0
	PARSE_OK       = 1
	PARSE_COMPLETE = 2

	EOF = -1
)

Variables

View Source
var (
	ErrMessageComplete = errors.New("message completed")
	ErrMessageShort    = errors.New("message is too short")
	ErrMessageInvalid  = errors.New("message is invalid")
	ErrArgumentInvalid = errors.New("argument is invalid")
	ErrEof             = errors.New("EOF")
	ErrUnexpectedEOF   = errors.New("unexpected EOF")
)

Functions

func GetPayLoadLength

func GetPayLoadLength(protocol string) int

func GetPayloadString

func GetPayloadString(data []byte, protocolName string) string

func SetPayLoadLength

func SetPayLoadLength(protocol string, length int)

Types

type FastFailFn

type FastFailFn func(message *PayloadMessage) bool

type PairMatch

type PairMatch func(requests []*PayloadMessage, response *PayloadMessage) int

type ParsePkgFn

type ParsePkgFn func(message *PayloadMessage) (success bool, complete bool)

type PayloadMessage

type PayloadMessage struct {
	Data     []byte
	Offset   int
	Protocol model.L4Proto
	// contains filtered or unexported fields
}

func NewRequestMessage

func NewRequestMessage(data []byte) *PayloadMessage

func NewResponseMessage

func NewResponseMessage(data []byte, attributeMap *model.AttributeMap) *PayloadMessage

func (PayloadMessage) AddBoolAttribute

func (message PayloadMessage) AddBoolAttribute(key string, value bool)

func (PayloadMessage) AddByteArrayUtf8Attribute

func (message PayloadMessage) AddByteArrayUtf8Attribute(key string, value []byte)

func (PayloadMessage) AddIntAttribute

func (message PayloadMessage) AddIntAttribute(key string, value int64)

func (PayloadMessage) AddStringAttribute

func (message PayloadMessage) AddStringAttribute(key string, value string)

func (PayloadMessage) AddUtf8StringAttribute

func (message PayloadMessage) AddUtf8StringAttribute(key string, value string)

func (PayloadMessage) GetAttributes

func (message PayloadMessage) GetAttributes() *model.AttributeMap

=============== Attributes ===============

func (PayloadMessage) GetBoolAttribute

func (message PayloadMessage) GetBoolAttribute(key string) bool

func (*PayloadMessage) GetData

func (message *PayloadMessage) GetData(offset int, length int) []byte

func (PayloadMessage) GetIntAttribute

func (message PayloadMessage) GetIntAttribute(key string) int64

func (PayloadMessage) GetStringAttribute

func (message PayloadMessage) GetStringAttribute(key string) string

func (PayloadMessage) HasAttribute

func (message PayloadMessage) HasAttribute(key string) bool

func (*PayloadMessage) HasMoreLength

func (message *PayloadMessage) HasMoreLength(length int) bool

func (*PayloadMessage) IsComplete

func (message *PayloadMessage) IsComplete() bool

func (*PayloadMessage) ReadArraySize

func (message *PayloadMessage) ReadArraySize(offset int, compact bool, size *int32) (toOffset int, err error)

func (*PayloadMessage) ReadBytes

func (message *PayloadMessage) ReadBytes(offset int, length int) (toOffset int, value []byte, err error)

func (*PayloadMessage) ReadInt16

func (message *PayloadMessage) ReadInt16(offset int, v *int16) (toOffset int, err error)

func (*PayloadMessage) ReadInt32

func (message *PayloadMessage) ReadInt32(offset int, v *int32) (toOffset int, err error)

func (*PayloadMessage) ReadNullableString

func (message *PayloadMessage) ReadNullableString(offset int, compact bool, v *string) (toOffset int, err error)

func (*PayloadMessage) ReadString

func (message *PayloadMessage) ReadString(offset int, compact bool, v *string) (toOffset int, err error)

func (*PayloadMessage) ReadUInt16

func (message *PayloadMessage) ReadUInt16(offset int) (value uint16, err error)

=============== PayLoad ===============

func (*PayloadMessage) ReadUnsignedVarInt

func (message *PayloadMessage) ReadUnsignedVarInt(offset int, v *uint64) (toOffset int, err error)

func (*PayloadMessage) ReadUntilBlank

func (message *PayloadMessage) ReadUntilBlank(from int) (int, []byte)

func (*PayloadMessage) ReadUntilBlankWithLength

func (message *PayloadMessage) ReadUntilBlankWithLength(from int, fixedLength int) (int, []byte)

func (*PayloadMessage) ReadUntilCRLF

func (message *PayloadMessage) ReadUntilCRLF(from int) (offset int, data []byte)

Read Util \r\n

func (*PayloadMessage) ReadVarInt

func (message *PayloadMessage) ReadVarInt(offset int, v *int64) (toOffset int, err error)

type PkgParser

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

func CreatePkgParser

func CreatePkgParser(fastFail FastFailFn, parser ParsePkgFn) PkgParser

func (*PkgParser) Add

func (parent *PkgParser) Add(fastFail FastFailFn, parser ParsePkgFn) *PkgParser

type ProtocolParser

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

func NewProtocolParser

func NewProtocolParser(protocol string, requestParser PkgParser, responseParser PkgParser, pairMatch PairMatch) *ProtocolParser

func (*ProtocolParser) AddPortCount

func (parser *ProtocolParser) AddPortCount(port uint32) uint32

func (*ProtocolParser) EnableMultiFrame

func (parser *ProtocolParser) EnableMultiFrame()

func (*ProtocolParser) GetProtocol

func (parser *ProtocolParser) GetProtocol() string

func (*ProtocolParser) MultiRequests

func (parser *ProtocolParser) MultiRequests() bool

func (*ProtocolParser) PairMatch

func (parser *ProtocolParser) PairMatch(requests []*PayloadMessage, response *PayloadMessage) int

func (*ProtocolParser) ParseRequest

func (parser *ProtocolParser) ParseRequest(message *PayloadMessage) bool

func (*ProtocolParser) ParseResponse

func (parser *ProtocolParser) ParseResponse(message *PayloadMessage) bool

func (*ProtocolParser) ResetPort

func (parser *ProtocolParser) ResetPort(port uint32)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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