luci: optimise generation nftset cache
This commit is contained in:
parent
e3942c2ccc
commit
45cdab67aa
@ -705,7 +705,7 @@ add_firewall_rule() {
|
|||||||
gen_nftset $NFTSET_GFW ipv4_addr
|
gen_nftset $NFTSET_GFW ipv4_addr
|
||||||
gen_nftset $NFTSET_LANLIST ipv4_addr $(gen_lanlist)
|
gen_nftset $NFTSET_LANLIST ipv4_addr $(gen_lanlist)
|
||||||
if [ -f $RULES_PATH/chnroute.nft ] && [ -s $RULES_PATH/chnroute.nft ] && [ $(awk 'END{print NR}' $RULES_PATH/chnroute.nft) -ge 8 ]; then
|
if [ -f $RULES_PATH/chnroute.nft ] && [ -s $RULES_PATH/chnroute.nft ] && [ $(awk 'END{print NR}' $RULES_PATH/chnroute.nft) -ge 8 ]; then
|
||||||
echolog "使用缓存加载chnroute..."
|
#echolog "使用缓存加载chnroute..."
|
||||||
nft -f $RULES_PATH/chnroute.nft
|
nft -f $RULES_PATH/chnroute.nft
|
||||||
else
|
else
|
||||||
gen_nftset $NFTSET_CHN ipv4_addr $(cat $RULES_PATH/chnroute | tr -s '\n' | grep -v "^#")
|
gen_nftset $NFTSET_CHN ipv4_addr $(cat $RULES_PATH/chnroute | tr -s '\n' | grep -v "^#")
|
||||||
@ -719,7 +719,7 @@ add_firewall_rule() {
|
|||||||
gen_nftset $NFTSET_GFW6 ipv6_addr
|
gen_nftset $NFTSET_GFW6 ipv6_addr
|
||||||
gen_nftset $NFTSET_LANLIST6 ipv6_addr $(gen_lanlist_6)
|
gen_nftset $NFTSET_LANLIST6 ipv6_addr $(gen_lanlist_6)
|
||||||
if [ -f $RULES_PATH/chnroute6.nft ] && [ -s $RULES_PATH/chnroute6.nft ] && [ $(awk 'END{print NR}' $RULES_PATH/chnroute6.nft) -ge 8 ]; then
|
if [ -f $RULES_PATH/chnroute6.nft ] && [ -s $RULES_PATH/chnroute6.nft ] && [ $(awk 'END{print NR}' $RULES_PATH/chnroute6.nft) -ge 8 ]; then
|
||||||
echolog "使用缓存加载chnroute6..."
|
#echolog "使用缓存加载chnroute6..."
|
||||||
nft -f $RULES_PATH/chnroute6.nft
|
nft -f $RULES_PATH/chnroute6.nft
|
||||||
else
|
else
|
||||||
gen_nftset $NFTSET_CHN6 ipv6_addr $(cat $RULES_PATH/chnroute6 | tr -s '\n' | grep -v "^#")
|
gen_nftset $NFTSET_CHN6 ipv6_addr $(cat $RULES_PATH/chnroute6 | tr -s '\n' | grep -v "^#")
|
||||||
|
@ -67,10 +67,11 @@ end
|
|||||||
local function gen_cache(set_name, ip_type, input_file, output_file)
|
local function gen_cache(set_name, ip_type, input_file, output_file)
|
||||||
local tmp_dir = "/tmp/"
|
local tmp_dir = "/tmp/"
|
||||||
local tmp_file = output_file .. "_tmp"
|
local tmp_file = output_file .. "_tmp"
|
||||||
gen_nftset(set_name, ip_type, tmp_file, input_file)
|
local tmp_set_name = set_name .. "_tmp"
|
||||||
luci.sys.call("nft list set inet fw4 " ..set_name.. " > " ..output_file)
|
gen_nftset(tmp_set_name, ip_type, tmp_file, input_file)
|
||||||
luci.sys.call("nft flush set inet fw4 " ..set_name)
|
luci.sys.call("nft list set inet fw4 " ..tmp_set_name.. " | sed 's/" ..tmp_set_name.. "/" ..set_name.. "/g' | cat > " ..output_file)
|
||||||
luci.sys.call("nft delete set inet fw4 " ..set_name)
|
luci.sys.call("nft flush set inet fw4 " ..tmp_set_name)
|
||||||
|
luci.sys.call("nft delete set inet fw4 " ..tmp_set_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- curl
|
-- curl
|
||||||
|
Loading…
Reference in New Issue
Block a user