X-Git-Url: http://git.openwrt.org/?p=feed%2Frouting.git;a=blobdiff_plain;f=bird-openwrt%2Fbird4-openwrt%2Fsrc%2Fmodel%2Ffilters.lua;fp=bird-openwrt%2Fbird4-openwrt%2Fsrc%2Fmodel%2Ffilters.lua;h=0000000000000000000000000000000000000000;hp=6f352b218e800349b98c177cce013d6edfd86ad8;hb=ecbdeb0500cc92b514a7442a09b9e90973fa3554;hpb=453de2136e2f354b2d6c88270297f31d4de488ae diff --git a/bird-openwrt/bird4-openwrt/src/model/filters.lua b/bird-openwrt/bird4-openwrt/src/model/filters.lua deleted file mode 100644 index 6f352b2..0000000 --- a/bird-openwrt/bird4-openwrt/src/model/filters.lua +++ /dev/null @@ -1,77 +0,0 @@ ---[[ -Copyright (C) 2014-2017 - Eloi Carbo - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]]-- - -local fs = require "nixio.fs" -local filters_dir = "/etc/bird4/filters/" -local lock_file = "/etc/bird4/filter_lock" - -m = SimpleForm("bird4", "Bird4 Filters", "INFO: New files are created using Timestamps.
In order to make it easier to handle, use SSH to connect to your terminal and rename those files.
If your file is not correctly shown in the list, please, refresh your browser.") - -s = m:section(SimpleSection) -files = s:option(ListValue, "Files", "Filter Files:") -local new_filter = filters_dir .. os.date("filter-%Y%m%d-%H%M") - --- New File Entry -files:value(new_filter, "New File (".. new_filter .. ")") -files.default = new_filter - -local i, file_list = 0, { } -for filename in io.popen("find " .. filters_dir .. " -type f"):lines() do - i = i + 1 - files:value(filename, filename) -end - -ld = s:option(Button, "_load", "Load File") -ld.inputstyle = "reload" - -st_file = s:option(DummyValue, "_stfile", "Editing file:") -function st_file.cfgvalue(self, section) - if ld:formvalue(section) then - fs.writefile(lock_file, files:formvalue(section)) - return files:formvalue(section) - else - fs.writefile(lock_file, "") - return "" - end -end - -area = s:option(Value, "_filters") -area.template = "bird4/tvalue" -area.rows = 30 -function area.cfgvalue(self,section) - if ld:formvalue(section) then - local contents = fs.readfile(files:formvalue(section)) - if contents then - return contents - else - return "" - end - else - return "" - end -end - -function area.write(self, section) - local locked_file = fs.readfile(lock_file) - if locked_file and not ld:formvalue(section) then - local text = self:formvalue(section):gsub("\r\n?", "\n") - fs.writefile(locked_file, text) - fs.writefile(lock_file, "") - end -end - -return m