small-package/luci-app-godproxy/luasrc/model/cbi/koolproxy/black_list.lua

32 lines
736 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

o = Map("koolproxy")
t = o:section(TypedSection, "global")
t.anonymous = true
e = t:option(TextValue, "adblock_domain")
e.description = translate("加入的网址将走广告过滤端口。只针对黑名单模式。只能输入WEB地址google.com每个地址一行。")
e.rows = 28
e.wrap = "off"
local fs = require "nixio.fs"
local i = "/etc/adblocklist/adblock"
function e.cfgvalue()
return fs.readfile(i) or ""
end
function e.write(self, section, value)
if value then
value = value:gsub("\r\n", "\n")
else
value = ""
end
fs.writefile("/tmp/adblock", value)
if (luci.sys.call("cmp -s /tmp/adblock /etc/adblocklist/adblock") == 1) then
fs.writefile(i, value)
end
fs.remove("/tmp/adblock")
end
return o