浏览代码

Optimizing update scripts and adjusting storage locations

Mattraks 5 年之前
父节点
当前提交
883e94d35f

+ 32 - 87
luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua

@@ -74,105 +74,50 @@ function refresh_data()
 	local set = luci.http.formvalue("set")
 	local uci = luci.model.uci.cursor()
 	local icount = 0
-	if set == "gfw_data" then
-		refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'gfwlist_url', 'https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt') .. ' > /tmp/gfw.b64'
+	local retstring = 0
+	local function update(url, file, type, file2)
+		local Num = 1
+		refresh_cmd = "wget-ssl --no-check-certificate -t 3 -T 10 -O- " .. url .. " > /tmp/ssr-update." .. type
 		sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
 		if sret == 0 then
-			luci.sys.call("/usr/bin/ssr-gfw")
-			icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l")
-			if tonumber(icount) > 1000 then
-				if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
-					oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
-				else
-					oldcount = "0"
-				end
-				if tonumber(icount) ~= tonumber(oldcount) then
-					luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf")
-					luci.sys.exec("cp -f /tmp/gfwnew.txt /tmp/dnsmasq.ssr/gfw_list.conf")
-					luci.sys.call("/etc/init.d/dnsmasq restart")
-					retstring = tostring(tonumber(icount)/2)
-				else
-					retstring = "0"
-				end
-			else
-				retstring = "-1"
+			if type == "gfw_data" then
+				luci.sys.call("/usr/bin/ssr-gfw " .. type)
+				Num = 2
 			end
-			luci.sys.exec("rm -f /tmp/gfwnew.txt")
-		else
-			retstring = "-1"
-		end
-	end
-	if set == "ip_data" then
-		refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'chnroute_url', 'https://ispip.clang.cn/all_cn.txt') .. " > /tmp/china_ssr.txt"
-		sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-		icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
-		if sret == 0 and tonumber(icount) > 1000 then
-			if nixio.fs.access("/etc/china_ssr.txt") then
-				oldcount = luci.sys.exec("cat /etc/china_ssr.txt | wc -l")
-			else
-				oldcount = "0"
+			if type == "ad_data" then
+				luci.sys.call("/usr/bin/ssr-ad " .. type)
 			end
-			if tonumber(icount) ~= tonumber(oldcount) then
-				luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
-				luci.sys.exec("/etc/init.d/shadowsocksr restart &")
-				retstring = tostring(tonumber(icount))
-			else
+			local new_md5 = luci.sys.exec("echo -n $([ -f '/tmp/ssr-update." .. type .. "' ] && md5sum /tmp/ssr-update." .. type .. " | awk '{print $1}')")
+			local old_md5 = luci.sys.exec("echo -n $([ -f '" .. file .. "' ] && md5sum " .. file .. " | awk '{print $1}')")
+			if new_md5 == old_md5 then
 				retstring = "0"
-			end
-		else
-			retstring = "-1"
-		end
-		luci.sys.exec("rm -f /tmp/china_ssr.txt")
-	end
-	if set == "nfip_data" then
-		refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'nfip_url','https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt') .." > /tmp/netflixip.list"
-		sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-		icount = luci.sys.exec("cat /tmp/netflixip.list | wc -l")
-		if sret == 0 and tonumber(icount) > 5 then
-			if nixio.fs.access("/etc/config/netflixip.list") then
-				oldcount = luci.sys.exec("cat /etc/config/netflixip.list | wc -l")
 			else
-				oldcount = "0"
-			end
-			if tonumber(icount) ~= tonumber(oldcount) then
-				luci.sys.exec("cp -f /tmp/netflixip.list /etc/config/netflixip.list")
-				luci.sys.exec("/etc/init.d/shadowsocksr restart &")
-				retstring = tostring(tonumber(icount))
-			else
-				retstring = "0"
-			end
-		else
-			retstring = "-1"
-		end
-		luci.sys.exec("rm -f /tmp/netflixip.list")
-	end
-	if set == "ad_data" then
-		refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'adblock_url','https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt') .." > /tmp/adnew.conf"
-		sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-		if sret == 0 then
-			luci.sys.call("/usr/bin/ssr-ad")
-			icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
-			if tonumber(icount) > 100 then
-				if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
-					oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")
+				icount = luci.sys.exec("cat /tmp/ssr-update." .. type .. " | wc -l")
+				luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file)
+				if file2 then luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file2) end
+				retstring = tostring(tonumber(icount)/Num)
+				if type == "gfw_data" or type == "ad_data" then
+					luci.sys.exec("/usr/share/shadowsocksr/gfw2ipset.sh gfw_data")
 				else
-					oldcount = "0"
+					luci.sys.exec("/etc/init.d/shadowsocksr restart &")
 				end
-				if tonumber(icount) ~= tonumber(oldcount) then
-					luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf")
-					luci.sys.exec("cp -f /tmp/ad.conf /tmp/dnsmasq.ssr/ad.conf")
-					luci.sys.call("/etc/init.d/dnsmasq restart")
-					retstring = tostring(tonumber(icount))
-				else
-					retstring = "0"
-				end
-			else
-				retstring = "-1"
 			end
-			luci.sys.exec("rm -f /tmp/ad.conf")
 		else
 			retstring = "-1"
 		end
+		luci.sys.exec("rm -f /tmp/ssr-update." .. type)
+	end
+	if set == "gfw_data" then
+		update(uci:get_first("shadowsocksr", "global", "gfwlist_url", "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"), "/etc/ssr/gfw_list.conf", set, "/tmp/dnsmasq.ssr/gfw_list.conf")
+	end
+	if set == "ip_data" then
+		update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", set)
+	end
+	if set == "ad_data" then
+		update(uci:get_first("shadowsocksr", "global", "adblock_url","https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"), "/etc/ssr/ad.conf", set, "/tmp/dnsmasq.ssr/ad.conf")
+	end
+	if set == "nfip_data" then
+		update(uci:get_first("shadowsocksr", "global", "nfip_url","https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt"), "/etc/ssr/netflixip.list", set)
 	end
 	luci.http.prepare_content("application/json")
 	luci.http.write_json({ret = retstring,retcount = icount})

+ 34 - 39
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua

@@ -1,5 +1,6 @@
+require "luci.ip"
+require "nixio.fs"
 local m, s, o
-local NXFS = require "nixio.fs"
 
 m = Map("shadowsocksr", translate("IP black-and-white list"))
 
@@ -27,9 +28,9 @@ o.rmempty = false
 o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Host List"))
 o.datatype = "ipaddr"
 luci.ip.neighbors({ family = 4 }, function(entry)
-		if entry.reachable then
-			o:value(entry.dest:string())
-		end
+	if entry.reachable then
+		o:value(entry.dest:string())
+	end
 end)
 o:depends("lan_ac_mode", "w")
 o:depends("lan_ac_mode", "b")
@@ -37,25 +38,25 @@ o:depends("lan_ac_mode", "b")
 o = s:taboption("lan_ac", DynamicList, "lan_bp_ips", translate("LAN Bypassed Host List"))
 o.datatype = "ipaddr"
 luci.ip.neighbors({ family = 4 }, function(entry)
-		if entry.reachable then
-			o:value(entry.dest:string())
-		end
+	if entry.reachable then
+		o:value(entry.dest:string())
+	end
 end)
 
 o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List"))
 o.datatype = "ipaddr"
 luci.ip.neighbors({ family = 4 }, function(entry)
-		if entry.reachable then
-			o:value(entry.dest:string())
-		end
+	if entry.reachable then
+		o:value(entry.dest:string())
+	end
 end)
 
 o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List"))
 o.datatype = "ipaddr"
 luci.ip.neighbors({ family = 4 }, function(entry)
-		if entry.reachable then
-			o:value(entry.dest:string())
-		end
+	if entry.reachable then
+		o:value(entry.dest:string())
+	end
 end)
 
 -- Part of Self
@@ -66,73 +67,67 @@ end)
 -- o:value("2", translatef("Forwarded Proxy"))
 -- o.rmempty = false
 
-s:tab("esc",  translate("Bypass Domain List"))
-
-local escconf = "/etc/config/white.list"
+s:tab("esc", translate("Bypass Domain List"))
+local escconf = "/etc/ssr/white.list"
 o = s:taboption("esc", TextValue, "escconf")
 o.rows = 13
 o.wrap = "off"
 o.rmempty = true
 o.cfgvalue = function(self, section)
-	return NXFS.readfile(escconf) or ""
+	return nixio.fs.readfile(escconf) or ""
 end
 o.write = function(self, section, value)
-	NXFS.writefile(escconf, value:gsub("\r\n", "\n"))
+	nixio.fs.writefile(escconf, value:gsub("\r\n", "\n"))
 end
 o.remove = function(self, section, value)
-	NXFS.writefile(escconf, "")
+	nixio.fs.writefile(escconf, "")
 end
 
-
-s:tab("block",  translate("Black Domain List"))
-
-local blockconf = "/etc/config/black.list"
+s:tab("block", translate("Black Domain List"))
+local blockconf = "/etc/ssr/black.list"
 o = s:taboption("block", TextValue, "blockconf")
 o.rows = 13
 o.wrap = "off"
 o.rmempty = true
 o.cfgvalue = function(self, section)
-	return NXFS.readfile(blockconf) or " "
+	return nixio.fs.readfile(blockconf) or " "
 end
 o.write = function(self, section, value)
-	NXFS.writefile(blockconf, value:gsub("\r\n", "\n"))
+	nixio.fs.writefile(blockconf, value:gsub("\r\n", "\n"))
 end
 o.remove = function(self, section, value)
-	NXFS.writefile(blockconf, "")
+	nixio.fs.writefile(blockconf, "")
 end
-
-s:tab("netflix",  translate("Netflix Domain List"))
-
-local netflixconf = "/etc/config/netflix.list"
+s:tab("netflix", translate("Netflix Domain List"))
+local netflixconf = "/etc/ssr/netflix.list"
 o = s:taboption("netflix", TextValue, "netflixconf")
 o.rows = 13
 o.wrap = "off"
 o.rmempty = true
 o.cfgvalue = function(self, section)
-	return NXFS.readfile(netflixconf) or " "
+	return nixio.fs.readfile(netflixconf) or " "
 end
 o.write = function(self, section, value)
-	NXFS.writefile(netflixconf, value:gsub("\r\n", "\n"))
+	nixio.fs.writefile(netflixconf, value:gsub("\r\n", "\n"))
 end
 o.remove = function(self, section, value)
-	NXFS.writefile(netflixconf, "")
+	nixio.fs.writefile(netflixconf, "")
 end
 
-s:tab("netflixip",  translate("Netflix IP List"))
-
-local netflixipconf = "/etc/config/netflixip.list"
+s:tab("netflixip", translate("Netflix IP List"))
+local netflixipconf = "/etc/ssr/netflixip.list"
 o = s:taboption("netflixip", TextValue, "netflixipconf")
 o.rows = 13
 o.wrap = "off"
 o.rmempty = true
 o.cfgvalue = function(self, section)
-	return NXFS.readfile(netflixipconf) or " "
+	return nixio.fs.readfile(netflixipconf) or " "
 end
 o.write = function(self, section, value)
-	NXFS.writefile(netflixipconf, value:gsub("\r\n", "\n"))
+	nixio.fs.writefile(netflixipconf, value:gsub("\r\n", "\n"))
 end
 o.remove = function(self, section, value)
-	NXFS.writefile(netflixipconf, "")
+	nixio.fs.writefile(netflixipconf, "")
 end
 
 return m

+ 63 - 66
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua

@@ -1,6 +1,8 @@
 -- Copyright (C) 2017 yushi studio <[email protected]>
 -- Licensed to the public under the GNU General Public License v3.
-
+require "nixio.fs"
+require "luci.sys"
+require "luci.model.uci"
 local m, s, o
 local redir_run=0
 local reudp_run=0
@@ -19,72 +21,67 @@ font_blue = [[<font color="green">]]
 font_off = [[</font>]]
 bold_on = [[<strong>]]
 bold_off = [[</strong>]]
-
-local fs = require "nixio.fs"
-local sys = require "luci.sys"
 local kcptun_version=translate("Unknown")
 local kcp_file="/usr/bin/kcptun-client"
-if not fs.access(kcp_file) then
-kcptun_version=translate("Not exist")
+if not nixio.fs.access(kcp_file) then
+	kcptun_version=translate("Not exist")
 else
-if not fs.access(kcp_file, "rwx", "rx", "rx") then
-fs.chmod(kcp_file, 755)
-end
-kcptun_version=sys.exec(kcp_file .. " -v | awk '{printf $3}'")
-if not kcptun_version or kcptun_version == "" then
-kcptun_version = translate("Unknown")
-end
-
+	if not nixio.fs.access(kcp_file, "rwx", "rx", "rx") then
+		nixio.fs.chmod(kcp_file, 755)
+	end
+	kcptun_version=luci.sys.exec(kcp_file .. " -v | awk '{printf $3}'")
+	if not kcptun_version or kcptun_version == "" then
+		kcptun_version = translate("Unknown")
+	end
 end
 
-if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
-gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2
+if nixio.fs.access("/etc/ssr/gfw_list.conf") then
+	gfw_count = tonumber(luci.sys.exec("cat /etc/ssr/gfw_list.conf | wc -l"))/2
 end
 
-if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
-ad_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l"))
+if nixio.fs.access("/etc/ssr/ad.conf") then
+	ad_count = tonumber(luci.sys.exec("cat /etc/ssr/ad.conf | wc -l"))
 end
 
-if nixio.fs.access("/etc/china_ssr.txt") then
-ip_count = tonumber(sys.exec("cat /etc/china_ssr.txt | wc -l"))
+if nixio.fs.access("/etc/ssr/china_ssr.txt") then
+	ip_count = tonumber(luci.sys.exec("cat /etc/ssr/china_ssr.txt | wc -l"))
 end
 
-if nixio.fs.access("/etc/config/netflixip.list") then
-nfip_count = tonumber(sys.exec("cat /etc/config/netflixip.list | wc -l"))
+if nixio.fs.access("/etc/ssr/netflixip.list") then
+	nfip_count = tonumber(luci.sys.exec("cat /etc/ssr/netflixip.list | wc -l"))
 end
 
-local icount=sys.exec("busybox ps -w | grep ssr-reudp |grep -v grep| wc -l")
+local icount=luci.sys.exec("busybox ps -w | grep ssr-reudp |grep -v grep| wc -l")
 if tonumber(icount)>0 then
-reudp_run=1
+	reudp_run=1
 else
-icount=sys.exec("busybox ps -w | grep ssr-retcp |grep \"\\-u\"|grep -v grep| wc -l")
-if tonumber(icount)>0 then
-reudp_run=1
-end
+	icount=luci.sys.exec("busybox ps -w | grep ssr-retcp |grep \"\\-u\"|grep -v grep| wc -l")
+	if tonumber(icount)>0 then
+		reudp_run=1
+	end
 end
 
 if luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") == 0 then
-redir_run=1
+	redir_run=1
 end
 
 if luci.sys.call("busybox ps -w | grep ssr-local | grep -v ssr-socksdns |grep -v grep >/dev/null") == 0 then
-sock5_run=1
+	sock5_run=1
 end
 
 if luci.sys.call("pidof kcptun-client >/dev/null") == 0 then
-kcptun_run=1
+	kcptun_run=1
 end
 
 if luci.sys.call("busybox ps -w | grep ssr-server | grep -v grep >/dev/null") == 0 then
-server_run=1
-end
-
-if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") == 0 then
-tunnel_run=1
+	server_run=1
 end
 
+-- if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") == 0 then
+-- tunnel_run=1
+-- end
 if luci.sys.call("pidof pdnsd >/dev/null") == 0 or (luci.sys.call("busybox ps -w | grep ssr-dns |grep -v grep >/dev/null") == 0 and luci.sys.call("pidof dns2socks >/dev/null") == 0)then
-pdnsd_run=1
+	pdnsd_run=1
 end
 
 m = SimpleForm("Version")
@@ -94,56 +91,56 @@ m.submit = false
 s=m:field(DummyValue,"redir_run",translate("Global Client"))
 s.rawhtml = true
 if redir_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
 else
-s.value = translate("Not Running")
+	s.value = translate("Not Running")
 end
 
 s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay"))
 s.rawhtml = true
 if reudp_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
 else
-s.value = translate("Not Running")
+	s.value = translate("Not Running")
 end
 
 if uci:get_first(shadowsocksr, 'global', 'pdnsd_enable', '0') ~= '0' then
-s=m:field(DummyValue,"pdnsd_run",translate("DNS Anti-pollution"))
-s.rawhtml = true
-if pdnsd_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
-else
-s.value = translate("Not Running")
-end
+	s=m:field(DummyValue,"pdnsd_run",translate("DNS Anti-pollution"))
+	s.rawhtml = true
+	if pdnsd_run == 1 then
+		s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	else
+		s.value = translate("Not Running")
+	end
 end
 
 s=m:field(DummyValue,"sock5_run",translate("Global SOCKS5 Proxy Server"))
 s.rawhtml = true
 if sock5_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
 else
-s.value = translate("Not Running")
+	s.value = translate("Not Running")
 end
 
 s=m:field(DummyValue,"server_run",translate("Local Servers"))
 s.rawhtml = true
 if server_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
 else
-s.value = translate("Not Running")
+	s.value = translate("Not Running")
 end
 
 if nixio.fs.access("/usr/bin/kcptun-client") then
-s=m:field(DummyValue,"kcp_version",translate("KcpTun Version"))
-s.rawhtml = true
-s.value =kcptun_version
-s=m:field(DummyValue,"kcptun_run",translate("KcpTun"))
-s.rawhtml = true
-if kcptun_run == 1 then
-s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
-else
-s.value = translate("Not Running")
-end
+	s=m:field(DummyValue,"kcp_version",translate("KcpTun Version"))
+	s.rawhtml = true
+	s.value =kcptun_version
+	s=m:field(DummyValue,"kcptun_run",translate("KcpTun"))
+	s.rawhtml = true
+	if kcptun_run == 1 then
+		s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
+	else
+		s.value = translate("Not Running")
+	end
 end
 
 s=m:field(DummyValue,"google",translate("Google Connectivity"))
@@ -170,10 +167,10 @@ s.template = "shadowsocksr/refresh"
 s.value = nfip_count .. " " .. translate("Records")
 
 if uci:get_first(shadowsocksr, 'global', 'adblock', '0') == '1' then
-s=m:field(DummyValue,"ad_data",translate("Advertising Data"))
-s.rawhtml = true
-s.template = "shadowsocksr/refresh"
-s.value = ad_count .. " " .. translate("Records")
+	s=m:field(DummyValue,"ad_data",translate("Advertising Data"))
+	s.rawhtml = true
+	s.template = "shadowsocksr/refresh"
+	s.value = ad_count .. " " .. translate("Records")
 end
 
 s=m:field(DummyValue,"check_port",translate("Check Server Port"))

+ 1 - 1
luci-app-ssr-plus/root/etc/config/shadowsocksr

@@ -24,7 +24,7 @@ config socks5_proxy
 	option local_address '0.0.0.0'
 
 config access_control
-	option wan_bp_list '/etc/china_ssr.txt'
+	option wan_bp_list '/etc/ssr/china_ssr.txt'
 	option lan_ac_mode 'b'
 	option router_proxy '1'
 	list wan_fw_ips '149.154.160.0/20'

+ 18 - 18
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -635,19 +635,19 @@ start() {
 
 	if rules; then
 		start_redir
-		mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/
-		if ! [ "$run_mode" == "oversea" ]; then
+			mkdir -p /tmp/dnsmasq.d /tmp/dnsmasq.ssr
 			cat <<-EOF >/tmp/dnsmasq.d/dnsmasq-ssr.conf
 				conf-dir=/tmp/dnsmasq.ssr
 			EOF
-		else
-			cat <<-EOF >/tmp/dnsmasq.d/dnsmasq-ssr.conf
-				conf-dir=/tmp/dnsmasq.oversea
-			EOF
-		fi
-		if [ $(uci_get_by_type global adblock 0) == "0" ]; then
-			rm -f /tmp/dnsmasq.ssr/ad.conf
-		fi
+			if [ "$run_mode" == "oversea" ]; then
+				cp -rf /etc/ssr/oversea_list.conf /tmp/dnsmasq.ssr/
+			else
+				cp -rf /etc/ssr/gfw_list.conf /tmp/dnsmasq.ssr/
+				cp -rf /etc/ssr/gfw_base.conf /tmp/dnsmasq.ssr/
+			fi
+			if [ "$(uci_get_by_type global adblock 0)" == "1" ]; then
+				cp -rf /etc/ssr/ad.conf /tmp/dnsmasq.ssr/
+			fi
 		/usr/share/shadowsocksr/gfw2ipset.sh
 
 		if [ "$NETFLIX_SERVER" != "nil" ]; then
@@ -655,21 +655,21 @@ start() {
 				cat /etc/config/netflix.list | while read line || [ -n "$line" ]; do
 					sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf
 				done
-				awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
-				awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5555"'\n",$0)}' /etc/config/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
+				awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/ssr/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
+				awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5555"'\n",$0)}' /etc/ssr/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
 
 				ipset -N netflix hash:net 2>/dev/null
-				cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; do
+				cat /etc/ssr/netflixip.list | while read nip || [ -n "$nip" ]; do
 					ipset add netflix $nip 2>/dev/null
 				done
 			else
-				cat /etc/config/netflix.list | while read line || [ -n "$line" ]; do
+				cat /etc/ssr/netflix.list | while read line || [ -n "$line" ]; do
 					sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf
 				done
-				awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
-				awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
+				awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/ssr/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
+				awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/ssr/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
 				ipset -N netflix hash:net 2>/dev/null
-				cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; do
+				cat /etc/ssr/netflixip.list | while read nip || [ -n "$nip" ]; do
 					ipset add netflix $nip 2>/dev/null
 				done
 			fi
@@ -747,7 +747,7 @@ stop() {
 		kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
 	fi
 	if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
-		rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf /tmp/dnsmasq.ssr/* /tmp/dnsmasq.oversea/*
+		rm -rf /tmp/dnsmasq.d/dnsmasq-ssr.conf /tmp/dnsmasq.ssr /tmp/dnsmasq.oversea
 		/etc/init.d/dnsmasq restart >/dev/null 2>&1
 	fi
 	del_cron

+ 28 - 9
luci-app-ssr-plus/root/etc/china_ssr.txt → luci-app-ssr-plus/root/etc/ssr/china_ssr.txt

@@ -1030,7 +1030,8 @@
 45.65.28.0/22
 45.112.132.0/22
 45.112.188.0/22
-45.112.208.0/21
+45.112.208.0/22
+45.112.212.0/22
 45.112.216.0/22
 45.112.220.0/22
 45.112.228.0/22
@@ -1471,6 +1472,9 @@
 45.253.232.0/22
 45.253.236.0/22
 45.253.240.0/22
+45.253.244.0/22
+45.253.248.0/22
+45.253.252.0/22
 45.254.0.0/22
 45.254.4.0/22
 45.254.8.0/22
@@ -1782,6 +1786,7 @@
 61.29.128.0/18
 61.29.192.0/19
 61.29.224.0/20
+61.29.240.0/20
 61.45.128.0/18
 61.45.224.0/20
 61.47.128.0/18
@@ -4004,6 +4009,25 @@
 103.149.210.0/23
 103.149.214.0/23
 103.149.220.0/23
+103.149.242.0/23
+103.149.244.0/23
+103.149.246.0/23
+103.149.248.0/23
+103.150.24.0/23
+103.150.66.0/23
+103.150.72.0/23
+103.150.122.0/23
+103.150.126.0/23
+103.150.128.0/23
+103.150.130.0/23
+103.150.146.0/23
+103.150.164.0/23
+103.150.172.0/23
+103.150.180.0/23
+103.150.200.0/23
+103.150.210.0/23
+103.150.214.0/23
+103.150.216.0/23
 103.192.0.0/22
 103.192.4.0/22
 103.192.8.0/22
@@ -5062,8 +5086,7 @@
 106.4.0.0/14
 106.8.0.0/15
 106.11.0.0/16
-106.12.0.0/15
-106.14.0.0/15
+106.12.0.0/14
 106.16.0.0/12
 106.32.0.0/12
 106.48.0.0/15
@@ -5401,10 +5424,7 @@
 117.32.0.0/13
 117.40.0.0/14
 117.44.0.0/15
-117.48.0.0/17
-117.48.128.0/17
-117.49.0.0/16
-117.50.0.0/15
+117.48.0.0/14
 117.53.48.0/20
 117.53.176.0/20
 117.57.0.0/16
@@ -5832,8 +5852,7 @@
 124.64.0.0/15
 124.66.0.0/17
 124.67.0.0/16
-124.68.0.0/15
-124.70.0.0/15
+124.68.0.0/14
 124.72.0.0/16
 124.73.0.0/16
 124.74.0.0/15

+ 0 - 0
luci-app-ssr-plus/root/etc/dnsmasq.ssr/gfw_base.conf → luci-app-ssr-plus/root/etc/ssr/gfw_base.conf


文件差异内容过多而无法显示
+ 44 - 204
luci-app-ssr-plus/root/etc/ssr/gfw_list.conf


+ 0 - 0
luci-app-ssr-plus/root/etc/config/netflix.list → luci-app-ssr-plus/root/etc/ssr/netflix.list


+ 0 - 0
luci-app-ssr-plus/root/etc/config/netflixip.list → luci-app-ssr-plus/root/etc/ssr/netflixip.list


+ 0 - 0
luci-app-ssr-plus/root/etc/dnsmasq.oversea/oversea_list.conf → luci-app-ssr-plus/root/etc/ssr/oversea_list.conf


+ 19 - 23
luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus

@@ -1,26 +1,22 @@
 #!/bin/sh
-
 uci -q batch <<-EOF >/dev/null
-	delete ucitrack.@shadowsocksr[-1]
-	add ucitrack shadowsocksr
-	set ucitrack.@shadowsocksr[-1].init=shadowsocksr
-	commit ucitrack
-	delete firewall.shadowsocksr
-	set firewall.shadowsocksr=include
-	set firewall.shadowsocksr.type=script
-	set firewall.shadowsocksr.path=/var/etc/shadowsocksr.include
-	set firewall.shadowsocksr.reload=1
-	commit firewall
+delete ucitrack.@shadowsocksr[-1]
+add ucitrack shadowsocksr
+set ucitrack.@shadowsocksr[-1].init=shadowsocksr
+commit ucitrack
+delete firewall.shadowsocksr
+set firewall.shadowsocksr=include
+set firewall.shadowsocksr.type=script
+set firewall.shadowsocksr.path=/var/etc/shadowsocksr.include
+set firewall.shadowsocksr.reload=1
+commit firewall
 EOF
-
-touch /etc/china_ssr.txt
-touch /etc/config/white.list
-touch /etc/config/black.list
-touch /etc/config/netflix.list
-touch /etc/config/netflixip.list
-touch /etc/dnsmasq.ssr/ad.conf
-touch /etc/dnsmasq.ssr/gfw_list.conf
-
-rm -rf /tmp/luci-modulecache/*
-rm -f /tmp/luci-indexcache
-exit 0
+touch /etc/ssr/china_ssr.txt
+touch /etc/ssr/white.list
+touch /etc/ssr/black.list
+touch /etc/ssr/netflix.list
+touch /etc/ssr/netflixip.list
+touch /etc/ssr/ad.conf
+touch /etc/ssr/gfw_list.conf
+rm -rf /tmp/luci-modulecache /tmp/luci-indexcache
+exit 0

+ 7 - 7
luci-app-ssr-plus/root/lib/upgrade/keep.d/luci-app-ssr-plus

@@ -1,8 +1,8 @@
-/etc/ssr_ip
-/etc/china_ssr.txt
 /etc/config/shadowsocksr
-/etc/config/white.list
-/etc/config/black.list
-/etc/config/netflix.list
-/etc/dnsmasq.ssr/ad.conf
-/etc/dnsmasq.ssr/gfw_list.conf
+/etc/ssr/china_ssr.txt
+/etc/ssr/white.list
+/etc/ssr/black.list
+/etc/ssr/netflix.list
+/etc/ssr/netflixip.list
+/etc/ssr/gfw_list.conf
+/etc/ssr/ad.conf

+ 5 - 5
luci-app-ssr-plus/root/usr/bin/ssr-ad

@@ -1,9 +1,9 @@
 #!/bin/sh -e
 if [ -f /tmp/adnew.conf ]; then
-  if (grep -wq "address=" /tmp/adnew.conf) ; then
-    cp /tmp/adnew.conf /tmp/ad.conf
-  else
-    cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' > /tmp/ad.conf
-  fi
+	if (grep -wq "address=" /tmp/adnew.conf); then
+		cp /tmp/adnew.conf /tmp/ssr-update.$1
+	else
+		cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' >/tmp/ssr-update.$1
+	fi
 fi
 rm -f /tmp/adnew.conf

+ 18 - 20
luci-app-ssr-plus/root/usr/bin/ssr-gfw

@@ -1,25 +1,23 @@
 #!/bin/sh -e
-
 generate_china_banned() {
-	cat $1 | base64 -d >/tmp/gfwlist.txt
-	rm -f $1
-	sed -i '/^@@|/d' /tmp/gfwlist.txt
-	cat /tmp/gfwlist.txt | sort -u |
-		sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' |
-		sed '/\*/d; /apple\.com/d; /sina\.cn/d; /sina\.com\.cn/d; /baidu\.com/d; /byr\.cn/d; /jlike\.com/d; /weibo\.com/d; /zhongsou\.com/d; /youdao\.com/d; /sogou\.com/d; /so\.com/d; /soso\.com/d; /aliyun\.com/d; /taobao\.com/d; /jd\.com/d; /qq\.com/d' |
-		sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/d' |
-		grep '^[0-9a-zA-Z\.-]\+$' | grep '\.' | sed 's#^\.\+##' | sort -u |
-		awk 'BEGIN { prev = "________"; } {
-		cur = $0;
-		if (index(cur, prev) == 1 && substr(cur, 1 + length(prev) ,1) == ".") {
-		} else {
-		print cur;
-		prev = cur;
-		}
-		}' | sort -u
+cat $1 | base64 -d >/tmp/gfwlist.txt
+rm -f $1
+sed -i '/^@@|/d' /tmp/gfwlist.txt
+cat /tmp/gfwlist.txt | sort -u |
+sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' |
+sed '/\*/d; /apple\.com/d; /sina\.cn/d; /sina\.com\.cn/d; /baidu\.com/d; /byr\.cn/d; /jlike\.com/d; /weibo\.com/d; /zhongsou\.com/d; /youdao\.com/d; /sogou\.com/d; /so\.com/d; /soso\.com/d; /aliyun\.com/d; /taobao\.com/d; /jd\.com/d; /qq\.com/d' |
+sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/d' |
+grep '^[0-9a-zA-Z\.-]\+$' | grep '\.' | sed 's#^\.\+##' | sort -u |
+awk 'BEGIN { prev = "________"; } {
+cur = $0;
+if (index(cur, prev) == 1 && substr(cur, 1 + length(prev) ,1) == ".") {
+} else {
+print cur;
+prev = cur;
 }
-
-generate_china_banned /tmp/gfw.b64 >/tmp/gfw.txt
+}' | sort -u
+}
+generate_china_banned /tmp/ssr-update.$1 >/tmp/gfw.txt
 rm -f /tmp/gfwlist.txt
-sed '/.*/s/.*/server=\/\.&\/127.0.0.1#5335\nipset=\/\.&\/gfwlist/' /tmp/gfw.txt >/tmp/gfwnew.txt
+sed '/.*/s/.*/server=\/\.&\/127.0.0.1#5335\nipset=\/\.&\/gfwlist/' /tmp/gfw.txt >/tmp/ssr-update.$1
 rm -f /tmp/gfw.txt

+ 8 - 4
luci-app-ssr-plus/root/usr/share/shadowsocksr/chinaipset.sh

@@ -1,5 +1,9 @@
-echo "create china hash:net family inet hashsize 1024 maxelem 65536" > /tmp/china.ipset
-awk '!/^$/&&!/^#/{printf("add china %s'" "'\n",$0)}' /etc/china_ssr.txt >> /tmp/china.ipset
+#!/bin/sh
+LOCK_FILE="/var/lock/ssr-chinaipset.lock"
+[ -f "$LOCK_FILE" ] && exit 2
+touch "$LOCK_FILE"
+echo "create china hash:net family inet hashsize 1024 maxelem 65536" >/tmp/china.ipset
+awk '!/^$/&&!/^#/{printf("add china %s'" "'\n",$0)}' /etc/ssr/china_ssr.txt >>/tmp/china.ipset
 ipset -! flush china
-ipset -! restore < /tmp/china.ipset 2>/dev/null
-rm -f /tmp/china.ipset
+ipset -! restore </tmp/china.ipset 2>/dev/null
+rm -f /tmp/china.ipset $LOCK_FILE

+ 3 - 3
luci-app-ssr-plus/root/usr/share/shadowsocksr/gfw2ipset.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
 mkdir -p /tmp/dnsmasq.ssr
-awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/config/black.list > /tmp/dnsmasq.ssr/blacklist_forward.conf
-awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/black.list >> /tmp/dnsmasq.ssr/blacklist_forward.conf
-awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/config/white.list > /tmp/dnsmasq.ssr/whitelist_forward.conf
+awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/ssr/black.list > /tmp/dnsmasq.ssr/blacklist_forward.conf
+awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/ssr/black.list >> /tmp/dnsmasq.ssr/blacklist_forward.conf
+awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/ssr/white.list > /tmp/dnsmasq.ssr/whitelist_forward.conf

+ 3 - 3
luci-app-ssr-plus/root/usr/share/shadowsocksr/ssrplusupdate.sh

@@ -1,6 +1,6 @@
 #!/bin/sh
-
 /usr/bin/lua /usr/share/shadowsocksr/update.lua
+sleep 2s
+/usr/share/shadowsocksr/chinaipset.sh
+sleep 2s
 /usr/bin/lua /usr/share/shadowsocksr/subscribe.lua
-sleep 10
-/etc/init.d/shadowsocksr restart

+ 31 - 105
luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua

@@ -3,123 +3,49 @@
 -- This file is part of the luci-app-ssr-plus update.lua
 -- By Mattraks
 ------------------------------------------------
-require 'nixio'
-require 'luci.util'
-require 'luci.jsonc'
-require 'luci.sys'
+require "luci.sys"
+require "luci.model.uci"
 local icount = 0
 local uci = luci.model.uci.cursor()
-
 local log = function(...)
 	print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " "))
 end
 
-log('正在更新【GFW列表】数据库')
-refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'gfwlist_url', 'https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt') .. " > /tmp/gfw.b64"
-sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-if sret == 0 then
-	luci.sys.call("/usr/bin/ssr-gfw")
-	icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l")
-	if tonumber(icount) > 1000 then
-		if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
-			oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
-		else
-			oldcount = "0"
-		end
-		if tonumber(icount) ~= tonumber(oldcount) then
-			luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf")
-			luci.sys.exec("cp -f /tmp/gfwnew.txt /tmp/dnsmasq.ssr/gfw_list.conf")
-			log('更新成功! 新的总纪录数:' .. tostring(tonumber(icount)/2))
-		else
-			log('你已经是最新数据,无需更新!')
-		end
-	else
-		log('更新失败!')
-	end
-	luci.sys.exec("rm -f /tmp/gfwnew.txt")
-else
-	log('更新失败!')
-end
-
-log('正在更新【国内IP段】数据库')
-refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'chnroute_url','https://ispip.clang.cn/all_cn.txt') .. " > /tmp/china_ssr.txt"
-sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
-if sret == 0 then
-	icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
-	if tonumber(icount) > 1000 then
-		if nixio.fs.access("/etc/china_ssr.txt") then
-			oldcount = luci.sys.exec("cat /etc/china_ssr.txt | wc -l")
-		else
-			oldcount = "0"
-		end
-		if tonumber(icount) ~= tonumber(oldcount) then
-			luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
-			log('更新成功! 新的总纪录数:' .. tostring(tonumber(icount)))
-		else
-			log('你已经是最新数据,无需更新!')
-		end
-	else
-		log('更新失败!')
-	end
-	luci.sys.exec("rm -f /tmp/china_ssr.txt")
-else
-	log('更新失败!')
-end
-
-if uci:get_first('shadowsocksr', 'global', 'adblock','0') == "1" then
-	log('正在更新【广告屏蔽】数据库')
-	refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'adblock_url','https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt') .. " > /tmp/adnew.conf"
+local function update(url, file, type, file2)
+	local Num = 1
+	refresh_cmd = "wget-ssl --no-check-certificate -t 3 -T 10 -O- " .. url .. " > /tmp/ssr-update." .. type
 	sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
 	if sret == 0 then
-		luci.sys.call("/usr/bin/ssr-ad")
-		icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
-		if tonumber(icount) > 100 then
-			if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
-				oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")
-			else
-				oldcount = "0"
-			end
-			if tonumber(icount) ~= tonumber(oldcount) then
-				luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf")
-				luci.sys.exec("cp -f /tmp/ad.conf /tmp/dnsmasq.ssr/ad.conf")
-				log('更新成功! 新的总纪录数:' .. tostring(tonumber(icount)))
-			else
-				log('你已经是最新数据,无需更新!')
-			end
-		else
-			log('更新失败!')
+		if type == "gfw_data" then
+			luci.sys.call("/usr/bin/ssr-gfw " .. type)
+			Num = 2
 		end
-		luci.sys.exec("rm -f /tmp/ad.conf")
-	else
-		log('更新失败!')
-	end
-end
-
---[[
-log('正在更新【Netflix IP段】数据库')
-refresh_cmd = "wget-ssl --no-check-certificate -O- " .. uci:get_first('shadowsocksr', 'global', 'nfip_url','https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt') .. " > /tmp/netflixip.list"
-sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
-if sret == 0 then
-	luci.sys.call("/usr/bin/ssr-gfw")
-	icount = luci.sys.exec("cat /tmp/netflixip.list | wc -l")
-	if tonumber(icount) > 5 then
-		if nixio.fs.access("/etc/config/netflixip.list") then
-			oldcount = luci.sys.exec("cat /etc/config/netflixip.list | wc -l")
-		else
-			oldcount = "0"
+		if type == "ad_data" then
+			luci.sys.call("/usr/bin/ssr-ad " .. type)
 		end
-		if tonumber(icount) ~= tonumber(oldcount) then
-			luci.sys.exec("cp -f /tmp/netflixip.list /etc/config/netflixip.list")
-			log('更新成功! 新的总纪录数:' .. tostring(tonumber(icount)))
+		local new_md5 = luci.sys.exec("echo -n $([ -f '/tmp/ssr-update." .. type .. "' ] && md5sum /tmp/ssr-update." .. type .. " | awk '{print $1}')")
+		local old_md5 = luci.sys.exec("echo -n $([ -f '" .. file .. "' ] && md5sum " .. file .. " | awk '{print $1}')")
+		if new_md5 == old_md5 then
+			log("你已经是最新数据,无需更新!")
 		else
-			log('你已经是最新数据,无需更新!')
+			icount = luci.sys.exec("cat /tmp/ssr-update." .. type .. " | wc -l")
+			luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file)
+			if file2 then luci.sys.exec("cp -f /tmp/ssr-update." .. type .. " " .. file2) end
+			log("更新成功! 新的总纪录数:" .. tostring(tonumber(icount)/Num))
 		end
 	else
-		log('更新失败!')
+		log("更新失败!")
 	end
-	luci.sys.exec("rm -f /tmp/netflixip.list")
-else
-	log('更新失败!')
+	luci.sys.exec("rm -f /tmp/ssr-update." .. type)
+end
+
+log("正在更新【GFW列表】数据库")
+update(uci:get_first("shadowsocksr", "global", "gfwlist_url", "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"), "/etc/ssr/gfw_list.conf", "gfw_data", "/tmp/dnsmasq.ssr/gfw_list.conf")
+log("正在更新【国内IP段】数据库")
+update(uci:get_first("shadowsocksr", "global", "chnroute_url","https://ispip.clang.cn/all_cn.txt"), "/etc/ssr/china_ssr.txt", "cnip")
+if uci:get_first("shadowsocksr", "global", "adblock","0") == "1" then
+	log("正在更新【广告屏蔽】数据库")
+	update(uci:get_first("shadowsocksr", "global", "adblock_url","https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"), "/etc/ssr/ad.conf", "ad_data", "/tmp/dnsmasq.ssr/ad.conf")
 end
---]]
+-- log("正在更新【Netflix IP段】数据库")
+-- update(uci:get_first("shadowsocksr", "global", "nfip_url","https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt"), "/etc/ssr/netflixip.list", "nfip_data")

部分文件因为文件数量过多而无法显示