Make sure that only one toggle can be enabled simultaneously (1 or 2)
But there is one more way - Lua. And it looks more correct than first one:
-- Define toggles
local log_toggle = nil
local wipe_toggle = nil
-- Function to initialize toggles
function init_toggles()
-- Log toggle
log_toggle = SimpleForm("log_toggle")
log_toggle.title = "Log Toggle"
log_toggle.reset = false
log_toggle:append(TextValue("status", ""))
log_toggle:append(Checkbox("enabled", "Enable Logging"))
-- Wipe toggle
wipe_toggle = SimpleForm("wipe_toggle")
wipe_toggle.title = "Wipe Toggle"
wipe_toggle.reset = false
wipe_toggle:append(TextValue("status", ""))
wipe_toggle:append(Checkbox("enabled", "Enable Wiping"))
end
-- Function to handle toggle changes
function toggle_change(section)
if section == log_toggle then
-- Disable wiping if logs enabled
if log_toggle.enabled.value then
wipe_toggle.enabled.disabled = true
else
wipe_toggle.enabled.disabled = false
end
-- Update services based on log toggle
if log_toggle.enabled.value then
luci.sys.call("/etc/init.d/gl_clients enable")
luci.sys.call("/etc/init.d/gl_clients start")
else
luci.sys.call("/etc/init.d/gl_clients disable")
luci.sys.call("/etc/init.d/gl_clients stop")
end
elseif section == wipe_toggle then
-- Disable logs if wiping enabled
if wipe_toggle.enabled.value then
log_toggle.enabled.disabled = true
else
log_toggle.enabled.disabled = false
end
-- Update services based on wipe toggle
if wipe_toggle.enabled.value then
-- Add code to enable wiping
else
-- Add code to disable wiping
end
end
end
-- Initialize toggles
init_toggles()
-- Add toggles to page
entry({"admin", "services", "bluemerle"}, cbi("Blue Merle"), _("Blue Merle")).dependent = false
entry({"admin", "services", "bluemerle"}, firstchild()).dependent = false
entry({"admin", "services", "bluemerle"}, log_toggle, _("Log Toggle")).dependent = false
entry({"admin", "services", "bluemerle"}, wipe_toggle, _("Wipe Toggle")).dependent = false
-- Handle toggle changes
log_toggle.apply = function() toggle_change(log_toggle) end
wipe_toggle.apply = function() toggle_change(wipe_toggle) end
———
Additional features:
———
This will (if toggle enabled):
This will generate router passwords like:
Original Password: MyPass123
May 1st Password: MyPass123-01
May 2nd Password: MyPass123-02
Block all ports except following:
Port 80 - HTTP (web browsing)
Port 443 - HTTPS (secure web browsing)
Port 53 - DNS (domain name resolution)
Port 123 - NTP (network time synchronization)
I created code draft to implement the MAC logging and MAC address wiping toggles in Blue Merle:
This will:
To stop writing logs at all you need to:
But there is one more way - Lua. And it looks more correct than first one:
——— Additional features: ——— This will (if toggle enabled):
Luci GUI (firewall.xml)
uci.lua
password.cron
firewall.lua