Added plugin context view

- Added plugin context view
- Moved plugin type definition to separate file
- Added wip request forwarder
This commit is contained in:
Toby Chui
2025-02-28 22:05:14 +08:00
parent 214b69b0b8
commit 5abc4ac606
9 changed files with 229 additions and 64 deletions

40
src/mod/plugins/typdef.go Normal file
View File

@@ -0,0 +1,40 @@
package plugins
import (
_ "embed"
"net/http"
"os/exec"
"sync"
"imuslab.com/zoraxy/mod/database"
"imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
"imuslab.com/zoraxy/mod/info/logger"
zoraxyPlugin "imuslab.com/zoraxy/mod/plugins/zoraxy_plugin"
)
//go:embed no_img.png
var noImg []byte
type Plugin struct {
RootDir string //The root directory of the plugin
Spec *zoraxyPlugin.IntroSpect //The plugin specification
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
process *exec.Cmd //The process of the plugin
}
type ManagerOptions struct {
PluginDir string
SystemConst *zoraxyPlugin.RuntimeConstantValue
Database *database.Database
Logger *logger.Logger
CSRFTokenGen func(*http.Request) string //The CSRF token generator function
}
type Manager struct {
LoadedPlugins sync.Map //Storing *Plugin
Options *ManagerOptions
}