mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-19 15:01:22 +02:00
feat: add event emission for blocked requests and provider changes
- Emit ACL blocked events with matched rule information - Emit HTTP blocked events from CIDR whitelist, ForwardAuth, and OIDC middlewares - Emit global events for provider file/docker changes - Add MatchedIndex method to ACL matchers for rule identification - Update goutils submodule for events package update
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
watcherEvents "github.com/yusing/godoxy/internal/watcher/events"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/eventqueue"
|
||||
"github.com/yusing/goutils/events"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
@@ -118,11 +119,21 @@ func (p *Provider) Start(parent task.Parent) error {
|
||||
|
||||
opts := eventqueue.Options[watcherEvents.Event]{
|
||||
FlushInterval: providerEventFlushInterval,
|
||||
OnFlush: func(events []watcherEvents.Event) {
|
||||
OnFlush: func(evs []watcherEvents.Event) {
|
||||
handler := p.newEventHandler()
|
||||
// routes' lifetime should follow the provider's lifetime
|
||||
handler.Handle(t, events)
|
||||
handler.Handle(t, evs)
|
||||
handler.Log()
|
||||
|
||||
globalEvents := make([]events.Event, len(evs))
|
||||
for i, ev := range evs {
|
||||
globalEvents[i] = events.NewEvent(events.LevelInfo, "provider_event", ev.Action.String(), map[string]any{
|
||||
"provider": p.String(),
|
||||
"type": ev.Type, // file / docker
|
||||
"actor": ev.ActorName, // file path / container name
|
||||
})
|
||||
}
|
||||
events.Global.AddAll(globalEvents)
|
||||
},
|
||||
OnError: func(err error) {
|
||||
p.Logger().Err(err).Msg("event error")
|
||||
|
||||
Reference in New Issue
Block a user