From b4a45a23e51f9878209766beb5d60dacd04372f8 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 19 May 2026 11:18:16 +0200 Subject: [PATCH] Add "disable_by_default" flag for plugins Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- docs/plugins.md | 7 ++++--- internal/plugins/manager.go | 4 ++++ plugins/ip_filter.lua | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index 5f53787..2b485d3 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -15,9 +15,10 @@ Every plugin must declare a `Plugin` table and implement the hooks it wants to u ```lua Plugin = { - name = "My Plugin", - description = "What this plugin does.", - priority = 0, -- higher = runs before other plugins (default: 0) + name = "My Plugin", + description = "What this plugin does.", + priority = 0, -- higher = runs before other plugins (default: 0) + disable_by_default = true, -- if true, plugin starts disabled on first load (default: false) -- Declare which hooks you use and whether they are synchronous (default: false). -- on_config and on_quit are always sync and do not need to be declared here. diff --git a/internal/plugins/manager.go b/internal/plugins/manager.go index 60e370c..a15db6e 100644 --- a/internal/plugins/manager.go +++ b/internal/plugins/manager.go @@ -117,6 +117,10 @@ func (m *Manager) loadPlugin(path string) (*Plugin, error) { p.Priority = int(n) } + if pluginTable.RawGetString("disable_by_default") == lua.LTrue { + p.Enabled = false + } + // Hooks configurable via the Plugin table (sync field). configurableHooks := map[string]bool{ "on_start": false, // async by default diff --git a/plugins/ip_filter.lua b/plugins/ip_filter.lua index ed634c9..d5569ec 100644 --- a/plugins/ip_filter.lua +++ b/plugins/ip_filter.lua @@ -10,6 +10,7 @@ Checks that the proxy's outbound IP is in an allowed list on startup. - if no IPs are configured, the check is skipped ]], on_start = { sync = false }, + disable_by_default = true, } local whitelist = {}