diff options
author | Ted Trask <ttrask01@yahoo.com> | 2014-02-03 21:54:10 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2014-02-03 21:54:10 +0000 |
commit | 9cf7dbead8f602c77541889bef4bc8e629e76853 (patch) | |
tree | 6a74f790d48f3a31fb374506951e3b8c8a7d9d91 /shorewall-model.lua | |
parent | 7b1dcaf9cdf3d5c62167e9b6b86797edb64b7e95 (diff) | |
download | acf-shorewall-9cf7dbead8f602c77541889bef4bc8e629e76853.tar.bz2 acf-shorewall-9cf7dbead8f602c77541889bef4bc8e629e76853.tar.xz |
Remove dead code
Diffstat (limited to 'shorewall-model.lua')
-rw-r--r-- | shorewall-model.lua | 223 |
1 files changed, 0 insertions, 223 deletions
diff --git a/shorewall-model.lua b/shorewall-model.lua index 75fccb5..1817199 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -10,162 +10,6 @@ local configfile = "/etc/shorewall/shorewall.conf" local processname = "shorewall" local packagename = "shorewall-shell" local baseurl = "/etc/shorewall/" ---[[ -local config = {} - --- ################################################################################ --- LOCAL FUNCTIONS - -local function read_config(file) - local path = baseurl .. file - if not (fs.is_file(path)) then - return {} - end - local filecontent = fs.read_file_as_array(path) or {} - local output = {} - for k,v in pairs(filecontent) do - if not string.find ( v, "^[;#].*" ) and not (string.find (v, "^%s*$")) then - local details = {} - for v in string.gmatch(v, "%S+") do - table.insert(details, v) - end - table.insert(output, details) - end - end - return output -end - -local function addremove_config( addremove, file, value, orgvalue ) - filepath = baseurl .. file - local cmdoutput - - -- Check if we are about to change a valid filename - local isvalidfile - for k,v in pairs(mymodule.getfilelist()) do - isvalidfile = true - if (v.value == filepath) then - break - end - isvalidfile = false - end - if not (fs.is_file(filepath)) or not (isvalidfile) then - return false, cfe({ - name="model:addremove_config()", - errtxt="'" .. filepath .. "' is not a valid file!", - }) - end - - if not (type(value) == "table") then - return false, cfe({ - name="model:addremove_config()", - errtxt="Value should come as an array!", - }) - end - - local filecontentarray = fs.read_file_as_array(filepath) or {} - - if (addremove == "delete" ) then - local modifyrow - local orgrecordtable = {} - for word in string.gmatch(orgvalue, "%S+") do - table.insert(orgrecordtable, word) - end - for i=1, #filecontentarray do - local recordtable = {} - for word in string.gmatch(filecontentarray[i], "%S+") do - table.insert(recordtable, word) - end - - if (table.concat(recordtable) == table.concat(orgrecordtable)) then - modifyrow = i - end - end - - if (tonumber(modifyrow)) then - table.remove(filecontentarray, modifyrow) - fs.write_file(filepath, table.concat(filecontentarray, "\n")) - return true, cfe({ - name="model:addremove_config()", - descr="* Record was successfully deleted!", - }) - else - return false, cfe({ - name="model:addremove_config()", - errtxt="Record was not deleted!", - }) - end - - elseif (addremove == "add" ) then - --Check if such record already exists - for k,v in pairs(filecontentarray) do - if not string.find ( v, "^[;#].*" ) then - local recordtable = {} - for word in string.gmatch(v, "%S+") do - table.insert(recordtable, word) - end - if (table.concat(recordtable) == table.concat(value)) then - return false, cfe({ - name="model:addremove_config()", - errtxt="The config already holds this kind of config!", - }) - end - end - end - - table.insert(filecontentarray, (#filecontentarray), table.concat(value, "\t")) - fs.write_file(filepath, table.concat(filecontentarray, "\n")) - return true, cfe({ - name="model:addremove_config()", - descr="* Record was successfully added!", - }) - - elseif (addremove == "modify" ) then - local modifyrow - local orgrecordtable = {} - for word in string.gmatch(orgvalue, "%S+") do - table.insert(orgrecordtable, word) - end - for i=1, #filecontentarray do - local recordtable = {} - for word in string.gmatch(filecontentarray[i], "%S+") do - table.insert(recordtable, word) - end - - if (table.concat(recordtable) == table.concat(orgrecordtable)) then - modifyrow = i - end - end - - if (tonumber(modifyrow)) then - table.remove(filecontentarray, modifyrow) - table.insert(filecontentarray, modifyrow, table.concat(value, "\t")) - fs.write_file(filepath, table.concat(filecontentarray, "\n")) - return true, cfe({ - name="model:addremove_config()", - descr="* Record was successfully modified!", - }) - else - return false, cfe({ - name="model:addremove_config()", - errtxt="Record was not modified!", - }) - end - - else - return false, cfe({ - name="model:addremove_config()", - errtxt="Wrong usage of this function! Available options are [add|delete|modify]. You chose '" .. addremove .. "'", - }) - end - - return false, cfe({ - name="model:addremove_config()", - errtxt="Something went wrong!", - debug=value, - }) -end ---]] - -- ################################################################################ -- PUBLIC FUNCTIONS @@ -227,71 +71,4 @@ function mymodule.updatefiledetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, is_valid_filename) end ---[[ -function mymodule.modify_config(self, addremove, file, value, orgvalue ) - return addremove_config(addremove, file, value, orgvalue ) -end - -function mymodule.getconfig() - local config = {} - - config.params = cfe({ - name = "params", - label="List of parameters", - type="select", - option={}, - }) - for k,v in pairs(read_config("params")) do - table.insert(config.params.option, v[1]) - end - config.params.size=#config.params.option + 1 - - config.interfaces = cfe({ - name = "interfaces", - label="List of interfaces", - type="select", - option=read_config("interfaces"), - }) - - config.zones = cfe({ - name = "zones", - label="List of zones", - type="select", - option=read_config("zones"), - }) - - config.policy = cfe({ - name = "policy", - label="List of policy", - type="select", - option=read_config("policy"), - }) - - config.rules = cfe({ - name = "rules", - label="List of rules", - type="select", - option=read_config("rules"), - }) - - config.masq = cfe({ - name = "masq", - label="List of rules", - type="select", - option=read_config("masq"), - }) - - return config - -end - -function mymodule.get_defined_zones () - local output = {} - for k,v in pairs(read_config("zones")) do - table.insert(output, string.match(v, "^%s*(%S*)")) - end - return output -end ---]] - return mymodule |