Documentation ¶
Index ¶
- Constants
- Variables
- func GetPayLoadLength(protocol string) int
- func GetPayloadString(data []byte, protocolName string) string
- func SetPayLoadLength(protocol string, length int)
- type FastFailFn
- type PairMatch
- type ParsePkgFn
- type PayloadMessage
- func (message PayloadMessage) AddBoolAttribute(key string, value bool)
- func (message PayloadMessage) AddByteArrayUtf8Attribute(key string, value []byte)
- func (message PayloadMessage) AddIntAttribute(key string, value int64)
- func (message PayloadMessage) AddStringAttribute(key string, value string)
- func (message PayloadMessage) AddUtf8StringAttribute(key string, value string)
- func (message PayloadMessage) GetAttributes() *model.AttributeMap
- func (message PayloadMessage) GetBoolAttribute(key string) bool
- func (message *PayloadMessage) GetData(offset int, length int) []byte
- func (message PayloadMessage) GetIntAttribute(key string) int64
- func (message PayloadMessage) GetStringAttribute(key string) string
- func (message PayloadMessage) HasAttribute(key string) bool
- func (message *PayloadMessage) HasMoreLength(length int) bool
- func (message *PayloadMessage) IsComplete() bool
- func (message *PayloadMessage) ReadArraySize(offset int, compact bool, size *int32) (toOffset int, err error)
- func (message *PayloadMessage) ReadBytes(offset int, length int) (toOffset int, value []byte, err error)
- func (message *PayloadMessage) ReadInt16(offset int, v *int16) (toOffset int, err error)
- func (message *PayloadMessage) ReadInt32(offset int, v *int32) (toOffset int, err error)
- func (message *PayloadMessage) ReadNullableString(offset int, compact bool, v *string) (toOffset int, err error)
- func (message *PayloadMessage) ReadString(offset int, compact bool, v *string) (toOffset int, err error)
- func (message *PayloadMessage) ReadUInt16(offset int) (value uint16, err error)
- func (message *PayloadMessage) ReadUnsignedVarInt(offset int, v *uint64) (toOffset int, err error)
- func (message *PayloadMessage) ReadUntilBlank(from int) (int, []byte)
- func (message *PayloadMessage) ReadUntilBlankWithLength(from int, fixedLength int) (int, []byte)
- func (message *PayloadMessage) ReadUntilCRLF(from int) (offset int, data []byte)
- func (message *PayloadMessage) ReadVarInt(offset int, v *int64) (toOffset int, err error)
- type PkgParser
- type ProtocolParser
- func (parser *ProtocolParser) AddPortCount(port uint32) uint32
- func (parser *ProtocolParser) EnableMultiFrame()
- func (parser *ProtocolParser) GetProtocol() string
- func (parser *ProtocolParser) MultiRequests() bool
- func (parser *ProtocolParser) PairMatch(requests []*PayloadMessage, response *PayloadMessage) int
- func (parser *ProtocolParser) ParseRequest(message *PayloadMessage) bool
- func (parser *ProtocolParser) ParseResponse(message *PayloadMessage) bool
- func (parser *ProtocolParser) ResetPort(port uint32)
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 GetPayloadString ¶
func SetPayLoadLength ¶
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 (*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 (*PayloadMessage) ReadString ¶
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)
Click to show internal directories.
Click to hide internal directories.