From c8e42dcf599d2ccf05213535da0de5eef31a6446 Mon Sep 17 00:00:00 2001 From: Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Fri, 12 Sep 2025 20:28:02 -0500 Subject: [PATCH] add a dummy event --- .../api-call-example/mod/zoraxy_plugin/events/events.go | 3 +++ example/plugins/debugger/mod/zoraxy_plugin/events/events.go | 3 +++ .../dynamic-capture-example/mod/zoraxy_plugin/events/events.go | 3 +++ example/plugins/event-subscriber-example/main.go | 1 + .../mod/zoraxy_plugin/events/events.go | 3 +++ example/plugins/helloworld/mod/zoraxy_plugin/events/events.go | 3 +++ .../plugins/restful-example/mod/zoraxy_plugin/events/events.go | 3 +++ .../static-capture-example/mod/zoraxy_plugin/events/events.go | 3 +++ example/plugins/upnp/mod/zoraxy_plugin/events/events.go | 3 +++ src/mod/plugins/eventlistener.go | 1 + src/mod/plugins/zoraxy_plugin/events/events.go | 3 +++ 11 files changed, 29 insertions(+) diff --git a/example/plugins/api-call-example/mod/zoraxy_plugin/events/events.go b/example/plugins/api-call-example/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/api-call-example/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/api-call-example/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/debugger/mod/zoraxy_plugin/events/events.go b/example/plugins/debugger/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/debugger/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/debugger/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/dynamic-capture-example/mod/zoraxy_plugin/events/events.go b/example/plugins/dynamic-capture-example/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/dynamic-capture-example/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/dynamic-capture-example/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/event-subscriber-example/main.go b/example/plugins/event-subscriber-example/main.go index 5867c02..714b399 100644 --- a/example/plugins/event-subscriber-example/main.go +++ b/example/plugins/event-subscriber-example/main.go @@ -44,6 +44,7 @@ func main() { string(events.EventBlacklistedIPBlocked): "This event is triggered when a blacklisted IP is blocked", string(events.EventBlacklistToggled): "This event is triggered when the blacklist is toggled for an access rule", string(events.EventAccessRuleCreated): "This event is triggered when a new access ruleset is created", + string(events.EventCustom): "This event is a custom event that can be emitted by any plugin, we subscribe to it to demonstrate a \"monitor\" plugin that can see all custom events emitted by other plugins", }, }) diff --git a/example/plugins/event-subscriber-example/mod/zoraxy_plugin/events/events.go b/example/plugins/event-subscriber-example/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/event-subscriber-example/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/event-subscriber-example/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/helloworld/mod/zoraxy_plugin/events/events.go b/example/plugins/helloworld/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/helloworld/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/helloworld/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/restful-example/mod/zoraxy_plugin/events/events.go b/example/plugins/restful-example/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/restful-example/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/restful-example/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/static-capture-example/mod/zoraxy_plugin/events/events.go b/example/plugins/static-capture-example/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/static-capture-example/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/static-capture-example/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/example/plugins/upnp/mod/zoraxy_plugin/events/events.go b/example/plugins/upnp/mod/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/example/plugins/upnp/mod/zoraxy_plugin/events/events.go +++ b/example/plugins/upnp/mod/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above } diff --git a/src/mod/plugins/eventlistener.go b/src/mod/plugins/eventlistener.go index 21d3244..e542175 100644 --- a/src/mod/plugins/eventlistener.go +++ b/src/mod/plugins/eventlistener.go @@ -34,6 +34,7 @@ func (p *Plugin) Notify(event events.Event) error { if !strings.HasPrefix(subscriptionPath, "/") { subscriptionPath = "/" + subscriptionPath } + subscriptionPath = strings.TrimSuffix(subscriptionPath, "/") // Prepare the URL url := fmt.Sprintf("http://127.0.0.1:%d%s/%s", p.AssignedPort, subscriptionPath, event.Name) diff --git a/src/mod/plugins/zoraxy_plugin/events/events.go b/src/mod/plugins/zoraxy_plugin/events/events.go index 33b08ce..f911162 100644 --- a/src/mod/plugins/zoraxy_plugin/events/events.go +++ b/src/mod/plugins/zoraxy_plugin/events/events.go @@ -35,6 +35,8 @@ const ( // A custom event emitted by a plugin, with the intention of being broadcast // to the designated recipient(s) EventCustom EventName = "customEvent" + // A dummy event to satisfy the requirement of having at least one event + EventDummy EventName = "dummy" // Add more event types as needed ) @@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{ EventBlacklistToggled: true, EventAccessRuleCreated: true, EventCustom: true, + EventDummy: true, // Add more event types as needed // NOTE: Keep up-to-date with event names specified above }