feat(app): add WGRplane web UI and backend features
- Add Vue 3 frontend with glassmorphism design (Tailwind CSS) - Add Go backend handlers: auth, webhooks, stats, scheduler, validation - Add i18n support (EN, ID, ZH) - Add Swagger docs and API handlers - Add nftables integration and plugins support - Remove deprecated go.mod (migrated to wgrplane)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Plugin defines a simple notification interface.
|
||||
type Plugin interface {
|
||||
Notify(event string, payload interface{})
|
||||
}
|
||||
|
||||
// TelegramNotifier is a mock notifier that would send a Telegram message in a real deployment.
|
||||
type TelegramNotifier struct{}
|
||||
|
||||
func (t *TelegramNotifier) Notify(event string, payload interface{}) {
|
||||
fmt.Printf("[TelegramNotifier] event=%s payload=%v\n", event, payload)
|
||||
}
|
||||
|
||||
// SlackNotifier is a mock notifier that would send a Slack message in a real deployment.
|
||||
type SlackNotifier struct{}
|
||||
|
||||
func (s *SlackNotifier) Notify(event string, payload interface{}) {
|
||||
fmt.Printf("[SlackNotifier] event=%s payload=%v\n", event, payload)
|
||||
}
|
||||
|
||||
// TrafficLogger logs traffic-related events for debugging/observability.
|
||||
type TrafficLogger struct{}
|
||||
|
||||
func (l *TrafficLogger) Notify(event string, payload interface{}) {
|
||||
fmt.Printf("[TrafficLogger] event=%s payload=%v\n", event, payload)
|
||||
}
|
||||
|
||||
// PluginManager loads and triggers plugins.
|
||||
type PluginManager struct {
|
||||
plugins []Plugin
|
||||
}
|
||||
|
||||
// NewPluginManager creates a new PluginManager instance.
|
||||
func NewPluginManager() *PluginManager {
|
||||
return &PluginManager{plugins: []Plugin{}}
|
||||
}
|
||||
|
||||
// LoadPlugins initializes the built-in example plugins.
|
||||
func (pm *PluginManager) LoadPlugins() {
|
||||
pm.plugins = []Plugin{
|
||||
&TelegramNotifier{},
|
||||
&SlackNotifier{},
|
||||
&TrafficLogger{},
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger dispatches an event to all registered plugins.
|
||||
func (pm *PluginManager) Trigger(event string, payload interface{}) {
|
||||
for _, p := range pm.plugins {
|
||||
p.Notify(event, payload)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user