event_processor

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ssl2Version   = 0x0002
	Ssl3Version   = 0x0300
	Tls1Version   = 0x0301
	Tls11Version  = 0x0302
	Tls12Version  = 0x0303
	Tls13Version  = 0x0304
	Dtls1Version  = 0xFEFF
	Dtls12Version = 0xFEFD
)
View Source
const (
	MaxTickerCount = 10   // 1 Sencond/(eventWorker.ticker.C) = 10
	MaxChanLen     = 1024 // 包队列长度

)
View Source
const (
	MaxIncomingChanLen = 1024
	MaxParserQueueLen  = 1024
)
View Source
const ChunkSize = 16
View Source
const ChunkSizeHalf = ChunkSize / 2
View Source
const ClientPrefaceLen = len(http2.ClientPreface)
View Source
const MaxDataSize = 1024 * 16
View Source
const SocketLifecycleUUIDPrefix = "sock:"

SocketLifecycleUUIDPrefix Socket生命周期UUID前缀

Variables

View Source
var (
	ErrEventWorkerIncomingFull  = errors.New("eventWorker Write failed, incoming chan is full")
	ErrEventWorkerOutcomingFull = errors.New("eventWorker Write failed, outComing chan is full")
)

Functions

func CToGoString

func CToGoString(c []byte) string

func GetAllModules

func GetAllModules() map[string]IParser

GetAllModules 获取modules列表

func Register

func Register(p IParser)

Types

type AttachType

type AttachType int64
const (
	ProbeEntry AttachType = iota
	ProbeRet
)

type Base

type Base struct {
	Timestamp int64  // 时间戳
	UUID      string // 唯一标识符
	PID       int64  // 进程ID
	PName     string // 进程名称
	SrcIP     string // 源IP
	SrcPort   uint16 // 源端口
	DstIP     string // 目标IP
	DstPort   uint16 // 目标端口
	Type      uint32 // 事件类型
}

Base 事件基础信息

type BaseEvent

type BaseEvent struct {
	DataType  int64
	Timestamp uint64
	Pid       uint32
	Tid       uint32
	Data      [MaxDataSize]byte
	DataLen   int32
	Comm      [16]byte
	Fd        uint32
	Version   int32
	// contains filtered or unexported fields
}

func (*BaseEvent) Base

func (be *BaseEvent) Base() Base

func (*BaseEvent) Clone

func (be *BaseEvent) Clone() IEventStruct

func (*BaseEvent) Decode

func (be *BaseEvent) Decode(payload []byte) (err error)

func (*BaseEvent) EventType

func (be *BaseEvent) EventType() Type

func (*BaseEvent) GetUUID

func (be *BaseEvent) GetUUID() string

func (*BaseEvent) Payload

func (be *BaseEvent) Payload() []byte

func (*BaseEvent) PayloadLen

func (be *BaseEvent) PayloadLen() int

func (*BaseEvent) String

func (be *BaseEvent) String() string

func (*BaseEvent) StringHex

func (be *BaseEvent) StringHex() string

func (*BaseEvent) ToProtobufEvent

func (be *BaseEvent) ToProtobufEvent() *pb.Event

type CollectorWriter

type CollectorWriter interface {
	Write(p []byte) (n int, err error)
}

CollectorWriter 收集器写入接口 用于识别日志输出器是否是collector类型

type DefaultParser

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

func (*DefaultParser) Display

func (dp *DefaultParser) Display() []byte

func (*DefaultParser) Init

func (dp *DefaultParser) Init()

func (*DefaultParser) IsDone

func (dp *DefaultParser) IsDone() bool

func (*DefaultParser) Name

func (dp *DefaultParser) Name() string

func (*DefaultParser) PacketType

func (dp *DefaultParser) PacketType() PacketType

func (*DefaultParser) ParserType

func (dp *DefaultParser) ParserType() ParserType

func (*DefaultParser) Reset

func (dp *DefaultParser) Reset()

func (*DefaultParser) Write

func (dp *DefaultParser) Write(b []byte) (int, error)

type EventProcessor

type EventProcessor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewEventProcessor

func NewEventProcessor(logger io.Writer, isHex bool, truncateSize uint64) *EventProcessor

func (*EventProcessor) Close

func (ep *EventProcessor) Close() error

func (*EventProcessor) ErrorChan

func (ep *EventProcessor) ErrorChan() chan error

func (*EventProcessor) GetLogger

func (ep *EventProcessor) GetLogger() io.Writer

func (*EventProcessor) Serve

func (ep *EventProcessor) Serve() error

Serve Write event 处理器读取事件

func (*EventProcessor) Write

func (ep *EventProcessor) Write(e IEventStruct)

Write event 外部调用者调用该方法

func (*EventProcessor) WriteDestroyConn

func (ep *EventProcessor) WriteDestroyConn(s uint64)

type HTTP2Request

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

func (*HTTP2Request) Display

func (h2r *HTTP2Request) Display() []byte

func (*HTTP2Request) Init

func (h2r *HTTP2Request) Init()

func (*HTTP2Request) IsDone

func (h2r *HTTP2Request) IsDone() bool

func (*HTTP2Request) Name

func (h2r *HTTP2Request) Name() string

func (*HTTP2Request) PacketType

func (h2r *HTTP2Request) PacketType() PacketType

func (*HTTP2Request) ParserType

func (h2r *HTTP2Request) ParserType() ParserType

func (*HTTP2Request) Reset

func (h2r *HTTP2Request) Reset()

func (*HTTP2Request) Write

func (h2r *HTTP2Request) Write(b []byte) (int, error)

type HTTP2Response

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

func (*HTTP2Response) Display

func (h2r *HTTP2Response) Display() []byte

func (*HTTP2Response) Init

func (h2r *HTTP2Response) Init()

func (*HTTP2Response) IsDone

func (h2r *HTTP2Response) IsDone() bool

func (*HTTP2Response) Name

func (h2r *HTTP2Response) Name() string

func (*HTTP2Response) PacketType

func (h2r *HTTP2Response) PacketType() PacketType

func (*HTTP2Response) ParserType

func (h2r *HTTP2Response) ParserType() ParserType

func (*HTTP2Response) Reset

func (h2r *HTTP2Response) Reset()

func (*HTTP2Response) Write

func (h2r *HTTP2Response) Write(b []byte) (int, error)

type HTTPRequest

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

func (*HTTPRequest) Display

func (hr *HTTPRequest) Display() []byte

func (*HTTPRequest) Init

func (hr *HTTPRequest) Init()

func (*HTTPRequest) IsDone

func (hr *HTTPRequest) IsDone() bool

func (*HTTPRequest) Name

func (hr *HTTPRequest) Name() string

func (*HTTPRequest) PacketType

func (hr *HTTPRequest) PacketType() PacketType

func (*HTTPRequest) ParserType

func (hr *HTTPRequest) ParserType() ParserType

func (*HTTPRequest) Reset

func (hr *HTTPRequest) Reset()

func (*HTTPRequest) Write

func (hr *HTTPRequest) Write(b []byte) (int, error)

type HTTPResponse

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

func (*HTTPResponse) Display

func (hr *HTTPResponse) Display() []byte

func (*HTTPResponse) Init

func (hr *HTTPResponse) Init()

func (*HTTPResponse) IsDone

func (hr *HTTPResponse) IsDone() bool

func (*HTTPResponse) Name

func (hr *HTTPResponse) Name() string

func (*HTTPResponse) PacketType

func (hr *HTTPResponse) PacketType() PacketType

func (*HTTPResponse) ParserType

func (hr *HTTPResponse) ParserType() ParserType

func (*HTTPResponse) Reset

func (hr *HTTPResponse) Reset()

func (*HTTPResponse) Write

func (hr *HTTPResponse) Write(b []byte) (int, error)

type IEventStruct

type IEventStruct interface {
	// GetUUID 获取事件的唯一标识符
	GetUUID() string

	// Payload 获取事件的payload数据
	Payload() []byte

	// Base 获取事件的基本信息
	Base() Base

	// ToProtobufEvent 转换为protobuf事件
	ToProtobufEvent() *pb.Event

	// Clone 克隆事件
	Clone() IEventStruct

	// EventType 获取事件类型
	EventType() Type
}

IEventStruct 事件接口定义 这个接口定义了event_processor需要的事件方法

type IParser

type IParser interface {
	Write(b []byte) (int, error)
	ParserType() ParserType
	PacketType() PacketType
	// Name Body() []byte
	Name() string
	IsDone() bool
	Init()
	Display() []byte
	Reset()
	// contains filtered or unexported methods
}

func GetModuleByName

func GetModuleByName(name string) IParser

GetModuleByName 获取modules列表

func NewParser

func NewParser(payload []byte) IParser

type IWorker

type IWorker interface {

	// 收包
	Write(IEventStruct) error
	GetUUID() string
	GetDestroyUUID() uint64
	IfUsed() bool
	Get()
	Put()
	CloseEventWorker()
}

func NewEventWorker

func NewEventWorker(uuid string, processor *EventProcessor) IWorker

type LifeCycleState

type LifeCycleState uint8

eventWorker有两种生命周期,一种由自己的定时器决定,另一种由外部Socket的生命周期决定

const (
	LifeCycleStateDefault LifeCycleState = iota
	LifeCycleStateSock
)

type PacketType

type PacketType uint8
const (
	PacketTypeNull PacketType = iota
	PacketTypeUnknow
	PacketTypeGzip
	PacketTypeWebSocket
)

type ParserType

type ParserType uint8
const (
	ParserTypeNull ParserType = iota
	ParserTypeHttpRequest
	ParserTypeHttp2Request
	ParserTypeHttpResponse
	ParserTypeHttp2Response
	ParserTypeWebSocket
)

type ProcessStatus

type ProcessStatus uint8
const (
	ProcessStateInit ProcessStatus = iota
	ProcessStateProcessing
	ProcessStateDone
)

type TlsVersion

type TlsVersion struct {
	Version int32
}

func (TlsVersion) String

func (t TlsVersion) String() string

type Type

type Type uint8

Type 事件类型

const (
	// TypeOutput 输出事件
	TypeOutput Type = iota
	// TypeEventProcessor 由event processor处理的事件
	TypeEventProcessor
	// TypeModuleData 模块缓存数据事件
	TypeModuleData
)

Jump to

Keyboard shortcuts

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