Added dynamic capture capabilities to plugin API

- Added dynamic capture ingress and sniff endpoint
- Removed static capture example (API update)
This commit is contained in:
Toby Chui
2025-03-02 12:26:44 +08:00
parent 39d6d16c2a
commit 23d4df1ed7
25 changed files with 961 additions and 644 deletions

View File

@@ -21,23 +21,27 @@ type Plugin struct {
Enabled bool //Whether the plugin is enabled
//Runtime
AssignedPort int //The assigned port for the plugin
uiProxy *dpcore.ReverseProxy //The reverse proxy for the plugin UI
staticRouteProxy map[string]*dpcore.ReverseProxy //Storing longest prefix => dpcore map for static route
process *exec.Cmd //The process of the plugin
AssignedPort int //The assigned port for the plugin
uiProxy *dpcore.ReverseProxy //The reverse proxy for the plugin UI
staticRouteProxy map[string]*dpcore.ReverseProxy //Storing longest prefix => dpcore map for static route
dynamicRouteProxy *dpcore.ReverseProxy //The reverse proxy for the dynamic route
process *exec.Cmd //The process of the plugin
}
type ManagerOptions struct {
PluginDir string //The directory where the plugins are stored
PluginGroups map[string][]string //The plugin groups,key is the tag name and the value is an array of plugin IDs
/* Runtime */
SystemConst *zoraxyPlugin.RuntimeConstantValue
Database *database.Database
Logger *logger.Logger
CSRFTokenGen func(*http.Request) string //The CSRF token generator function
CSRFTokenGen func(*http.Request) string `json:"-"` //The CSRF token generator function
Database *database.Database `json:"-"`
Logger *logger.Logger `json:"-"`
}
type Manager struct {
LoadedPlugins sync.Map //Storing *Plugin
TagPluginMap sync.Map //Storing *radix.Tree for each plugin tag
LoadedPlugins sync.Map //Storing *Plugin
tagPluginMap sync.Map //Storing *radix.Tree for each plugin tag
tagPluginList map[string][]*Plugin //Storing the plugin list for each tag, only concurrent READ is allowed
Options *ManagerOptions
}