luci-app-ssr-plus:Add gfwlist update URL (#3965)

This commit is contained in:
Mattraks 2020-03-24 11:27:30 +08:00 committed by GitHub
parent 9cbca25d79
commit 5b7fec3ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 261 additions and 19176 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ssr-plus PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=173 PKG_VERSION:=173
PKG_RELEASE:=6 PKG_RELEASE:=7
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
@ -33,7 +33,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server
bool "Include ShadowsocksR Server" bool "Include ShadowsocksR Server"
default y if x86||x86_64||arm||aarch64 default y if x86||x86_64||arm||aarch64
endef endef
define Package/$(PKG_NAME) define Package/$(PKG_NAME)
SECTION:=luci SECTION:=luci
CATEGORY:=LuCI CATEGORY:=LuCI
@ -68,9 +68,6 @@ define Package/$(PKG_NAME)/conffiles
endef endef
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) ./root/etc/china_ssr.txt $(1)/etc/china_ssr.txt
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./root/etc/config/shadowsocksr $(1)/etc/config/shadowsocksr $(INSTALL_CONF) ./root/etc/config/shadowsocksr $(1)/etc/config/shadowsocksr
$(INSTALL_DATA) ./root/etc/config/*.list $(1)/etc/config/ $(INSTALL_DATA) ./root/etc/config/*.list $(1)/etc/config/

View File

@ -9,7 +9,7 @@ function index()
end end
entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true
entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true
entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply=true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply = true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true
entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true
entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true
entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true
@ -19,19 +19,19 @@ function index()
entry({"admin", "services", "shadowsocksr", "subscribe"}, call("subscribe")) entry({"admin", "services", "shadowsocksr", "subscribe"}, call("subscribe"))
entry({"admin", "services", "shadowsocksr", "checkport"}, call("check_port")) entry({"admin", "services", "shadowsocksr", "checkport"}, call("check_port"))
entry({"admin", "services", "shadowsocksr", "log"},form("shadowsocksr/log"),_("Log"), 80).leaf = true entry({"admin", "services", "shadowsocksr", "log"},form("shadowsocksr/log"),_("Log"), 80).leaf = true
entry({"admin", "services", "shadowsocksr","run"},call("act_status")).leaf=true entry({"admin", "services", "shadowsocksr","run"},call("act_status")).leaf = true
entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf=true entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf = true
end end
function subscribe() function subscribe()
luci.sys.call("/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua >> /tmp/ssrplus.log 2>&1") luci.sys.call("/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua >> /tmp/ssrplus.log 2>&1")
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json({ ret = 1 }) luci.http.write_json({ret = 1})
end end
function act_status() function act_status()
local e={} local e = {}
e.running=luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null")==0 e.running = luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") == 0
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json(e) luci.http.write_json(e)
end end
@ -62,136 +62,138 @@ function check_status()
local set = "/usr/bin/ssr-check www." .. luci.http.formvalue("set") .. ".com 80 3 1" local set = "/usr/bin/ssr-check www." .. luci.http.formvalue("set") .. ".com 80 3 1"
sret = luci.sys.call(set) sret = luci.sys.call(set)
if sret == 0 then if sret == 0 then
retstring ="0" retstring = "0"
else else
retstring ="1" retstring = "1"
end end
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json({ ret=retstring }) luci.http.write_json({ret = retstring})
end end
function refresh_data() function refresh_data()
local set =luci.http.formvalue("set") local set = luci.http.formvalue("set")
local uci=luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local icount =0 local icount = 0
if set == "gfw_data" then if set == "gfw_data" then
refresh_cmd="wget-ssl --no-check-certificate -O - https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt > /tmp/gfw.b64" 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") sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
if sret == 0 then if sret == 0 then
luci.sys.call("/usr/bin/ssr-gfw") luci.sys.call("/usr/bin/ssr-gfw")
icount=luci.sys.exec("cat /tmp/gfwnew.txt | wc -l") icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l")
if tonumber(icount) > 1000 then if tonumber(icount) > 1000 then
oldcount= luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l") oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
if tonumber(icount) ~= tonumber(oldcount) then 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 /etc/dnsmasq.ssr/gfw_list.conf")
luci.sys.exec("cp -f /tmp/gfwnew.txt /tmp/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") luci.sys.call("/etc/init.d/dnsmasq restart")
retstring=tostring(tonumber(icount)/2) retstring = tostring(tonumber(icount)/2)
else else
retstring ="0" retstring = "0"
end end
else else
retstring="-1" retstring = "-1"
end end
luci.sys.exec("rm -f /tmp/gfwnew.txt") luci.sys.exec("rm -f /tmp/gfwnew.txt")
else else
retstring="-1" retstring = "-1"
end end
elseif set == "ip_data" then end
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' if set == "ip_data" then
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") 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'
icount=luci.sys.exec("cat /tmp/china_ssr.txt | wc -l") 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 sret == 0 and tonumber(icount) > 1000 then
oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l") oldcount = luci.sys.exec("cat /etc/china_ssr.txt | wc -l")
if tonumber(icount) ~= tonumber(oldcount) then if tonumber(icount) ~= tonumber(oldcount) then
luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt") luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
luci.sys.exec("/etc/init.d/shadowsocksr restart &") luci.sys.exec("/etc/init.d/shadowsocksr restart &")
retstring=tostring(tonumber(icount)) retstring = tostring(tonumber(icount))
else else
retstring="0" retstring = "0"
end end
else else
retstring="-1" retstring = "-1"
end end
luci.sys.exec("rm -f /tmp/china_ssr.txt") luci.sys.exec("rm -f /tmp/china_ssr.txt")
elseif set == "nfip_data" then end
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" if set == "nfip_data" then
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") 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"
icount=luci.sys.exec("cat /tmp/netflixip.list | wc -l") 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 sret == 0 and tonumber(icount) > 5 then
oldcount=luci.sys.exec("cat /etc/config/netflixip.list | wc -l") oldcount = luci.sys.exec("cat /etc/config/netflixip.list | wc -l")
if tonumber(icount) ~= tonumber(oldcount) then if tonumber(icount) ~= tonumber(oldcount) then
luci.sys.exec("cp -f /tmp/netflixip.list /etc/config/netflixip.list") luci.sys.exec("cp -f /tmp/netflixip.list /etc/config/netflixip.list")
luci.sys.exec("/etc/init.d/shadowsocksr restart &") luci.sys.exec("/etc/init.d/shadowsocksr restart &")
retstring=tostring(tonumber(icount)) retstring = tostring(tonumber(icount))
else else
retstring="0" retstring = "0"
end end
else else
retstring="-1" retstring = "-1"
end end
luci.sys.exec("rm -f /tmp/netflixip.list") luci.sys.exec("rm -f /tmp/netflixip.list")
else end
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" if set == "ad_data" then
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") 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"
if sret== 0 then sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
if sret == 0 then
luci.sys.call("/usr/bin/ssr-ad") luci.sys.call("/usr/bin/ssr-ad")
icount=luci.sys.exec("cat /tmp/ad.conf | wc -l") icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
if tonumber(icount) > 100 then if tonumber(icount) > 100 then
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l") oldcount = luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")
else else
oldcount="0" oldcount = "0"
end end
if tonumber(icount) ~= tonumber(oldcount) then 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 /etc/dnsmasq.ssr/ad.conf")
luci.sys.exec("cp -f /tmp/ad.conf /tmp/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") luci.sys.call("/etc/init.d/dnsmasq restart")
retstring=tostring(tonumber(icount)) retstring = tostring(tonumber(icount))
else else
retstring="0" retstring = "0"
end end
else else
retstring="-1" retstring = "-1"
end end
luci.sys.exec("rm -f /tmp/ad.conf") luci.sys.exec("rm -f /tmp/ad.conf")
else else
retstring="-1" retstring = "-1"
end end
end end
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json({ret=retstring,retcount=icount}) luci.http.write_json({ret = retstring,retcount = icount})
end end
function check_port() function check_port()
local set="" local set = ""
local retstring="<br /><br />" local retstring = "<br /><br />"
local s local s
local server_name="" local server_name = ""
local shadowsocksr="shadowsocksr" local uci = luci.model.uci.cursor()
local uci=luci.model.uci.cursor() local iret = 1
local iret=1 uci:foreach("shadowsocksr", "servers", function(s)
uci:foreach(shadowsocksr, "servers", function(s)
if s.alias then if s.alias then
server_name=s.alias server_name = s.alias
elseif s.server and s.server_port then elseif s.server and s.server_port then
server_name="%s:%s" %{s.server, s.server_port} server_name = "%s:%s" %{s.server, s.server_port}
end end
iret=luci.sys.call(" ipset add ss_spec_wan_ac " .. s.server .. " 2>/dev/null") iret = luci.sys.call("ipset add ss_spec_wan_ac " .. s.server .. " 2>/dev/null")
socket=nixio.socket("inet", "stream") socket = nixio.socket("inet", "stream")
socket:setopt("socket", "rcvtimeo", 3) socket:setopt("socket", "rcvtimeo", 3)
socket:setopt("socket", "sndtimeo", 3) socket:setopt("socket", "sndtimeo", 3)
ret=socket:connect(s.server,s.server_port) ret = socket:connect(s.server,s.server_port)
if tostring(ret) == "true" then if tostring(ret) == "true" then
socket:close() socket:close()
retstring=retstring .. "<font color='green'>[" .. server_name .. "] OK.</font><br />" retstring = retstring .. "<font color = 'green'>[" .. server_name .. "] OK.</font><br />"
else else
retstring=retstring .. "<font color='red'>[" .. server_name .. "] Error.</font><br />" retstring = retstring .. "<font color = 'red'>[" .. server_name .. "] Error.</font><br />"
end end
if iret == 0 then if iret == 0 then
luci.sys.call(" ipset del ss_spec_wan_ac " .. s.server) luci.sys.call("ipset del ss_spec_wan_ac " .. s.server)
end end
end) end)
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json({ret=retstring}) luci.http.write_json({ret = retstring})
end end

View File

@ -45,6 +45,20 @@ o.datatype = "uinteger"
o:depends("enable_switch", "1") o:depends("enable_switch", "1")
o.default = 3 o.default = 3
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false
o = s:option(Value, "adblock_url", translate("adblock_url"))
o:value("https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
o.default = "https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf"
o:depends("adblock", "1")
o.description = translate("Support AdGuardHome and DNSMASQ format list")
o = s:option(Value, "gfwlist_url", translate("gfwlist Update url"))
o:value("https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt", translate("Loukky/gfwlist-by-loukky"))
o:value("https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt", translate("gfwlist/gfwlist"))
o.default = "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"
o = s:option(Value, "chnroute_url", translate("Chnroute Update url")) o = s:option(Value, "chnroute_url", translate("Chnroute Update url"))
o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN")) o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN"))
o.default = "https://ispip.clang.cn/all_cn.txt" o.default = "https://ispip.clang.cn/all_cn.txt"
@ -55,15 +69,6 @@ o:value("https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/getflix.t
o.default = "https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt" o.default = "https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt"
o.description = translate("Customize Netflix IP Url") o.description = translate("Customize Netflix IP Url")
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false
o = s:option(Value, "adblock_url", translate("adblock_url"))
o:value("https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
o.default = "https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf"
o:depends("adblock", "1")
o.description = translate("Support AdGuardHome and DNSMASQ format list")
-- [[ SOCKS5 Proxy ]]-- -- [[ SOCKS5 Proxy ]]--
s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server")) s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server"))
s.anonymous = true s.anonymous = true

View File

@ -166,12 +166,6 @@ msgstr "编辑服务器配置"
msgid "Alias" msgid "Alias"
msgstr "别名" msgstr "别名"
msgid "SOCKS Proxy"
msgstr "SOCKS(4/5)代理"
msgid "Enable SOCKS Proxy"
msgstr "启用 SOCKS 代理"
msgid "Server" msgid "Server"
msgstr "服务器" msgstr "服务器"
@ -283,6 +277,9 @@ msgstr "【国内IP段】数据库"
msgid "Netflix IP Data" msgid "Netflix IP Data"
msgstr "【Netflix IP段】数据库" msgstr "【Netflix IP段】数据库"
msgid "Advertising Data"
msgstr "【广告屏蔽】数据库"
msgid "Records" msgid "Records"
msgstr "条记录" msgstr "条记录"
@ -332,10 +329,16 @@ msgid "Enable adblock"
msgstr "启用广告屏蔽" msgstr "启用广告屏蔽"
msgid "adblock_url" msgid "adblock_url"
msgstr "广告屏蔽订阅" msgstr "广告屏蔽更新URL"
msgid "gfwlist Update url"
msgstr "GFWList更新URL"
msgid "Chnroute Update url"
msgstr "国内IP段更新URL"
msgid "nfip_url" msgid "nfip_url"
msgstr "Netflix IP更新URL" msgstr "Netflix IP更新URL"
msgid "Customize Netflix IP Url" msgid "Customize Netflix IP Url"
msgstr "自定义Netflix IP更新URL默认项目地址https://github.com/QiuSimons/Netflix_IP" msgstr "自定义Netflix IP更新URL默认项目地址https://github.com/QiuSimons/Netflix_IP"
@ -343,15 +346,6 @@ msgstr "自定义Netflix IP更新URL默认项目地址https://github.com/Q
msgid "Enable Process Deamon" msgid "Enable Process Deamon"
msgstr "启用进程自动守护" msgstr "启用进程自动守护"
msgid "Advertising Data"
msgstr "【广告屏蔽】数据库"
msgid "Chnroute Setting"
msgstr "国内IP段数据库更新设置"
msgid "Update url"
msgstr "更新链接"
msgid "DNS Server IP and Port" msgid "DNS Server IP and Port"
msgstr "DNS服务器地址和端口" msgstr "DNS服务器地址和端口"
@ -496,24 +490,12 @@ msgstr "游戏模式UDP中继服务器"
msgid "Game Mode UDP Relay" msgid "Game Mode UDP Relay"
msgstr "游戏模式UDP中继" msgstr "游戏模式UDP中继"
msgid "adblock settings"
msgstr "广告屏蔽设置"
msgid "Server failsafe auto swith and custom update settings" msgid "Server failsafe auto swith and custom update settings"
msgstr "服务器节点故障自动切换/广告屏蔽/国内IP段数据库更新设置" msgstr "服务器节点故障自动切换/广告屏蔽/国内IP段数据库更新设置"
msgid "Support AdGuardHome and DNSMASQ format list" msgid "Support AdGuardHome and DNSMASQ format list"
msgstr "同时支持 AdGuard Home 和 DNSMASQ 格式的过滤列表" msgstr "同时支持 AdGuard Home 和 DNSMASQ 格式的过滤列表"
msgid "Enable Custom Chnroute"
msgstr "自定义国内IP段数据库更新"
msgid "Chnroute Update url"
msgstr "国内IP段数据库更新URL"
msgid "Delete all severs"
msgstr "删除所有服务器节点"
msgid "Delete All Subscribe Severs" msgid "Delete All Subscribe Severs"
msgstr "删除所有订阅服务器节点" msgstr "删除所有订阅服务器节点"

File diff suppressed because it is too large Load Diff

View File

@ -11,13 +11,12 @@ config global
option switch_timeout '5' option switch_timeout '5'
option switch_time '667' option switch_time '667'
option switch_try_count '3' option switch_try_count '3'
option adblock '0' option gfwlist_url 'https://raw.githubusercontent.com/Loukky/gfwlist-by-loukky/master/gfwlist.txt'
option adblock_url 'https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf'
option chnroute_url 'https://ispip.clang.cn/all_cn.txt' option chnroute_url 'https://ispip.clang.cn/all_cn.txt'
option nfip_url 'https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt' option nfip_url 'https://raw.githubusercontent.com/QiuSimons/Netflix_IP/master/NF_only.txt'
option adblock_url 'https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf'
option netflix_server 'same' option netflix_server 'same'
option threads '0' option threads '0'
config socks5_proxy config socks5_proxy
option socks '0' option socks '0'

View File

@ -48,8 +48,8 @@ uci_get_by_cfgid() {
} }
check_host() { check_host() {
local host=$1 local host=$1
if echo $host | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then if echo $host | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
hostip=$host hostip=$host
elif [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then elif [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then
hostip=$host hostip=$host
@ -91,7 +91,7 @@ gen_config_file() {
if echo $hostip | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then if echo $hostip | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
hostip=$hostip hostip=$hostip
else else
hostip=$(cat /etc/ssr_ip) hostip=$(cat /tmp/ssr_ip)
fi fi
fi fi
[ "$2" == "0" -a "$kcp_flag" == "1" ] && hostip="127.0.0.1" [ "$2" == "0" -a "$kcp_flag" == "1" ] && hostip="127.0.0.1"
@ -179,9 +179,9 @@ start_rules() {
else else
server=$(ping $server -W 1 -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1) server=$(ping $server -W 1 -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1)
if echo $server | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then if echo $server | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
echo $server >/etc/ssr_ip echo $server >/tmp/ssr_ip
else else
server=$(cat /etc/ssr_ip) server=$(cat /tmp/ssr_ip)
fi fi
fi fi
kcp_server=$server kcp_server=$server
@ -224,9 +224,9 @@ start_rules() {
proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443" proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443"
fi fi
if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
netflix="1" netflix="1"
else else
netflix="0" netflix="0"
fi fi
netflix_ip=$(check_host $(uci_get_by_name $NETFLIX_SERVER server)) netflix_ip=$(check_host $(uci_get_by_name $NETFLIX_SERVER server))
/usr/bin/ssr-rules \ /usr/bin/ssr-rules \
@ -313,7 +313,7 @@ start_redir() {
-l :$server_port $password $kcp_param -l :$server_port $password $kcp_param
kcp_enable_flag=1 kcp_enable_flag=1
fi fi
gen_config_file $GLOBAL_SERVER 0 $(uci_get_by_name $GLOBAL_SERVER local_port 1234) gen_config_file $GLOBAL_SERVER 0 $(uci_get_by_name $GLOBAL_SERVER local_port 1234)
local stype=$(uci_get_by_name $GLOBAL_SERVER type) local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" ]; then if [ "$stype" == "ss" ]; then
@ -330,25 +330,25 @@ start_redir() {
elif [ "$stype" == "tun" ]; then elif [ "$stype" == "tun" ]; then
sscmd="/usr/sbin/redsocks2" sscmd="/usr/sbin/redsocks2"
fi fi
local ntype=$(uci_get_by_name $NETFLIX_SERVER type) local ntype=$(uci_get_by_name $NETFLIX_SERVER type)
if [ "$ntype" == "ss" ]; then if [ "$ntype" == "ss" ]; then
ncmd="/usr/bin/ss-redir" ncmd="/usr/bin/ss-redir"
sssock="/usr/bin/ss-local" sssock="/usr/bin/ss-local"
elif [ "$ntype" == "ssr" ]; then elif [ "$ntype" == "ssr" ]; then
ncmd="/usr/bin/ssr-redir" ncmd="/usr/bin/ssr-redir"
sssock="/usr/bin/ssr-local" sssock="/usr/bin/ssr-local"
elif [ "$ntype" == "v2ray" ]; then elif [ "$ntype" == "v2ray" ]; then
ncmd="/usr/bin/v2ray/v2ray" ncmd="/usr/bin/v2ray/v2ray"
[ ! -f "$ncmd" ] && ncmd="/usr/bin/v2ray" [ ! -f "$ncmd" ] && ncmd="/usr/bin/v2ray"
elif [ "$ntype" == "trojan" ]; then elif [ "$ntype" == "trojan" ]; then
ncmd="/usr/sbin/trojan" ncmd="/usr/sbin/trojan"
elif [ "$ntype" == "socks5" ]; then elif [ "$ntype" == "socks5" ]; then
ncmd="/usr/sbin/redsocks2" ncmd="/usr/sbin/redsocks2"
elif [ "$ntype" == "tun" ]; then elif [ "$ntype" == "tun" ]; then
ncmd="/usr/sbin/redsocks2" ncmd="/usr/sbin/redsocks2"
fi fi
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type) local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
if [ "$utype" == "ss" ]; then if [ "$utype" == "ss" ]; then
ucmd="/usr/bin/ss-redir" ucmd="/usr/bin/ss-redir"
@ -371,71 +371,70 @@ start_redir() {
fi fi
redir_tcp=1 redir_tcp=1
if [ "$stype" == "ss" -o "$stype" == "ssr" ]; then if [ "$stype" == "ss" -o "$stype" == "ssr" ]; then
local last_config_file=$CONFIG_FILE local last_config_file=$CONFIG_FILE
local pid_file="/var/run/ssr-retcp.pid" local pid_file="/var/run/ssr-retcp.pid"
for i in $(seq 1 $threads); do for i in $(seq 1 $threads); do
$sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1 $sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1
done done
echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >>/tmp/ssrplus.log
elif [ "$stype" == "v2ray" ]; then elif [ "$stype" == "v2ray" ]; then
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >>/tmp/ssrplus.log
elif [ "$stype" == "trojan" ]; then elif [ "$stype" == "trojan" ]; then
for i in $(seq 1 $threads); do for i in $(seq 1 $threads); do
$sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 & $sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 &
done done
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) , $threads Threads Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) , $threads Threads Started!" >>/tmp/ssrplus.log
elif [ "$stype" == "socks5" ]; then elif [ "$stype" == "socks5" ]; then
/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-retcp.conf" socks5 tcp $(uci_get_by_name $GLOBAL_SERVER local_port) \ /usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-retcp.conf" socks5 tcp $(uci_get_by_name $GLOBAL_SERVER local_port) \
$(check_host $(uci_get_by_name $GLOBAL_SERVER server)) $(uci_get_by_name $GLOBAL_SERVER server_port) \ $(check_host $(uci_get_by_name $GLOBAL_SERVER server)) $(uci_get_by_name $GLOBAL_SERVER server_port) \
$(uci_get_by_name $GLOBAL_SERVER auth_enable 0) $(uci_get_by_name $GLOBAL_SERVER username) $(uci_get_by_name $GLOBAL_SERVER password) $(uci_get_by_name $GLOBAL_SERVER auth_enable 0) $(uci_get_by_name $GLOBAL_SERVER username) $(uci_get_by_name $GLOBAL_SERVER password)
for i in $(seq 1 $threads); do for i in $(seq 1 $threads); do
$sscmd -c /var/etc/redsocks-ssr-retcp.conf >/dev/null 2>&1 $sscmd -c /var/etc/redsocks-ssr-retcp.conf >/dev/null 2>&1
done done
echo "$(date "+%Y-%m-%d %H:%M:%S") Socks5 REDIRECT/TPROXY $threads Threads Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") Socks5 REDIRECT/TPROXY $threads Threads Started!" >>/tmp/ssrplus.log
elif [ "$stype" == "tun" ]; then elif [ "$stype" == "tun" ]; then
/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-retcp.conf" vpn $(uci_get_by_name $GLOBAL_SERVER iface "br-lan") $(uci_get_by_name $GLOBAL_SERVER local_port) /usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-retcp.conf" vpn $(uci_get_by_name $GLOBAL_SERVER iface "br-lan") $(uci_get_by_name $GLOBAL_SERVER local_port)
for i in $(seq 1 $threads); do for i in $(seq 1 $threads); do
$sscmd -c /var/etc/redsocks-ssr-retcp.conf >/dev/null 2>&1 $sscmd -c /var/etc/redsocks-ssr-retcp.conf >/dev/null 2>&1
done done
echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel REDIRECT $threads Threads Started!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel REDIRECT $threads Threads Started!" >>/tmp/ssrplus.log
fi fi
if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
if [ "$ntype" == "ss" -o "$ntype" == "ssr" ]; then if [ "$ntype" == "ss" -o "$ntype" == "ssr" ]; then
gen_config_file $NETFLIX_SERVER 2 4321 gen_config_file $NETFLIX_SERVER 2 4321
gen_config_file $NETFLIX_SERVER 3 1088 gen_config_file $NETFLIX_SERVER 3 1088
$sssock -c /var/etc/shadowsocksr_s.json $ARG_OTA -f /var/run/ssr-socksdns.pid >/dev/null 2>&1 $sssock -c /var/etc/shadowsocksr_s.json $ARG_OTA -f /var/run/ssr-socksdns.pid >/dev/null 2>&1
dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 &
$ncmd -c /var/etc/shadowsocksr_n.json $ARG_OTA -f /var/run/ssr-netflix.pid >/dev/null 2>&1 $ncmd -c /var/etc/shadowsocksr_n.json $ARG_OTA -f /var/run/ssr-netflix.pid >/dev/null 2>&1
elif [ "$ntype" == "v2ray" ]; then elif [ "$ntype" == "v2ray" ]; then
lua /usr/share/shadowsocksr/genv2config.lua $NETFLIX_SERVER tcp 4321 1088 >/var/etc/v2-ssr-netflix.json lua /usr/share/shadowsocksr/genv2config.lua $NETFLIX_SERVER tcp 4321 1088 >/var/etc/v2-ssr-netflix.json
$ncmd -config /var/etc/v2-ssr-netflix.json >/dev/null 2>&1 & $ncmd -config /var/etc/v2-ssr-netflix.json >/dev/null 2>&1 &
dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 &
elif [ "$ntype" == "trojan" ]; then elif [ "$ntype" == "trojan" ]; then
lua /usr/share/shadowsocksr/gentrojanconfig.lua $NETFLIX_SERVER nat 4321 >/var/etc/trojan-ssr-netflix.json lua /usr/share/shadowsocksr/gentrojanconfig.lua $NETFLIX_SERVER nat 4321 >/var/etc/trojan-ssr-netflix.json
sed -i 's/\\//g' /var/etc/trojan-ssr-netflix.json sed -i 's/\\//g' /var/etc/trojan-ssr-netflix.json
$ncmd --config /var/etc/trojan-ssr-netflix.json >/dev/null 2>&1 & $ncmd --config /var/etc/trojan-ssr-netflix.json >/dev/null 2>&1 &
lua /usr/share/shadowsocksr/gentrojanconfig.lua $NETFLIX_SERVER client 1088 >/var/etc/trojan-ssr-socksdns.json lua /usr/share/shadowsocksr/gentrojanconfig.lua $NETFLIX_SERVER client 1088 >/var/etc/trojan-ssr-socksdns.json
sed -i 's/\\//g' /var/etc/trojan-ssr-socksdns.json sed -i 's/\\//g' /var/etc/trojan-ssr-socksdns.json
$ncmd --config /var/etc/trojan-ssr-socksdns.json >/dev/null 2>&1 & $ncmd --config /var/etc/trojan-ssr-socksdns.json >/dev/null 2>&1 &
dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 &
elif [ "$ntype" == "socks5" ]; then elif [ "$ntype" == "socks5" ]; then
/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-netflix.conf" socks5 tcp 4321 \ /usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-netflix.conf" socks5 tcp 4321 \
$(check_host $(uci_get_by_name $NETFLIX_SERVER server)) $(uci_get_by_name $NETFLIX_SERVER server_port) \ $(check_host $(uci_get_by_name $NETFLIX_SERVER server)) $(uci_get_by_name $NETFLIX_SERVER server_port) \
$(uci_get_by_name $NETFLIX_SERVER auth_enable 0) $(uci_get_by_name $NETFLIX_SERVER username) $(uci_get_by_name $NETFLIX_SERVER password) $(uci_get_by_name $NETFLIX_SERVER auth_enable 0) $(uci_get_by_name $NETFLIX_SERVER username) $(uci_get_by_name $NETFLIX_SERVER password)
$ncmd -c /var/etc/redsocks-ssr-netflix.conf >/dev/null 2>&1 $ncmd -c /var/etc/redsocks-ssr-netflix.conf >/dev/null 2>&1
microsocks -i 127.0.0.1 -p 1088 ssr-socksdns >/dev/null 2>&1 & microsocks -i 127.0.0.1 -p 1088 ssr-socksdns >/dev/null 2>&1 &
dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 &
elif [ "$ntype" == "tun" ]; then elif [ "$ntype" == "tun" ]; then
/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-netflix.conf" vpn $(uci_get_by_name $NETFLIX_SERVER iface "br-lan") 4321 /usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-netflix.conf" vpn $(uci_get_by_name $NETFLIX_SERVER iface "br-lan") 4321
$ncmd -c /var/etc/redsocks-ssr-netflix.conf >/dev/null 2>&1 $ncmd -c /var/etc/redsocks-ssr-netflix.conf >/dev/null 2>&1
microsocks -i 127.0.0.1 -p 1088 ssr-socksdns >/dev/null 2>&1 & microsocks -i 127.0.0.1 -p 1088 ssr-socksdns >/dev/null 2>&1 &
dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 & dns2socks 127.0.0.1:1088 8.8.8.8:53 127.0.0.1:5555 -q >/dev/null 2>&1 &
fi fi
fi fi
if [ -n "$UDP_RELAY_SERVER" ]; then if [ -n "$UDP_RELAY_SERVER" ]; then
redir_udp=1 redir_udp=1
if [ "$utype" == "ss" -o "$utype" == "ssr" ]; then if [ "$utype" == "ss" -o "$utype" == "ssr" ]; then
@ -457,10 +456,10 @@ start_redir() {
$ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 & $ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 &
ipt2socks -U -b 0.0.0.0 -4 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 & ipt2socks -U -b 0.0.0.0 -4 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 &
elif [ "$utype" == "socks5" ]; then elif [ "$utype" == "socks5" ]; then
/usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-reudp.conf" socks5 udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) \ /usr/share/shadowsocksr/genred2config.sh "/var/etc/redsocks-ssr-reudp.conf" socks5 udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) \
$(check_host $(uci_get_by_name $UDP_RELAY_SERVER server)) $(uci_get_by_name $UDP_RELAY_SERVER server_port) \ $(check_host $(uci_get_by_name $UDP_RELAY_SERVER server)) $(uci_get_by_name $UDP_RELAY_SERVER server_port) \
$(uci_get_by_name $UDP_RELAY_SERVER auth_enable 0) $(uci_get_by_name $UDP_RELAY_SERVER username) $(uci_get_by_name $UDP_RELAY_SERVER password) $(uci_get_by_name $UDP_RELAY_SERVER auth_enable 0) $(uci_get_by_name $UDP_RELAY_SERVER username) $(uci_get_by_name $UDP_RELAY_SERVER password)
$ucmd -c /var/etc/redsocks-ssr-reudp.conf >/dev/null 2>&1 $ucmd -c /var/etc/redsocks-ssr-reudp.conf >/dev/null 2>&1
elif [ "$stype" == "tun" ]; then elif [ "$stype" == "tun" ]; then
redir_udp=0 redir_udp=0
echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel UDP TPROXY Relay not supported!" >>/tmp/ssrplus.log echo "$(date "+%Y-%m-%d %H:%M:%S") Network Tunnel UDP TPROXY Relay not supported!" >>/tmp/ssrplus.log
@ -528,17 +527,17 @@ start_service() {
[ $(uci_get_by_name $1 enable 0) == "0" ] && return 1 [ $(uci_get_by_name $1 enable 0) == "0" ] && return 1
let server_count=server_count+1 let server_count=server_count+1
if [ "$server_count" == "1" ]; then if [ "$server_count" == "1" ]; then
if ! (iptables-save -t filter | grep SSR-SERVER-RULE >/dev/null); then if ! (iptables-save -t filter | grep SSR-SERVER-RULE >/dev/null); then
iptables -N SSR-SERVER-RULE && \ iptables -N SSR-SERVER-RULE && \
iptables -t filter -I INPUT -j SSR-SERVER-RULE iptables -t filter -I INPUT -j SSR-SERVER-RULE
fi fi
fi fi
if [ "$(uci_get_by_name $1 type ssr)" == "ssr" ]; then if [ "$(uci_get_by_name $1 type ssr)" == "ssr" ]; then
gen_service_file $1 /var/etc/${NAME}_$server_count.json gen_service_file $1 /var/etc/${NAME}_$server_count.json
/usr/bin/ssr-server -c /var/etc/${NAME}_$server_count.json -u -f /var/run/ssr-server$server_count.pid >/dev/null 2>&1 /usr/bin/ssr-server -c /var/etc/${NAME}_$server_count.json -u -f /var/run/ssr-server$server_count.pid >/dev/null 2>&1
else else
microsocks -i :: -p $(uci_get_by_name $1 server_port) -1 -u $(uci_get_by_name $1 username) -P $(uci_get_by_name $1 password) ssr-server$server_count >/dev/null 2>&1 & microsocks -i :: -p $(uci_get_by_name $1 server_port) -1 -u $(uci_get_by_name $1 username) -P $(uci_get_by_name $1 password) ssr-server$server_count >/dev/null 2>&1 &
fi fi
iptables -t filter -A SSR-SERVER-RULE -p tcp --dport $(uci_get_by_name $1 server_port) -j ACCEPT iptables -t filter -A SSR-SERVER-RULE -p tcp --dport $(uci_get_by_name $1 server_port) -j ACCEPT
iptables -t filter -A SSR-SERVER-RULE -p udp --dport $(uci_get_by_name $1 server_port) -j ACCEPT iptables -t filter -A SSR-SERVER-RULE -p udp --dport $(uci_get_by_name $1 server_port) -j ACCEPT
return 0 return 0
@ -580,24 +579,24 @@ start_local() {
mkdir -p /var/run /var/etc mkdir -p /var/run /var/etc
if [ "$local_type" == "ssr" ]; then if [ "$local_type" == "ssr" ]; then
gen_config_file $local_server 3 $(uci_get_by_type socks5_proxy local_port 1080) gen_config_file $local_server 3 $(uci_get_by_type socks5_proxy local_port 1080)
/usr/bin/ssr-local -c $CONFIG_SOCK5_FILE -u -f /var/run/ssr-local.pid >/dev/null 2>&1 /usr/bin/ssr-local -c $CONFIG_SOCK5_FILE -u -f /var/run/ssr-local.pid >/dev/null 2>&1
elif [ "$local_type" == "ss" ]; then elif [ "$local_type" == "ss" ]; then
gen_config_file $local_server 3 $(uci_get_by_type socks5_proxy local_port 1080) gen_config_file $local_server 3 $(uci_get_by_type socks5_proxy local_port 1080)
/usr/bin/ss-local -c $CONFIG_SOCK5_FILE -u -f /var/run/ssr-local.pid >/dev/null 2>&1 /usr/bin/ss-local -c $CONFIG_SOCK5_FILE -u -f /var/run/ssr-local.pid >/dev/null 2>&1
elif [ "$local_type" == "v2ray" ]; then elif [ "$local_type" == "v2ray" ]; then
lua /usr/share/shadowsocksr/genv2config.lua $local_server tcp 0 $(uci_get_by_type socks5_proxy local_port 1080) >/var/etc/v2-ssr-local.json lua /usr/share/shadowsocksr/genv2config.lua $local_server tcp 0 $(uci_get_by_type socks5_proxy local_port 1080) >/var/etc/v2-ssr-local.json
sed -i 's/\\//g' /var/etc/v2-ssr-local.json sed -i 's/\\//g' /var/etc/v2-ssr-local.json
/usr/bin/v2ray/v2ray -config /var/etc/v2-ssr-local.json >/dev/null 2>&1 & /usr/bin/v2ray/v2ray -config /var/etc/v2-ssr-local.json >/dev/null 2>&1 &
elif [ "$local_type" == "trojan" ]; then elif [ "$local_type" == "trojan" ]; then
lua /usr/share/shadowsocksr/gentrojanconfig.lua $local_server client $(uci_get_by_type socks5_proxy local_port 1080) >/var/etc/trojan-ssr-local.json lua /usr/share/shadowsocksr/gentrojanconfig.lua $local_server client $(uci_get_by_type socks5_proxy local_port 1080) >/var/etc/trojan-ssr-local.json
sed -i 's/\\//g' /var/etc/trojan-ssr-local.json sed -i 's/\\//g' /var/etc/trojan-ssr-local.json
/usr/sbin/trojan --config /var/etc/trojan-ssr-local.json >/dev/null 2>&1 & /usr/sbin/trojan --config /var/etc/trojan-ssr-local.json >/dev/null 2>&1 &
else else
microsocks -i :: -p $(uci_get_by_type socks5_proxy local_port 1080) ssr-local >/dev/null 2>&1 & microsocks -i :: -p $(uci_get_by_type socks5_proxy local_port 1080) ssr-local >/dev/null 2>&1 &
fi fi
local_enable=1 local_enable=1
} }
rules() { rules() {
@ -619,12 +618,12 @@ start() {
GLOBAL_SERVER=$switch_server GLOBAL_SERVER=$switch_server
switch_enable=1 switch_enable=1
fi fi
NETFLIX_SERVER=$(uci_get_by_type global netflix_server same) NETFLIX_SERVER=$(uci_get_by_type global netflix_server same)
if [ "$NETFLIX_SERVER" == "same" ]; then if [ "$NETFLIX_SERVER" == "same" ]; then
NETFLIX_SERVER=$GLOBAL_SERVER NETFLIX_SERVER=$GLOBAL_SERVER
fi fi
if rules; then if rules; then
start_redir start_redir
mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/ mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/
@ -641,34 +640,30 @@ start() {
rm -f /tmp/dnsmasq.ssr/ad.conf rm -f /tmp/dnsmasq.ssr/ad.conf
fi fi
/usr/share/shadowsocksr/gfw2ipset.sh /usr/share/shadowsocksr/gfw2ipset.sh
if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then if [ "$NETFLIX_SERVER" != "$GLOBAL_SERVER" ]; then
cat /etc/config/netflix.list | while read line || [ -n "$line" ]; cat /etc/config/netflix.list | while read line || [ -n "$line" ]; do
do sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf
sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf done
done awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
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("server=/.%s/'"127.0.0.1#5555"'\n",$0)}' /etc/config/netflix.list >> /tmp/dnsmasq.ssr/netflix_forward.conf
ipset -N netflix hash:net 2>/dev/null
ipset -N netflix hash:net 2>/dev/null cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; do
cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; ipset add netflix $nip 2>/dev/null
do done
ipset add netflix $nip 2>/dev/null else
done cat /etc/config/netflix.list | while read line || [ -n "$line" ]; do
else sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf
cat /etc/config/netflix.list | while read line || [ -n "$line" ]; done
do awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list >/tmp/dnsmasq.ssr/netflix_forward.conf
sed -i "/$line/d" /tmp/dnsmasq.ssr/gfw_list.conf awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/netflix.list >>/tmp/dnsmasq.ssr/netflix_forward.conf
done ipset -N netflix hash:net 2>/dev/null
awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"netflix"'\n",$0)}' /etc/config/netflix.list > /tmp/dnsmasq.ssr/netflix_forward.conf cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; do
awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/netflix.list >> /tmp/dnsmasq.ssr/netflix_forward.conf ipset add netflix $nip 2>/dev/null
ipset -N netflix hash:net 2>/dev/null done
cat /etc/config/netflixip.list | while read nip || [ -n "$nip" ]; fi
do
ipset add netflix $nip 2>/dev/null
done
fi
/etc/init.d/dnsmasq restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
start_server start_server
@ -676,27 +671,27 @@ start() {
if [ $(uci_get_by_type global monitor_enable 0) == "1" ]; then if [ $(uci_get_by_type global monitor_enable 0) == "1" ]; then
let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable
if [ $total_count -gt 0 ]; then if [ $total_count -gt 0 ]; then
#param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw #param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw
service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable
fi fi
fi fi
ENABLE_SERVER=$(uci_get_by_type global global_server nil) ENABLE_SERVER=$(uci_get_by_type global global_server nil)
if [ "$ENABLE_SERVER" == "nil" ]; then if [ "$ENABLE_SERVER" == "nil" ]; then
return 1 return 1
else else
STYPE=$(uci_get_by_name $ENABLE_SERVER type nil) STYPE=$(uci_get_by_name $ENABLE_SERVER type nil)
if [ "$STYPE" == "nil" ]; then if [ "$STYPE" == "nil" ]; then
CFGID=$(uci_get_by_cfgid servers type nil) CFGID=$(uci_get_by_cfgid servers type nil)
if [ "$CFGID" == "nil" ]; then if [ "$CFGID" == "nil" ]; then
uci set shadowsocksr.@global[0].global_server='nil' uci set shadowsocksr.@global[0].global_server='nil'
else else
uci set shadowsocksr.@global[0].global_server=$CFGID uci set shadowsocksr.@global[0].global_server=$CFGID
fi fi
uci commit shadowsocksr uci commit shadowsocksr
/etc/init.d/shadowsocksr restart /etc/init.d/shadowsocksr restart
fi fi
fi fi
} }
boot() { boot() {
@ -739,7 +734,7 @@ stop() {
kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1 kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi fi
if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf /tmp/dnsmasq.ssr/* /tmp/dnsmasq.oversea/*
/etc/init.d/dnsmasq restart >/dev/null 2>&1 /etc/init.d/dnsmasq restart >/dev/null 2>&1
fi fi
del_cron del_cron

View File

@ -7,7 +7,7 @@ require 'nixio'
require 'luci.util' require 'luci.util'
require 'luci.jsonc' require 'luci.jsonc'
require 'luci.sys' require 'luci.sys'
local icount =0 local icount = 0
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local log = function(...) local log = function(...)
@ -15,7 +15,7 @@ local log = function(...)
end end
log('正在更新【GFW列表】数据库') log('正在更新【GFW列表】数据库')
refresh_cmd = "wget-ssl --no-check-certificate -O - https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt > /tmp/gfw.b64" 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//tmp/gfw.b64'
sret = luci.sys.call(refresh_cmd .. " 2>/dev/null") sret = luci.sys.call(refresh_cmd .. " 2>/dev/null")
if sret == 0 then if sret == 0 then
luci.sys.call("/usr/bin/ssr-gfw") luci.sys.call("/usr/bin/ssr-gfw")