From aed8c0e66059d5d0b2fd0fc3b220adb307674fa0 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Thu, 5 Mar 2020 19:05:52 +0800 Subject: [PATCH] luci-app-vssr: sync with upstream source --- package/ctcgfw/luci-app-vssr/Makefile | 4 +-- .../luci-app-vssr/luasrc/controller/vssr.lua | 7 ++--- .../luasrc/model/cbi/vssr/advanced.lua | 4 +-- .../luasrc/model/cbi/vssr/client-config.lua | 15 ++++++++++ .../luasrc/model/cbi/vssr/status.lua | 2 +- .../ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po | 2 ++ .../ctcgfw/luci-app-vssr/root/etc/init.d/vssr | 29 ++++++++++++++++++- .../ctcgfw/luci-app-vssr/root/usr/bin/vssr-ad | 9 ++++-- 8 files changed, 59 insertions(+), 13 deletions(-) diff --git a/package/ctcgfw/luci-app-vssr/Makefile b/package/ctcgfw/luci-app-vssr/Makefile index b61eaf8c74..95139b7fb9 100644 --- a/package/ctcgfw/luci-app-vssr/Makefile +++ b/package/ctcgfw/luci-app-vssr/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-vssr -PKG_VERSION:=1.17 -PKG_RELEASE:=20200304-4 +PKG_VERSION:=1.18 +PKG_RELEASE:=20200305-4 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ diff --git a/package/ctcgfw/luci-app-vssr/luasrc/controller/vssr.lua b/package/ctcgfw/luci-app-vssr/luasrc/controller/vssr.lua index 5bc1ecb271..3876140dbb 100644 --- a/package/ctcgfw/luci-app-vssr/luasrc/controller/vssr.lua +++ b/package/ctcgfw/luci-app-vssr/luasrc/controller/vssr.lua @@ -313,11 +313,7 @@ local set =luci.http.formvalue("set") local icount =0 if set == "gfw_data" then -if nixio.fs.access("/usr/bin/wget-ssl") then refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64" - else - refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64" - end sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") if sret== 0 then luci.sys.call("/usr/bin/vssr-gfw") @@ -326,6 +322,8 @@ if nixio.fs.access("/usr/bin/wget-ssl") then oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l") 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 /etc/dnsmasq.ssr/gfw_list.conf /tmp/dnsmasq.ssr/gfw_list.conf") + luci.sys.call("/etc/init.d/dnsmasq restart") retstring=tostring(math.ceil(tonumber(icount)/2)) else retstring ="0" @@ -375,6 +373,7 @@ if sret== 0 then luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf") retstring=tostring(math.ceil(tonumber(icount))) if oldcount==0 then + luci.sys.exec("cp -f /etc/dnsmasq.ssr/ad.conf /tmp/dnsmasq.ssr/ad.conf") luci.sys.call("/etc/init.d/dnsmasq restart") end else diff --git a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/advanced.lua b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/advanced.lua index 931d82cb1c..95f89c8992 100644 --- a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/advanced.lua +++ b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/advanced.lua @@ -77,7 +77,7 @@ o = s:option(Flag, "adblock", translate("Enable adblock")) o.rmempty = false o = s:option(Value, "adblock_url", translate("adblock_url")) -o.default = "https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt" +o.default = "https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf" -- [[ chnroute ]] s = m:section(TypedSection, "global", translate("Chnroute Setting")) @@ -87,7 +87,7 @@ o = s:option(Flag, "chnroute", translate("Enable custom chnroute")) o.rmempty = false o = s:option(Value, "chnroute_url", translate("Update url")) -o.default = "https://cdn.jsdelivr.net/gh/17mon/china_ip_list/china_ip_list.txt" +o.default = "https://ispip.clang.cn/all_cn.txt" -- [[ haProxy ]]-- diff --git a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/client-config.lua b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/client-config.lua index 802b2b41c1..dc3bbb9bc0 100644 --- a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/client-config.lua +++ b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/client-config.lua @@ -76,6 +76,10 @@ o:value("ssr", translate("ShadowsocksR")) if nixio.fs.access("/usr/bin/ss-redir") then o:value("ss", translate("Shadowsocks")) end + +if nixio.fs.access("/usr/bin/ipt2socks") then +o:value("socks5", translate("Socks5")) +end o.description = translate( "Using incorrect encryption mothod may causes service fail to start") @@ -99,12 +103,23 @@ o.rmempty = false -- o.default = 60 -- o.rmempty = false +o = s:option(Flag, "auth_enable", translate("Enable Authentication")) +o.rmempty = false +o.default = "0" +o:depends("type", "socks5") + +o = s:option(Value, "username", translate("Username")) +o.rmempty = true +o:depends("type", "socks5") + + o = s:option(Value, "password", translate("Password")) o.password = true o.rmempty = true o:depends("type", "ssr") o:depends("type", "ss") o:depends("type", "trojan") +o:depends("type", "socks5") o = s:option(ListValue, "encrypt_method", translate("Encrypt Method")) diff --git a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/status.lua b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/status.lua index b8350025a4..f228b02ad5 100644 --- a/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/status.lua +++ b/package/ctcgfw/luci-app-vssr/luasrc/model/cbi/vssr/status.lua @@ -1,7 +1,7 @@ -- Copyright (C) 2017 yushi studio -- Licensed to the public under the GNU General Public License v3. -local IPK_Version="20200304.1.17" +local IPK_Version="20200305.1.18" local m, s, o local redir_run=0 local reudp_run=0 diff --git a/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po b/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po index 004e465fb8..d01f061188 100644 --- a/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po +++ b/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po @@ -866,3 +866,5 @@ msgstr "进程详情:" msgid "File Viewer" msgstr "文件查看器" +msgid "Enable Authentication" +msgstr "启用 用户名/密码 认证" \ No newline at end of file diff --git a/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr b/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr index f719c9d6ce..71bc8620d9 100755 --- a/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr +++ b/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr @@ -617,9 +617,11 @@ start_redir() { sscmd="/usr/bin/v2ray/v2ray" elif [ "$stype" == "trojan" ] ;then sscmd="/usr/sbin/trojan" + elif [ "$stype" == "socks5" ]; then + sscmd="/usr/bin/ipt2socks" 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 ucmd="/usr/bin/ss-redir" elif [ "$utype" == "ssr" ] ;then @@ -628,6 +630,8 @@ start_redir() { ucmd="/usr/bin/v2ray/v2ray" elif [ "$utype" == "trojan" ] ;then ucmd="/usr/sbin/trojan" + elif [ "$stype" == "socks5" ]; then + ucmd="/usr/bin/ipt2socks" fi if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then @@ -658,6 +662,17 @@ start_redir() { done echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) $threads 线程 已启动!" >> /tmp/vssr.log +elif [ "$stype" == "socks5" ]; then + for i in $(seq 1 $threads); do + if [ "$(uci_get_by_name $GLOBAL_SERVER auth_enable 0)" == "0" ]; then + $sscmd -T -4 -b 0.0.0.0 -s $(uci_get_by_name $GLOBAL_SERVER server) -p $(uci_get_by_name $GLOBAL_SERVER server_port) -l $(uci_get_by_name $GLOBAL_SERVER local_port) -R ssr-retcp >/dev/null 2>&1 & + else + $sscmd -T -4 -b 0.0.0.0 -s $(uci_get_by_name $GLOBAL_SERVER server) -p $(uci_get_by_name $GLOBAL_SERVER server_port) -a $(uci_get_by_name $GLOBAL_SERVER username) \ + -k $(uci_get_by_name $GLOBAL_SERVER password) -l $(uci_get_by_name $GLOBAL_SERVER local_port) -R ssr-retcp >/dev/null 2>&1 & + fi + done + echo "$(date "+%Y-%m-%d %H:%M:%S") Socks5 REDIRECT/TPROXY, $threads 线程 已启动!" >>/tmp/vssr.log + fi #转发UDP @@ -681,8 +696,16 @@ start_redir() { sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json $ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 & ipt2socks -U -4 -b 0.0.0.0 -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 + if [ "$(uci_get_by_name $GLOBAL_SERVER auth_enable 0)" == "0" ]; then + $ucmd -4 -b 0.0.0.0 -s $(uci_get_by_name $UDP_RELAY_SERVER server) -p $(uci_get_by_name $UDP_RELAY_SERVER server_port) -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) -U ssr-reudp >/dev/null 2>&1 & + else + $ucmd -4 -b 0.0.0.0 -s $(uci_get_by_name $UDP_RELAY_SERVER server) -p $(uci_get_by_name $UDP_RELAY_SERVER server_port) -a $(uci_get_by_name $GLOBAL_SERVER username) \ + -k $(uci_get_by_name $GLOBAL_SERVER password) -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) -U ssr-reudp >/dev/null 2>&1 & + fi fi +fi #deal with dns if [ "$(uci_get_by_type global pdnsd_enable)" -ne "0" ] ;then @@ -928,6 +951,7 @@ start_local() { 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 & local_enable=3 + fi if [ "$http_enable" -eq 1 ] ;then @@ -1068,6 +1092,7 @@ stop() { killall -q -9 ss-local killall -q -9 haproxy killall -q -9 privoxy + killall -q -9 ipt2socks killall -q -9 v2ray-plugin killall -q -9 gq-client killall -q -9 gq-server @@ -1108,3 +1133,5 @@ stop() { del_cron } + + diff --git a/package/ctcgfw/luci-app-vssr/root/usr/bin/vssr-ad b/package/ctcgfw/luci-app-vssr/root/usr/bin/vssr-ad index 668a262664..2c7ffef057 100755 --- a/package/ctcgfw/luci-app-vssr/root/usr/bin/vssr-ad +++ b/package/ctcgfw/luci-app-vssr/root/usr/bin/vssr-ad @@ -1,6 +1,9 @@ #!/bin/sh -e - if [ -f /tmp/adnew.conf ]; then - cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' > /tmp/ad.conf + 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 fi - +rm -f /tmp/adnew.conf