mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-09-14 08:09:38 +02:00
add a dummy event
This commit is contained in:
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ func main() {
|
|||||||
string(events.EventBlacklistedIPBlocked): "This event is triggered when a blacklisted IP is blocked",
|
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.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.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",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ func (p *Plugin) Notify(event events.Event) error {
|
|||||||
if !strings.HasPrefix(subscriptionPath, "/") {
|
if !strings.HasPrefix(subscriptionPath, "/") {
|
||||||
subscriptionPath = "/" + subscriptionPath
|
subscriptionPath = "/" + subscriptionPath
|
||||||
}
|
}
|
||||||
|
subscriptionPath = strings.TrimSuffix(subscriptionPath, "/")
|
||||||
|
|
||||||
// Prepare the URL
|
// Prepare the URL
|
||||||
url := fmt.Sprintf("http://127.0.0.1:%d%s/%s", p.AssignedPort, subscriptionPath, event.Name)
|
url := fmt.Sprintf("http://127.0.0.1:%d%s/%s", p.AssignedPort, subscriptionPath, event.Name)
|
||||||
|
@@ -35,6 +35,8 @@ const (
|
|||||||
// A custom event emitted by a plugin, with the intention of being broadcast
|
// A custom event emitted by a plugin, with the intention of being broadcast
|
||||||
// to the designated recipient(s)
|
// to the designated recipient(s)
|
||||||
EventCustom EventName = "customEvent"
|
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
|
// Add more event types as needed
|
||||||
)
|
)
|
||||||
@@ -44,6 +46,7 @@ var validEventNames = map[EventName]bool{
|
|||||||
EventBlacklistToggled: true,
|
EventBlacklistToggled: true,
|
||||||
EventAccessRuleCreated: true,
|
EventAccessRuleCreated: true,
|
||||||
EventCustom: true,
|
EventCustom: true,
|
||||||
|
EventDummy: true,
|
||||||
// Add more event types as needed
|
// Add more event types as needed
|
||||||
// NOTE: Keep up-to-date with event names specified above
|
// NOTE: Keep up-to-date with event names specified above
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user