-- -- (C) 2013-24 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path local template = require "template_utils" local system_setup_ui_utils = require "system_setup_ui_utils" require "lua_utils" require "prefs_utils" prefsSkipRedis(true) if not (ntop.isnEdge() or ntop.isAppliance()) or not isAdministrator() then return end local sys_config if ntop.isnEdge() then package.path = dirs.installdir .. "/pro/scripts/lua/nedge/modules/system_config/?.lua;" .. package.path sys_config = require("nf_config"):create(true) else -- ntop.isAppliance() package.path = dirs.installdir .. "/scripts/lua/modules/system_config/?.lua;" .. package.path sys_config = require("appliance_config"):create(true) end system_setup_ui_utils.process_apply_discard_config(sys_config) local mode = sys_config:getOperatingMode() if (_POST["rescan_interfaces"] ~= nil) then sys_config:rescanInterfaces() elseif (_POST["lan_interfaces"] ~= nil) and (_POST["wan_interfaces"] ~= nil) then sys_config:setLanWanIfaces(split(_POST["lan_interfaces"], ","), split(_POST["wan_interfaces"], ",")) if (mode == "routing") then -- Ensure we are on static mode on the lan inteface local lan_ifaces = sys_config:getLanInterfaces() for _, lan_iface in ipairs(lan_ifaces) do sys_config:setInterfaceMode(lan_iface, "static") end -- Add to the list of gateways if not already present local wan_ifaces = sys_config:getWanInterfaces() for _, wan_iface in ipairs(wan_ifaces) do sys_config:addGateway(wan_iface, wan_iface) end end sys_config:save() end local function valuesToKeys(t) local res = {} for k, v in pairs(t or {}) do res[v] = 1 end return res end local function printIfSelected(iface, interfaces_set) print([[]]) end local print_page_body -- Interaface limits configuration local min_lan_ifaces = "1" local min_wan_ifaces = "1" local max_lan_ifaces = "1" local max_wan_ifaces = "" if mode == "routing" then -- testing max_lan_ifaces = "" elseif mode == "bridging" then -- temporary limits - we need to support multiple LAN interfaces in C code max_wan_ifaces = "1" elseif mode == "passive" then min_wan_ifaces = "" end local lan_label local wan_label if mode == "passive" then lan_label = i18n("appliance.management") wan_label = i18n("appliance.capture_interfaces") else lan_label = i18n("nedge.lan") wan_label = i18n("nedge.wan") end print_page_body = function() printPageSection(i18n("prefs.network_interfaces")) local ifaces = sys_config:getAllInterfaces() print[[
]] print('') print('') print('') print('') end system_setup_ui_utils.print_setup_page(print_page_body, sys_config) print( template.gen("modal_confirm_dialog.html", { dialog={ id = "RescanInterfacesDialog", action = "$('#RescanInterfacesForm').submit()", title = i18n("nedge.rescan_interfaces"), message = i18n("nedge.rescan_interfaces_msg"), confirm = i18n("nedge.rescan_and_restart_self"), confirm_button = "btn-danger", } }) ) print[[
]]