mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-14 14:40:58 +00:00
Fixed parsers
This commit is contained in:
@@ -55,6 +55,12 @@ local Config = Class(nil, {
|
|||||||
["BLLIST_STRIP_WWW"] = true,
|
["BLLIST_STRIP_WWW"] = true,
|
||||||
["NFT_TABLE"] = true,
|
["NFT_TABLE"] = true,
|
||||||
["NFT_TABLE_DNSMASQ"] = true,
|
["NFT_TABLE_DNSMASQ"] = true,
|
||||||
|
["NFTSET_CIDR"] = true,
|
||||||
|
["NFTSET_IP"] = true,
|
||||||
|
["NFTSET_DNSMASQ"] = true,
|
||||||
|
["NFTSET_CIDR_USER"] = true,
|
||||||
|
["NFTSET_IP_USER"] = true,
|
||||||
|
["NFTSET_DNSMASQ_USER"] = true,
|
||||||
["NFTSET_CIDR_CFG"] = true,
|
["NFTSET_CIDR_CFG"] = true,
|
||||||
["NFTSET_IP_CFG"] = true,
|
["NFTSET_IP_CFG"] = true,
|
||||||
["NFTSET_DNSMASQ"] = true,
|
["NFTSET_DNSMASQ"] = true,
|
||||||
@@ -389,6 +395,9 @@ end
|
|||||||
|
|
||||||
function BlackListParser:write_ipset_config()
|
function BlackListParser:write_ipset_config()
|
||||||
local file_handler = assert(io.open(self.IP_DATA_FILE, "w"), "Could not open nftset config")
|
local file_handler = assert(io.open(self.IP_DATA_FILE, "w"), "Could not open nftset config")
|
||||||
|
for _, v in ipairs({ self.NFTSET_CIDR, self.NFTSET_IP, self.NFTSET_CIDR_USER, self.NFTSET_IP_USER }) do
|
||||||
|
file_handler:write(string.format("flush set %s %s\n", self.NFT_TABLE, v))
|
||||||
|
end
|
||||||
file_handler:write(
|
file_handler:write(
|
||||||
string.format("table %s {\n%s", self.NFT_TABLE, self.NFTSET_IP_CFG)
|
string.format("table %s {\n%s", self.NFT_TABLE, self.NFTSET_IP_CFG)
|
||||||
)
|
)
|
||||||
@@ -609,7 +618,6 @@ local Ra = Class(BlackListParser, {
|
|||||||
function Ra:download_config(url, file)
|
function Ra:download_config(url, file)
|
||||||
local ret_val = false
|
local ret_val = false
|
||||||
self.current_file_handler = assert(io.open(file, "w"), "Could not open file")
|
self.current_file_handler = assert(io.open(file, "w"), "Could not open file")
|
||||||
--self.current_file_handler:setvbuf("no")
|
|
||||||
if self:get_http_data(url) then
|
if self:get_http_data(url) then
|
||||||
ret_val = true
|
ret_val = true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ class Config:
|
|||||||
"BLLIST_STRIP_WWW",
|
"BLLIST_STRIP_WWW",
|
||||||
"NFT_TABLE",
|
"NFT_TABLE",
|
||||||
"NFT_TABLE_DNSMASQ",
|
"NFT_TABLE_DNSMASQ",
|
||||||
|
"NFTSET_CIDR",
|
||||||
|
"NFTSET_IP",
|
||||||
|
"NFTSET_DNSMASQ",
|
||||||
|
"NFTSET_CIDR_USER",
|
||||||
|
"NFTSET_IP_USER",
|
||||||
|
"NFTSET_DNSMASQ_USER",
|
||||||
"NFTSET_CIDR_CFG",
|
"NFTSET_CIDR_CFG",
|
||||||
"NFTSET_IP_CFG",
|
"NFTSET_IP_CFG",
|
||||||
"NFTSET_DNSMASQ",
|
"NFTSET_DNSMASQ",
|
||||||
@@ -497,6 +503,9 @@ class WriteConfigFiles(Config):
|
|||||||
|
|
||||||
def write_ipset_config(self, ip_set, cidr_set):
|
def write_ipset_config(self, ip_set, cidr_set):
|
||||||
with open(self.IP_DATA_FILE, "wt", buffering=self.write_buffer) as file_handler:
|
with open(self.IP_DATA_FILE, "wt", buffering=self.write_buffer) as file_handler:
|
||||||
|
for i in (self.NFTSET_CIDR, self.NFTSET_IP,
|
||||||
|
self.NFTSET_CIDR_USER, self.NFTSET_IP_USER):
|
||||||
|
file_handler.write("flush set {} {}\n".format(self.NFT_TABLE, i))
|
||||||
file_handler.write(
|
file_handler.write(
|
||||||
"table {} {{\n{}".format(self.NFT_TABLE, self.NFTSET_IP_CFG)
|
"table {} {{\n{}".format(self.NFT_TABLE, self.NFTSET_IP_CFG)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user