luci-app-ssr-plus-Jo: sync with upstream source

This commit is contained in:
CN_SZTL 2020-03-05 19:05:28 +08:00
parent 4eafa63a28
commit f4ddbc00fe
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
7 changed files with 142 additions and 111 deletions

View File

@ -28,7 +28,7 @@ entry({"admin", "vpn", "shadowsocksr", "appointlist"},form("shadowsocksr/appoint
entry({"admin", "vpn", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"),22).leaf = true
end
entry({"admin", "vpn", "shadowsocksr", "status"},form("shadowsocksr/status"),_("Status"), 23).leaf = true
entry({"admin", "vpn", "shadowsocksr", "logview"}, cbi("vssr/logview", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), _("Log") ,30).leaf=true
entry({"admin", "vpn", "shadowsocksr", "logview"}, cbi("shadowsocksr/logview", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), _("Log") ,30).leaf=true
entry({"admin", "vpn", "shadowsocksr", "fileread"}, call("act_read"), nil).leaf=true
entry({"admin", "vpn", "shadowsocksr", "refresh"}, call("refresh_data"))
entry({"admin", "vpn", "shadowsocksr", "checkport"}, call("check_port"))

View File

@ -134,6 +134,9 @@ 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")
upload_conf = s:option(FileUpload, "")
@ -155,18 +158,27 @@ o.rmempty = false
-- o.default = 60
-- o.rmempty = false
o = s:option(Value, "weight", translate("Weight"))
o.datatype = "uinteger"
o.default = 10
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"))

View File

@ -58,12 +58,6 @@ o = s:option(DummyValue, "", "")
o.rawhtml = true
o.template = "shadowsocksr/update_subscribe"
o = s:option(Button,"update",translate("Update All Subscribe Severs"),translate("No special needs, please click here to subscribe to update"))
o.inputstyle = "reload"
o.write = function()
luci.sys.call("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/vssr.log 2>&1")
luci.http.redirect(luci.dispatcher.build_url("admin", "vpn", "shadowsocksr", "servers"))
end
o = s:option(Button,"delete",translate("Delete All Subscribe Severs"))
@ -87,8 +81,3 @@ end
return m

View File

@ -1,109 +1,123 @@
<%+cbi/valueheader%>
<link rel="stylesheet" href="/luci-static/shadowsocksr/css/shadowsocksr.css?v=72883">
<label class="cbi-value-title"><%= translate("Before subscribing please click below to delete all servers in the subscription") %></label>
<link rel="stylesheet" href="/luci-static/shadowsocksr/css/shadowsocksr.css?v=72883">
<label class="cbi-value-title"><%= translate("Update") %></label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-reload" id="update_subscribe" type="button"
size="0" value="<%= translate("Save And Start Subscribe") %> ">
size="0" value="<%= translate("Save And Start Subscribe") %>">
</div>
<script type="text/javascript">
const SAVE_SUBSCRIBE_URL = '<%=luci.dispatcher.build_url("admin", "vpn", "shadowsocksr","subscribe")%>';
const SERVERS_URL = '<%=luci.dispatcher.build_url("admin", "vpn", "shadowsocksr","servers")%>';
var _responseLen;
var noChange = 0;
//<![CDATA[
var _responseLen;
var noChange = 0;
var x = 5;
var modal = '<div class="modals-bg">' +
'<div class="modals">' +
'<h2><%:Subscription%></h2>' +
'<h3 style="margin-left:0;"><%:Subscribing,Please do not refresh!%></h3>' +
'<textarea cols="63" rows="28" wrap="on" readonly="readonly" id="log_content3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>' +
'</div>' +
'</div>';
//显示并开始刷新订阅
function update_subscribe() {
'<div class="modals">' +
'<h2><%:Subscription%></h2>'+
'<h3 style="margin-left:0;"><%:Subscribing,Please do not refresh!%></h3>'+
'<textarea cols="63" rows="28" wrap="on" readonly="readonly" id="log_content3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>'+
'</div>'+
'</div>';
function update_subscribe() {
$("body").append(modal);
$(".modals-bg").show();
setTimeout("get_realtime_log();", 500);
}
//保存订阅按钮
$("#update_subscribe").click(function () {
prefix_array = $("#cbi-vssr-server_subscribe .cbi-section-node").attr("id").split("-");
$(".modals-bg").show();
setTimeout("get_realtime_log();", 500);
}
function submit_url(){
prefix_array = $("#cbi-shadowsocksr-server_subscribe .cbi-section-node").attr("id").split("-");
prefix_array[0] = "cbid";
prefix = prefix_array.join(".");
if ($("[name='" + prefix + ".auto_update']").is(":checked")) {
if($("[name='"+prefix+".auto_update']").is(":checked")){
var auto_update = "1";
} else {
}else{
var auto_update = "0";
}
var auto_update_time = $("[name='" + prefix + ".auto_update_time']").val();
var auto_update_time = $("[name='"+prefix+".auto_update_time']").val();
var subscribe_url = [];
$("[name='" + prefix + ".subscribe_url']").each(function () {
if ($(this).val() != "") {
$("[name='"+prefix+".subscribe_url']").each(function(){
if($(this).val() != ""){
subscribe_url.push($(this).val());
}
});
if ($("[name='" + prefix + ".proxy']").is(":checked")) {
if($("[name='"+prefix+".proxy']").is(":checked")){
var proxy = "1";
} else {
}else{
var proxy = "0";
}
var data = {
auto_update: auto_update,
auto_update_time: auto_update_time,
auto_update:auto_update,
auto_update_time : auto_update_time,
subscribe_url: JSON.stringify(subscribe_url),
proxy: proxy
}
//console.log(data);
$.ajax({
type: "post",
url: SAVE_SUBSCRIBE_URL,
dataType: "json",
data: data,
success: function (d) {
if (d.error == 0) {
update_subscribe();
} else {
alert("请至少填写一个订阅链接");
type: "post",
url: "<%=luci.dispatcher.build_url('admin', 'vpn', 'shadowsocksr','subscribe')%>",
dataType : "json",
data: data,
success: function (d) {
if(d.error == 0){
//console.log("开始订阅");
update_subscribe();
}else{
alert("请至少填写一个订阅链接");
}
}
}
});
return false;
});
function get_realtime_log() {
$.ajax({
url: '/check_update.htm?v=' + parseInt(Math.random() * 100000000),
dataType: 'html',
error: function (xhr) {
setTimeout("get_realtime_log();", 1000);
},
success: function (response) {
var retArea = document.getElementById("log_content3");
if (response.search("END SUBSCRIBE") != -1) {
noChange++;
}
console.log(noChange);
if (noChange > 10) {
window.location.href = SERVERS_URL;
return false;
} else {
setTimeout("get_realtime_log();", 250);
}
retArea.value = response;
retArea.scrollTop = retArea.scrollHeight;
_responseLen = response.length;
},
error: function () {
setTimeout("get_realtime_log();", 500);
}
});
});
}
$("#update_subscribe").click(function(){
//console.log("提交数据");
submit_url();
return false;
});
function refresh_page(){
location.reload();
return false;
}
function get_realtime_log() {
$.ajax({
url: '/check_update.htm?v='+parseInt(Math.random() * 100000000),
dataType: 'html',
error: function (xhr) {
setTimeout("get_realtime_log();", 1000);
},
success: function (response) {
var retArea = document.getElementById("log_content3");
if (response.search("END SUBSCRIBE") != -1) {
noChange++;
}
console.log(noChange);
if (noChange > 10) {
window.location.href="<%=luci.dispatcher.build_url('admin', 'vpn', 'shadowsocksr','servers')%>"
return false;
} else {
setTimeout("get_realtime_log();", 250);
}
retArea.value = response;
retArea.scrollTop = retArea.scrollHeight;
_responseLen = response.length;
},
error: function () {
setTimeout("get_realtime_log();", 500);
}
});
}
//]]>
</script>
<%+cbi/valuefooter%>

View File

@ -11,6 +11,8 @@ msgstr "停用"
msgid "Enable Servers"
msgstr "开启服务"
msgid "Enable Authentication"
msgstr "启用 用户名/密码 认证"
msgid "Open v2ray split-flow"
msgstr "开启V2ray分流"

View File

@ -217,7 +217,7 @@ start_rules() {
local local_port=$(uci_get_by_name $GLOBAL_SERVER local_port)
local lan_ac_ips=$(uci_get_by_type access_control lan_ac_ips)
local lan_ac_mode=$(uci_get_by_type access_control lan_ac_mode)
local lan_ac_mode="b"
local router_proxy=$(uci_get_by_type access_control router_proxy)
if [ "$GLOBAL_SERVER" = "$UDP_RELAY_SERVER" -a $kcp_flag = 0 ]; then
ARG_UDP="-u"
@ -263,7 +263,6 @@ start_rules() {
-i "$(uci_get_by_type access_control wan_bp_list)" \
-b "$(uci_get_by_type access_control wan_bp_ips)" \
-w "$(uci_get_by_type access_control wan_fw_ips)" \
-B "$(uci_get_by_type access_control lan_bp_ips)" \
-p "$(uci_get_by_type access_control lan_fp_ips)" \
-G "$(uci_get_by_type access_control lan_gm_ips)" \
-D "$proxyport" \
@ -648,6 +647,8 @@ start_redir() {
sscmd="/usr/sbin/trojan"
elif [ "$stype" == "v2ray" ] ;then
sscmd="/usr/bin/v2ray/v2ray"
elif [ "$stype" == "socks5" ]; then
sscmd="/usr/bin/ipt2socks"
fi
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
@ -659,6 +660,8 @@ start_redir() {
ucmd="/usr/sbin/trojan"
elif [ "$utype" == "v2ray" ] ;then
ucmd="/usr/bin/v2ray/v2ray"
elif [ "$stype" == "socks5" ]; then
ucmd="/usr/bin/ipt2socks"
fi
if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then
@ -683,10 +686,20 @@ start_redir() {
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) $threads Threads Started!" >> /tmp/ssrplus.log
elif [ "$stype" == "v2ray" ] ;then
for i in $(seq 1 $threads); do
for i in $(seq 1 $threads); do
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
done
done
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) $threads Threads Started!" >> /tmp/ssrplus.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/ssrplus.log
fi
@ -710,6 +723,14 @@ start_redir() {
lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json
sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json
$ucmd -config /var/etc/v2-ssr-reudp.json >/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
@ -1103,6 +1124,7 @@ stop() {
killall -q -9 gq-client
killall -q -9 gq-server
killall -q -9 obfs-local
killall -q -9 ipt2socks
killall -q -9 obfs-server
killall -q -9 chinadns
killall -q -9 udp2raw
@ -1138,3 +1160,4 @@ stop() {
del_cron
}

View File

@ -26,7 +26,6 @@ usage() {
define access control mode
-b <wan_ips> wan ip of will be bypassed
-w <wan_ips> wan ip of will be forwarded
-B <bp_lan_ips> lan ip of will be bypassed proxy
-p <fp_lan_ips> lan ip of will be global proxy
-G <gm_lan_ips> lan ip of will be game mode proxy
-D <proxy_ports> proxy ports
@ -89,7 +88,7 @@ ipset_r() {
EOF
ipset -N gfwlist hash:net 2>/dev/null
$IPT -N SS_SPEC_WAN_AC
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
$IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
@ -100,7 +99,7 @@ EOF
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN
$IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW
$IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
elif [ "$RUNMODE" = "oversea" ] ;then
ipset -N oversea hash:net 2>/dev/null
@ -111,7 +110,7 @@ EOF
for ip in $LAN_GM_IP; do ipset -! add gmlan $ip ; done
$IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set --match-set china dst -j SS_SPEC_WAN_FW
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
elif [ "$RUNMODE" = "routers" ] ;then
ipset -! -R <<-EOF || return 1
@ -128,16 +127,14 @@ EOF
elif [ "$RUNMODE" = "all" ] ;then
$IPT -N SS_SPEC_WAN_AC
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
$IPT -I SS_SPEC_WAN_AC -p tcp ! --dport 53 -d $server -j RETURN
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
fi
ipset -N fplan hash:net 2>/dev/null
for ip in $LAN_FP_IP; do ipset -! add fplan $ip ; done
$IPT -I SS_SPEC_WAN_AC -m set --match-set fplan src -j SS_SPEC_WAN_FW
ipset -N bplan hash:net 2>/dev/null
for ip in $LAN_BP_IP; do ipset -! add bplan $ip; done
$IPT -I SS_SPEC_WAN_AC -m set --match-set bplan src -j RETURN
ipset -N whitelist hash:net 2>/dev/null
ipset -N blacklist hash:net 2>/dev/null
$IPT -I SS_SPEC_WAN_AC -m set --match-set blacklist src -j SS_SPEC_WAN_FW
@ -160,7 +157,6 @@ fw_rule() {
$IPT -A SS_SPEC_WAN_FW -d 224.0.0.0/4 -j RETURN
$IPT -A SS_SPEC_WAN_FW -d 240.0.0.0/4 -j RETURN
$IPT -A SS_SPEC_WAN_FW -p tcp $PROXY_PORTS \
$IPT -A SS_SPEC_WAN_FW -p tcp $PROXY_PORTS \
-j REDIRECT --to-ports $local_port 2>/dev/null || {
loger 3 "Can't redirect, please check the iptables."
exit 1
@ -221,8 +217,8 @@ tp_rule() {
$ipt -A SS_SPEC_TPROXY -p udp -d 192.168.0.0/16 -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp -d 224.0.0.0/4 -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp -d 240.0.0.0/4 -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp ! --dport 53 -d $server -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp -m set --match-set bplan src -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp -d $SERVER -j RETURN
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set fplan src \
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
@ -330,7 +326,7 @@ EOF
return 0
}
while getopts ":s:l:S:L:i:e:a:B:b:w:p:G:D:k:oOuUfgrRczh" arg; do
while getopts ":s:l:S:L:i:e:a:b:w:p:G:D:k:oOuUfgrRczh" arg; do
case "$arg" in
s)
server=$OPTARG
@ -353,11 +349,6 @@ while getopts ":s:l:S:L:i:e:a:B:b:w:p:G:D:k:oOuUfgrRczh" arg; do
a)
LAN_AC_IP=$OPTARG
;;
B)
LAN_BP_IP=$OPTARG
;;
b)
WAN_BP_IP=$(for ip in $OPTARG; do echo $ip; done)
;;