From 0fdfda436b21070d90bceeecc8f86265888e2cf2 Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Sun, 16 Mar 2025 11:41:46 +0800 Subject: [PATCH] Added plugin info view - Added plugin info view - Removed zerotier related start parameters - Added automatic tag filter reset on tab change in http proxy page --- src/api.go | 1 + src/def.go | 2 - src/mod/plugins/handler.go | 22 +++ src/web/components/httprp.html | 3 + src/web/components/plugins.html | 94 ++++++++++--- src/web/snippet/pluginInfo.html | 232 ++++++++++++++++++++++++++++++++ 6 files changed, 334 insertions(+), 20 deletions(-) create mode 100644 src/web/snippet/pluginInfo.html diff --git a/src/api.go b/src/api.go index e211dfb..66000b3 100644 --- a/src/api.go +++ b/src/api.go @@ -226,6 +226,7 @@ func RegisterPluginAPIs(authRouter *auth.RouterDef) { authRouter.HandleFunc("/api/plugins/enable", pluginManager.HandleEnablePlugin) authRouter.HandleFunc("/api/plugins/disable", pluginManager.HandleDisablePlugin) authRouter.HandleFunc("/api/plugins/icon", pluginManager.HandleLoadPluginIcon) + authRouter.HandleFunc("/api/plugins/info", pluginManager.HandlePluginInfo) authRouter.HandleFunc("/api/plugins/groups/list", pluginManager.HandleListPluginGroups) authRouter.HandleFunc("/api/plugins/groups/add", pluginManager.HandleAddPluginToGroup) diff --git a/src/def.go b/src/def.go index a17c919..0719405 100644 --- a/src/def.go +++ b/src/def.go @@ -80,8 +80,6 @@ var ( allowSshLoopback = flag.Bool("sshlb", false, "Allow loopback web ssh connection (DANGER)") allowMdnsScanning = flag.Bool("mdns", true, "Enable mDNS scanner and transponder") mdnsName = flag.String("mdnsname", "", "mDNS name, leave empty to use default (zoraxy_{node-uuid}.local)") - ztAuthToken = flag.String("ztauth", "", "ZeroTier authtoken for the local node") - ztAPIPort = flag.Int("ztport", 9993, "ZeroTier controller API port") runningInDocker = flag.Bool("docker", false, "Run Zoraxy in docker compatibility mode") acmeAutoRenewInterval = flag.Int("autorenew", 86400, "ACME auto TLS/SSL certificate renew check interval (seconds)") acmeCertAutoRenewDays = flag.Int("earlyrenew", 30, "Number of days to early renew a soon expiring certificate (days)") diff --git a/src/mod/plugins/handler.go b/src/mod/plugins/handler.go index 9151d52..8e95805 100644 --- a/src/mod/plugins/handler.go +++ b/src/mod/plugins/handler.go @@ -173,6 +173,28 @@ func (m *Manager) HandleListPlugins(w http.ResponseWriter, r *http.Request) { utils.SendJSONResponse(w, string(js)) } +func (m *Manager) HandlePluginInfo(w http.ResponseWriter, r *http.Request) { + pluginID, err := utils.GetPara(r, "plugin_id") + if err != nil { + utils.SendErrorResponse(w, "plugin_id not found") + return + } + + plugin, err := m.GetPluginByID(pluginID) + if err != nil { + utils.SendErrorResponse(w, err.Error()) + return + } + + js, err := json.Marshal(plugin) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + utils.SendJSONResponse(w, string(js)) +} + func (m *Manager) HandleLoadPluginIcon(w http.ResponseWriter, r *http.Request) { pluginID, err := utils.GetPara(r, "plugin_id") if err != nil { diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 871d0eb..fa5c9ca 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -665,6 +665,9 @@ //Bind on tab switch events tabSwitchEventBind["httprp"] = function(){ listProxyEndpoints(); + + //Reset the tag filter + $("#tagFilterDropdown").dropdown('set selected', ""); } /* Tags & Search */ diff --git a/src/web/components/plugins.html b/src/web/components/plugins.html index e2b8d84..c2e463b 100644 --- a/src/web/components/plugins.html +++ b/src/web/components/plugins.html @@ -63,6 +63,42 @@ .selectedPluginItem.active .selectedIcon{ display: block; } + + .pluginAddRemoveButtons{ + border-left: 1px solid var(--divider_color); + border-right: 1px solid var(--divider_color); + display: flex !important; + align-items: center !important; + justify-content: center !important; + } + + .pluginAddRemoveButtons .mobileViewOnly{ + display: none; + } + + .selectColTitle{ + font-weight: bold; + margin-bottom: 0.4em; + text-align: center; + width: 100%; + } + + @media (max-width: 780px) { + .pluginAddRemoveButtons { + border-left: none; + border-right: none; + border-top: 1px solid var(--divider_color); + border-bottom: 1px solid var(--divider_color); + } + + .pluginAddRemoveButtons .mobileViewOnly{ + display: block; + } + + .pluginAddRemoveButtons .wideViewOnly{ + display: none; + } + }
@@ -77,25 +113,38 @@ Plugin Map
Assigning a plugin to a tag will make the plugin available to the HTTP Proxy rule with the same tag.
+
+
Unassigned Plugins
Select a tag to view available plugins
-
+
- -
- +
+ +
+ +
+
+ +
+ +
@@ -110,6 +159,7 @@
+
Assigned Plugins
Select a tag to view assigned plugins @@ -117,6 +167,7 @@
+

Plugin List @@ -280,7 +331,7 @@ function bindEventsToSelectableItems(){ //Bind events for the buttons function bindTagAssignButtonEvents(){ - $("#addSelectedPluginTotagBtn").on("click", function(){ + $(".addSelectedPluginTotagBtn").on("click", function(){ const selectedPlugin = $(".selectablePluginItem.active"); const selectedTag = $("#pluginTagList").dropdown("get value"); if (selectedPlugin.length == 0){ @@ -295,7 +346,7 @@ function bindTagAssignButtonEvents(){ addPluginToTag(pluginId, selectedTag); }); - $("#removeSelectedPluginFromTagBtn").on("click", function(){ + $(".removeSelectedPluginFromTagBtn").on("click", function(){ const selectedPlugin = $(".selectedPluginItem.active"); const selectedTag = $("#pluginTagList").dropdown("get value"); if (selectedPlugin.length == 0){ @@ -429,14 +480,15 @@ function initiatePluginList(){ ${plugin.Spec.url} ${plugin.Spec.type==0?"Router":"Utilities"} -
- - -
+ + + `; @@ -505,6 +557,12 @@ function stopPlugin(pluginId, btn=undefined){ }); } +/* Plugin information */ +function getPluginInfo(pluginId, btn){ + let payload = encodeURIComponent(JSON.stringify({plugin_id: pluginId})); + showSideWrapper("snippet/pluginInfo.html?t=" + Date.now() + "#" + payload); +} + diff --git a/src/web/snippet/pluginInfo.html b/src/web/snippet/pluginInfo.html new file mode 100644 index 0000000..692a06b --- /dev/null +++ b/src/web/snippet/pluginInfo.html @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + +
+
+
+
+ Plugin Information +
+
+
+ +
+
+
+ Plugin Image +
+
+ IntroSpect +

The plugin registered the following information about itself

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IntroSpectResponse
Name
Version
Author
Description
Category
URL
Contact
+
+ Runtime Values +

Zoraxy assigned the following settings for its runtime

+ + + + + + + + + + + + + + + + + + + + +
PropertiesConfiguration
Enabled
Assigned Port
Working Directory
+
+
+
+
+ + Developer Insights +
+
+

Plugin IntroSpect Path Registration

+

The following static capture paths are registered by this plugin and will be intercepting all traffics that request these paths.
+ If dynamic capture path is not empty, all traffic headers will be forwarded to plugin for processing and optionally intercept.

+ + + + + + + + + + + + + + + + + + + + + + + +
Registered Static Capture Paths
+ Paths (and subpaths) to be intercepted by this plugin
Static Capture Ingress
+ Static intercept request ingress path
Dynamic Capture Sniffing Path
+ Request header ingress for intercept precheck
Dynamic Capture Ingress
+ Dynamic intercept request ingress path
Registered UI Proxy Path
+ The relative path of the web UI
+
+
+
+
+ +
+
+ +
+


+ + + \ No newline at end of file