' +
+ '
' +
'
<%:Subscription%>
' +
'<%:Subscribing,Please do not refresh!%>
' +
'' +
@@ -24,7 +24,10 @@
//显示并开始刷新订阅
function update_subscribe() {
$("body").append(modal);
- $(".modals-bg").show();
+ $(".modals-bg").removeClass("hide");
+ setTimeout(function(){
+ $(".modals").removeClass("hide");
+ }, 200);
setTimeout("get_realtime_log();", 500);
}
//保存订阅按钮
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 ba0b7b14e2..d39453b898 100644
--- a/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po
+++ b/package/ctcgfw/luci-app-vssr/po/zh_Hans/vssr.po
@@ -173,7 +173,10 @@ msgid "Alias"
msgstr "别名"
msgid "V2ray SOCKS5 Proxy"
-msgstr "V2ray SOCKS5代理"
+msgstr "V2ray SOCKS5 代理"
+
+msgid "V2ray HTTP Proxy"
+msgstr "V2ray HTTP 代理"
msgid "Server"
msgstr "服务器"
@@ -539,6 +542,12 @@ msgstr "用户名"
msgid "Socks pass"
msgstr "密码"
+msgid "HTTP user"
+msgstr "用户名"
+
+msgid "HTTP pass"
+msgstr "密码"
+
msgid "Enable Servers"
msgstr "开启服务"
diff --git a/package/ctcgfw/luci-app-vssr/root/etc/config/vssr b/package/ctcgfw/luci-app-vssr/root/etc/config/vssr
index 088a72a5c5..8db9e5a9ca 100755
--- a/package/ctcgfw/luci-app-vssr/root/etc/config/vssr
+++ b/package/ctcgfw/luci-app-vssr/root/etc/config/vssr
@@ -21,6 +21,14 @@ config socks5_proxy
option Socks_user 'user'
option Socks_pass 'password'
+config http_proxy
+ option enable_server '0'
+ option local_port '1088'
+ option local_address '0.0.0.0'
+ option enable_auth '0'
+ option http_user 'user'
+ option http_pass 'password'
+
config access_control
option wan_bp_list '/etc/vssr/china_ssr.txt'
option lan_ac_mode 'b'
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 21271961a7..064f8f89dc 100755
--- a/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr
+++ b/package/ctcgfw/luci-app-vssr/root/etc/init.d/vssr
@@ -20,7 +20,12 @@ NAME=vssr
CONFIG_FILE=/var/etc/${NAME}_t.json
CONFIG_UDP_FILE=/var/etc/${NAME}_u.json
CONFIG_SOCK5_FILE=/var/etc/${NAME}_s.json
+CRON_FILE=/etc/crontabs/root
+#定义可执行文件路径
+VSSR_RULES_BIN=/usr/bin/vssr-rules
+
+#初始化配置
server_count=0
redir_tcp=0
redir_udp=0
@@ -33,9 +38,10 @@ switch_enable=0
shunt_enable=0
switch_server=$1
MAXFD=32768
-CRON_FILE=/etc/crontabs/root
threads=1
-scount=0
+
+
+#读取 uci 数据
uci_get_by_name() {
local ret=$(uci get $NAME.$1.$2 2>/dev/null)
echo ${ret:=$3}
@@ -46,6 +52,24 @@ uci_get_by_type() {
echo ${ret:=$3}
}
+run_mode=$(uci_get_by_type global run_mode)
+is_xray=$(uci_get_by_type global use_xray)
+
+#查找可执行文件
+find_bin() {
+ case "$1" in
+ ss) ret="ss-redir" ;;
+ ss-local) ret="ss-local" ;;
+ ssr) ret="ssr-redir" ;;
+ ssr-local) ret="ssr-local" ;;
+ ssr-server) ret="ssr-server" ;;
+ v2ray | vless) [[ $is_xray = "1" ]] && ret="xray" || ret="v2ray" ;;
+ trojan) ret="trojan" ;;
+ esac
+ echo $(find /usr -perm /+x -type f -name $ret)
+}
+
+#添加定时执行脚本
add_cron() {
sed -i '/vssr.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/vssr.log' >>$CRON_FILE
[ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/bin/lua /usr/share/vssr/subscribe.lua" >>$CRON_FILE
@@ -53,13 +77,16 @@ add_cron() {
crontab $CRON_FILE
}
+#删除定时执行脚本
del_cron() {
sed -i '/vssr/d' $CRON_FILE
sed -i '/vssr.log/d' $CRON_FILE
/etc/init.d/cron restart
}
+
+#计算分流数量
count_shunt() {
- scount=0
+ snum=0
eval shunt_array1="youtube"
eval shunt_array2="tw_video"
eval shunt_array3="netflix"
@@ -72,17 +99,16 @@ count_shunt() {
local server_index=$(uci_get_by_type global ${a}_server)
local server_type=$(uci_get_by_name $server_index type)
if [ "$server_type" != "" ]; then
- scount=$(($scount + 1))
+ snum=$(($snum + 1))
fi
done
+ echo $snum
}
-count_shunt
-run_mode=$(uci_get_by_type global run_mode)
-is_xray=$(uci_get_by_type global use_xray)
+
+#创建配置文件
gen_config_file() {
local hostip=$(uci_get_by_name $1 server)
-
[ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1"
if [ $2 = "0" ]; then
@@ -94,17 +120,12 @@ gen_config_file() {
config_file=$CONFIG_UDP_FILE
server_obj=$UDP_RELAY_SERVER
fi
- if [ $(uci_get_by_name $1 fast_open 0) = "1" ]; then
- fastopen="true"
- else
- fastopen="false"
- fi
+ [[ $(uci_get_by_name $1 fast_open 0) = "1" ]] && fastopen="true" || fastopen="false"
local stype=$(uci_get_by_name $1 type)
local port=$(uci_get_by_name $1 local_port)
- if [ "$stype" == "vless" ]; then
- stype="v2ray"
- fi
+ [[ "$stype" == "vless" ]] && stype="v2ray"
+
if [ "$stype" == "trojan" ]; then
if [ "$re_type" == "udp" ]; then
re_type="client"
@@ -113,16 +134,19 @@ gen_config_file() {
re_type="nat"
fi
fi
+
local mport=0
if [ $3 = "1" ]; then
stype="v2ray"
mport=1090
re_type="tcp"
fi
+
lua /usr/share/vssr/genconfig_${stype}.lua ${server_obj} ${re_type} ${port} ${hostip} ${mport} >${config_file}
sed -i 's/\\//g' $config_file
}
+#获取arg输出
get_arg_out() {
case "$(uci_get_by_type access_control router_proxy 1)" in
1) echo "-o" ;;
@@ -130,6 +154,7 @@ get_arg_out() {
esac
}
+#启动规则
start_rules() {
local server=$(uci_get_by_name $GLOBAL_SERVER server)
#resolve name
@@ -185,15 +210,12 @@ start_rules() {
#deal gfw firewall rule
local gfwmode=""
- if [ "$run_mode" = "gfw" ]; then
- gfwmode="-g"
- elif [ "$run_mode" = "router" ]; then
- gfwmode="-r"
- elif [ "$run_mode" = "oversea" ]; then
- gfwmode="-c"
- elif [ "$run_mode" = "all" ]; then
- gfwmode="-z"
- fi
+ case "$run_mode" in
+ gfw) gfwmode="-g" ;;
+ router) gfwmode="-r" ;;
+ oversea) gfwmode="-c" ;;
+ all) gfwmode="-z" ;;
+ esac
local dports=$(uci_get_by_type global dports 1)
if [ $dports = "1" ]; then
@@ -202,7 +224,7 @@ start_rules() {
proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443 "
fi
- /usr/bin/vssr-rules \
+ $VSSR_RULES_BIN \
-s "$server" \
-l "$local_port" \
-S "$udp_server" \
@@ -218,6 +240,7 @@ start_rules() {
return $?
}
+#启动PDNSD
start_pdnsd() {
local usr_dns="$1"
local usr_port="$2"
@@ -265,24 +288,8 @@ start_pdnsd() {
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf &
}
-find_bin() {
- case "$1" in
- ss) ret="/usr/bin/ss-redir" ;;
- ss-local) ret="/usr/bin/ss-local" ;;
- ssr) ret="/usr/bin/ssr-redir" ;;
- ssr-local) ret="/usr/bin/ssr-local" ;;
- ssr-server) ret="/usr/bin/ssr-server" ;;
- v2ray | vless)
- ret="/usr/bin/v2ray/v2ray" && [ ! -f "$ret" ] && ret="/usr/bin/v2ray"
- if [ $is_xray = "1" ]; then
- ret="/usr/bin/xray" && [ ! -f "$ret" ] && ret="/usr/bin/xray/xray"
- fi
- ;;
- trojan) ret="/usr/sbin/trojan" ;;
- esac
- echo $ret
-}
-#分流节点
+
+#开启分流
start_shunt() {
eval shunt_type1="global"
eval shunt_type2="youtube"
@@ -360,8 +367,7 @@ start_redir() {
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
sscmd=$(find_bin $stype)
- local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
- ucmd=$(find_bin $utype)
+
if [ "$(uci_get_by_type global threads 0)" = "0" ]; then
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
@@ -370,6 +376,7 @@ start_redir() {
fi
#转发TCP
redir_tcp=1
+ scount=$(count_shunt)
if [ $scount == "0" ]; then
local last_config_file=$CONFIG_FILE
case "$stype" in
@@ -408,6 +415,8 @@ start_redir() {
#转发UDP
if [ -n "$UDP_RELAY_SERVER" ]; then
redir_udp=1
+ local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
+ ucmd=$(find_bin $utype)
gen_config_file $UDP_RELAY_SERVER 1 0
last_config_file=$CONFIG_UDP_FILE
case "$stype" in
@@ -467,11 +476,7 @@ start_redir() {
}
gen_service_file() {
- if [ $(uci_get_by_name $1 fast_open) = "1" ]; then
- fastopen="true"
- else
- fastopen="false"
- fi
+ [[ $(uci_get_by_name $1 fast_open) = "1" ]] && fastopen="true" || fastopen="false"
cat <<-EOF >$2
{
"server": "0.0.0.0",
@@ -504,6 +509,7 @@ start_service() {
iptables -t filter -A SSR-SERVER-RULE -p udp --dport $(uci_get_by_name $1 server_port) -j ACCEPT
return 0
}
+
gen_serv_include() {
FWI=$(uci get firewall.vssr.path 2>/dev/null)
[ -n "$FWI" ] || return 0
@@ -535,15 +541,17 @@ start_server() {
}
start_local() {
- local local_server=$(uci_get_by_type socks5_proxy enable_server)
+ local socks_server=$(uci_get_by_type socks5_proxy enable_server)
+ local http_server=$(uci_get_by_type http_proxy enable_server)
- [ "$local_server" = "0" ] && return 1
+ if [ "$socks_server" = "0" -a "$http_server" = "0" ]; then
+ return 1
+ fi
mkdir -p /var/run /var/etc
lua /usr/share/vssr/genconfig_v2ray_s.lua >$CONFIG_SOCK5_FILE
sed -i 's/\\//g' $config_file
socksbin=$(find_bin "v2ray")
- echo $socksbin
$socksbin -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 &
local_enable=1
}
@@ -639,7 +647,7 @@ stop() {
killall -q -9 ss-redir ss-local obfs-local ssr-redir ssr-local ssr-server v2ray v2ray-plugin xray trojan microsocks ipt2socks dns2socks pdnsd
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
diff --git a/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/genconfig_v2ray_s.lua b/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/genconfig_v2ray_s.lua
index 17d7e7c8b9..beed53de26 100755
--- a/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/genconfig_v2ray_s.lua
+++ b/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/genconfig_v2ray_s.lua
@@ -2,25 +2,47 @@ local ucursor = require 'luci.model.uci'.cursor()
local name = 'vssr'
local json = require 'luci.jsonc'
local proto = 'socks'
+local socks_switch = ucursor:get_first(name, 'socks5_proxy', 'enable_server')
local auth_type = ucursor:get_first(name, 'socks5_proxy', 'enable_auth')
local local_port = ucursor:get_first(name, 'socks5_proxy', 'local_port')
local Socks_user = ucursor:get_first(name, 'socks5_proxy', 'Socks_user')
local Socks_pass = ucursor:get_first(name, 'socks5_proxy', 'Socks_pass')
+local http_switch = ucursor:get_first(name, 'socks5_proxy', 'enable_server')
+local auth_typeh = ucursor:get_first(name, 'http_proxy', 'enable_auth')
+local local_porth = ucursor:get_first(name, 'http_proxy', 'local_port')
+local http_user = ucursor:get_first(name, 'http_proxy', 'http_user')
+local http_pass = ucursor:get_first(name, 'http_proxy', 'http_pass')
+
+function gen_inbound(sw, auth_type, local_port, user, pass, proto)
+ local bound = {}
+ if sw == 0 then
+ bound = nil
+ else
+ bound = {
+ port = local_port,
+ protocol = proto,
+ settings = {
+ auth = (auth_type == '1') and 'password' or 'noauth',
+ accounts = (auth_type == '1') and {{user = (auth_type == '1') and user, pass = pass}} or nil
+ }
+ }
+ end
+ return bound
+end
+
+inbounds_table = {}
+
+table.insert(inbounds_table, gen_inbound(socks_switch, auth_type, local_port, Socks_user, Socks_pass, 'socks'))
+table.insert(inbounds_table, gen_inbound(http_switch, auth_typeh, local_porth, http_user, http_pass, 'http'))
+
local v2ray = {
log = {
-- error = "/var/log/v2ray.log",
loglevel = 'warning'
},
-- 传入连接
- inbound = {
- port = local_port,
- protocol = proto,
- settings = {
- auth = (auth_type == '1') and 'password' or 'noauth',
- accounts = (auth_type == '1') and {{user = (auth_type == '1') and Socks_user, pass = Socks_pass}} or nil
- }
- },
+ inbounds = inbounds_table,
-- 传出连接
outbound = {protocol = 'freedom'},
-- 额外传出连接
diff --git a/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/subscribe.lua b/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/subscribe.lua
index 357f3ec6b7..6397a5b543 100644
--- a/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/subscribe.lua
+++ b/package/ctcgfw/luci-app-vssr/root/usr/share/vssr/subscribe.lua
@@ -390,7 +390,7 @@ local execute = function()
end
-- diff
do
- assert(next(nodeResult), 'node result is empty')
+ assert(next(nodeResult), '获取不到节点信息,请检查路由器是否能够访问网络,或者订阅链接是否正确')
local add, del = 0, 0
ucic:foreach(
name,
@@ -453,7 +453,7 @@ if subscribe_url and #subscribe_url > 0 then
execute,
function(e)
log(e)
- log(debug.traceback())
+ -- log(debug.traceback())
log('发生错误, 正在恢复服务')
log('END SUBSCRIBE')
local firstServer = ucic:get_first(name, uciType)
diff --git a/package/ctcgfw/luci-app-vssr/root/www/luci-static/vssr/css/vssr.css b/package/ctcgfw/luci-app-vssr/root/www/luci-static/vssr/css/vssr.css
index a523425925..394ed97a77 100644
--- a/package/ctcgfw/luci-app-vssr/root/www/luci-static/vssr/css/vssr.css
+++ b/package/ctcgfw/luci-app-vssr/root/www/luci-static/vssr/css/vssr.css
@@ -622,7 +622,12 @@ footer.mobile-hide {
left: 0;
top: 0;
background: rgba(255, 255, 255, 0.8);
- display: none;
+ transition: all 0.2s;
+}
+
+.modals-bg.hide{
+ visibility: hidden;
+ opacity: 0;
}
.modals {
@@ -642,6 +647,14 @@ footer.mobile-hide {
/* Firefox */
-webkit-box-sizing: border-box;
/* Safari */
+ transition: all 0.3s ease-in-out;
+ transform: scale(1);
+}
+
+.modals.hide{
+ visibility: hidden;
+ opacity: 0;
+ transform: scale(0.5);
}
.modals h2 {