Skip to content

Commit

Permalink
user: support event processor
Browse files Browse the repository at this point in the history
Decode the content of an OpenSSL event.

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
  • Loading branch information
cfc4n committed Jan 21, 2024
1 parent f368e82 commit 74d8c9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion user/event/event_openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (se *SSLDataEvent) String() string {

func (se *SSLDataEvent) Clone() IEventStruct {
event := new(SSLDataEvent)
event.eventType = EventTypeModuleData //EventTypeEventProcessor
event.eventType = EventTypeEventProcessor
return event
}

Expand Down
19 changes: 13 additions & 6 deletions user/module/imodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,22 @@ func (m *Module) Decode(em *ebpf.Map, b []byte) (event event.IEventStruct, err e
return te, nil
}

// 写入数据,或者上传到远程数据库,写入到其他chan 等。
// Dispatcher 写入数据,或者上传到远程数据库,写入到其他chan 等。
func (m *Module) Dispatcher(e event.IEventStruct) {
switch e.EventType() {
case event.EventTypeOutput:
if m.conf.GetHex() {

// If Hex mode is enabled, data in hex format is directly printed for event processor and output events
if m.conf.GetHex() {
if e.EventType() == event.EventTypeEventProcessor || e.EventType() == event.EventTypeOutput {
m.logger.Println(e.StringHex())
} else {
m.logger.Println(e.String())
return
}
}

// If Hex mode is not enabled, or if the event_processor and output events are not enabled,
// they will be handled according to multiple branches of the switch
switch e.EventType() {
case event.EventTypeOutput:
m.logger.Println(e.String())
case event.EventTypeEventProcessor:
m.processor.Write(e)
case event.EventTypeModuleData:
Expand Down

0 comments on commit 74d8c9e

Please sign in to comment.