luci-app-passwall: bump to latest git HEAD
This commit is contained in:
parent
4b4766ff2f
commit
c9363ceabe
@ -1,76 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG=passwall
|
||||
CONFIG_PATH=/var/etc/$CONFIG
|
||||
|
||||
uci_get_by_name() {
|
||||
local ret=$(uci get $CONFIG.$1.$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $CONFIG.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
TCP_REDIR_SERVER=$(uci_get_by_type global tcp_redir_server nil)
|
||||
UDP_REDIR_SERVER=$(uci_get_by_type global udp_redir_server nil)
|
||||
[ "$UDP_REDIR_SERVER" == "default" ] && UDP_REDIR_SERVER=$TCP_REDIR_SERVER
|
||||
SOCKS5_PROXY_SERVER=$(uci_get_by_type global socks5_proxy_server nil)
|
||||
dns_mode=$(uci_get_by_type global dns_mode)
|
||||
use_haproxy=$(uci_get_by_type global_haproxy balancing_enable 0)
|
||||
haproxy_port=$(uci_get_by_type global_haproxy haproxy_port)
|
||||
use_kcp=$(uci_get_by_name $TCP_REDIR_SERVER use_kcp 0)
|
||||
kcp_port=$(uci_get_by_type global_proxy kcptun_port 11183)
|
||||
|
||||
#tcp
|
||||
if [ $TCP_REDIR_SERVER != "nil" ] ;then
|
||||
icount=`ps -w | grep -E "ss-redir|ssr-redir|v2ray" | grep $CONFIG_PATH/TCP.json | grep -v grep | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#udp
|
||||
if [ $UDP_REDIR_SERVER != "nil" ] ;then
|
||||
icount=`ps -w | grep -E "ss-redir|ssr-redir|v2ray" | grep $CONFIG_PATH/UDP.json | grep -v grep | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#socks5
|
||||
if [ $SOCKS5_PROXY_SERVER != "nil" ] ;then
|
||||
icount=`ps -w | grep -E "ss-redir|ssr-redir|v2ray" | grep $CONFIG_PATH/SOCKS5.json | grep -v grep | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#dns
|
||||
icount=`netstat -apn | grep 7913 | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#kcptun
|
||||
if [ $use_kcp -gt 0 ] ;then
|
||||
icount=`ps -w | grep kcptun_client | grep $kcp_port |grep -v grep | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#haproxy
|
||||
if [ $use_haproxy -gt 0 ] ;then
|
||||
icount=`ps -w | grep haproxy | grep $haproxy_port | grep -v grep | wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
@ -1,224 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG=passwall
|
||||
LOG_FILE=/var/log/$CONFIG.log
|
||||
url_main="https://raw.githubusercontent.com/hq450/fancyss/master/rules"
|
||||
SS_PATH=/usr/share/$CONFIG
|
||||
DNSMASQ_PATH=$SS_PATH/dnsmasq.d
|
||||
RULE_PATH=$SS_PATH/rule
|
||||
Date=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
update=$1
|
||||
gfwlist_update=0
|
||||
chnroute_update=0
|
||||
Pcap_Routing_update=0
|
||||
Pcap_WhiteList_update=0
|
||||
if [ -n "$update" ];then
|
||||
[ -n "$(echo $update | grep "gfwlist_update")" ] && gfwlist_update=1
|
||||
[ -n "$(echo $update | grep "chnroute_update")" ] && chnroute_update=1
|
||||
[ -n "$(echo $update | grep "Pcap_Routing_update")" ] && Pcap_Routing_update=1
|
||||
[ -n "$(echo $update | grep "Pcap_WhiteList_update")" ] && Pcap_WhiteList_update=1
|
||||
else
|
||||
gfwlist_update=`uci get $CONFIG.@global_rules[0].gfwlist_update`
|
||||
chnroute_update=`uci get $CONFIG.@global_rules[0].chnroute_update`
|
||||
Pcap_Routing_update=`uci get $CONFIG.@global_rules[0].Pcap_Routing_update`
|
||||
Pcap_WhiteList_update=`uci get $CONFIG.@global_rules[0].Pcap_WhiteList_update`
|
||||
fi
|
||||
|
||||
if [ "$gfwlist_update" == 0 -a "$chnroute_update" == 0 -a "$Pcap_Routing_update" == 0 -a "$Pcap_WhiteList_update" == 0 ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
# detect ss version
|
||||
#ss_basic_version_web1=`curl -s https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/shadowsocks/version | sed -n 1p`
|
||||
|
||||
# rule update
|
||||
echo $Date: 开始更新规则,请等待... > $LOG_FILE
|
||||
#wget -q --no-check-certificate --timeout=15 https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/version1 -O /tmp/version1
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/version1
|
||||
status1=`curl -w %{http_code} --connect-timeout 10 $url_main/version1 --silent -o /tmp/version1`
|
||||
if [ -z "$status1" ] || [ "$status1" == "404" ];then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
online_content=$(cat /tmp/version1 2>/dev/null)
|
||||
if [ -z "$online_content" ];then
|
||||
rm -rf /tmp/version1
|
||||
echo $Date: 没有检测到在线版本,可能是访问github有问题,去大陆白名单模式试试吧! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
|
||||
# update gfwlist
|
||||
if [ "$gfwlist_update" == 1 ];then
|
||||
gfwlist=$(cat /tmp/version1 | sed -n 1p)
|
||||
version_gfwlist2=$(echo $gfwlist | sed 's/ /\n/g'| sed -n 1p)
|
||||
md5sum_gfwlist2=$(echo $gfwlist | sed 's/ /\n/g'| tail -n 2 | head -n 1)
|
||||
local_md5sum_gfwlist=`md5sum $DNSMASQ_PATH/gfwlist.conf |awk '{print $1}'`
|
||||
if [ ! -z "$version_gfwlist2" ];then
|
||||
version_gfwlist1=$(uci_get_by_type global_rules gfwlist_version)
|
||||
if [ "$version_gfwlist1" != "$version_gfwlist2" -o "$md5sum_gfwlist2" != "$local_md5sum_gfwlist" ];then
|
||||
echo $Date: 检测到新版本gfwlist,开始更新... >> $LOG_FILE
|
||||
echo $Date: 下载gfwlist到临时文件... >> $LOG_FILE
|
||||
#wget --no-check-certificate --timeout=15 -q https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/gfwlist.conf -O /tmp/gfwlist.conf
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/gfwlist.conf
|
||||
status2=`curl -w %{http_code} --connect-timeout 10 $url_main/gfwlist.conf --silent -o /tmp/gfwlist.conf`
|
||||
if [ -z "$status2" ] || [ "$status2" == "404" ];then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_gfwlist1=$(md5sum /tmp/gfwlist.conf | sed 's/ /\n/g'| sed -n 1p)
|
||||
if [ "$md5sum_gfwlist1"x = "$md5sum_gfwlist2"x ];then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始gfwlist文件 >> $LOG_FILE
|
||||
mv /tmp/gfwlist.conf $DNSMASQ_PATH/gfwlist.conf
|
||||
uci set $CONFIG.@global_rules[0].gfwlist_version=$version_gfwlist2
|
||||
rm -rf /tmp/dnsmasq.d/gfwlist.conf
|
||||
reboot="1"
|
||||
echo $Date: 你的gfwlist已经更新到最新了哦~ >> $LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到gfwlist本地版本号和在线版本号相同,不用更新! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: gfwlist文件下载失败! >> $LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/gfwlist.conf
|
||||
fi
|
||||
|
||||
|
||||
# update chnroute
|
||||
if [ "$chnroute_update" == 1 ];then
|
||||
chnroute=$(cat /tmp/version1 | sed -n 2p)
|
||||
version_chnroute2=$(echo $chnroute | sed 's/ /\n/g'| sed -n 1p)
|
||||
md5sum_chnroute2=$(echo $chnroute | sed 's/ /\n/g'| tail -n 2 | head -n 1)
|
||||
local_md5sum_chnroute=`md5sum $RULE_PATH/chnroute |awk '{print $1}'`
|
||||
if [ ! -z "$version_chnroute2" ];then
|
||||
version_chnroute1=$(uci_get_by_type global_rules chnroute_version)
|
||||
if [ "$version_chnroute1" != "$version_chnroute2" -o "$md5sum_chnroute2" != "$local_md5sum_chnroute" ];then
|
||||
echo $Date: 检测到新版本chnroute,开始更新... >> $LOG_FILE
|
||||
echo $Date: 下载chnroute到临时文件... >> $LOG_FILE
|
||||
#wget --no-check-certificate --timeout=15 -q https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/chnroute.txt -O /tmp/chnroute
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/chnroute.txt
|
||||
status3=`curl -w %{http_code} --connect-timeout 10 $url_main/chnroute.txt --silent -o /tmp/chnroute`
|
||||
if [ -z "$status3" ] || [ "$status3" == "404" ];then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_chnroute1=$(md5sum /tmp/chnroute | sed 's/ /\n/g'| sed -n 1p)
|
||||
if [ "$md5sum_chnroute1"x = "$md5sum_chnroute2"x ];then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始chnroute文件 >> $LOG_FILE
|
||||
mv /tmp/chnroute $RULE_PATH/chnroute
|
||||
uci set $CONFIG.@global_rules[0].chnroute_version=$version_chnroute2
|
||||
ipset flush chnroute
|
||||
ipset destroy chnroute
|
||||
reboot="1"
|
||||
echo $Date: 你的chnroute已经更新到最新了哦~ >> $LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到chnroute本地版本号和在线版本号相同,不用更新! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: chnroute文件下载失败! >> $LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/chnroute
|
||||
fi
|
||||
|
||||
# update Routing
|
||||
if [ "$Pcap_Routing_update" == 1 ];then
|
||||
Routing=$(cat /tmp/version1 | sed -n 5p)
|
||||
version_Routing2=$(echo $Routing | sed 's/ /\n/g'| sed -n 1p)
|
||||
md5sum_Routing2=$(echo $Routing | sed 's/ /\n/g'| tail -n 2 | head -n 1)
|
||||
local_md5sum_Routing=`md5sum /etc/pcap-dnsproxy/Routing.txt |awk '{print $1}'`
|
||||
if [ ! -z "$version_Routing2" ];then
|
||||
version_Routing1=$(uci_get_by_type global_rules pcap_Routing_version)
|
||||
if [ "$version_Routing1" != "$version_Routing2" -o "$md5sum_Routing2" != "$local_md5sum_Routing" ];then
|
||||
echo $Date: 检测到新版本Routing,开始更新... >> $LOG_FILE
|
||||
echo $Date: 下载Routing到临时文件... >> $LOG_FILE
|
||||
status4=`curl -w %{http_code} --connect-timeout 10 $url_main/Routing.txt --silent -o /tmp/Routing.txt`
|
||||
if [ -z "$status4" ] || [ "$status4" == "404" ];then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_Routing1=$(md5sum /tmp/Routing.txt | sed 's/ /\n/g'| sed -n 1p)
|
||||
if [ "$md5sum_Routing1"x = "$md5sum_Routing2"x ];then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始Routing文件 >> $LOG_FILE
|
||||
mkdir -p /etc/pcap-dnsproxy
|
||||
mv /tmp/Routing.txt /etc/pcap-dnsproxy/Routing.txt
|
||||
uci set $CONFIG.@global_rules[0].pcap_Routing_version=$version_Routing2
|
||||
reboot="1"
|
||||
echo $Date: 你的Routing已经更新到最新了哦~ >> $LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到Routing本地版本号和在线版本号相同,不用更新! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: Routing文件下载失败! >> $LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/Routing.txt
|
||||
fi
|
||||
|
||||
# update WhiteList
|
||||
if [ "$Pcap_WhiteList_update" == 1 ];then
|
||||
WhiteList=$(cat /tmp/version1 | sed -n 7p)
|
||||
version_WhiteList2=$(echo $WhiteList | sed 's/ /\n/g'| sed -n 1p)
|
||||
md5sum_WhiteList2=$(echo $WhiteList | sed 's/ /\n/g'| tail -n 2 | head -n 1)
|
||||
local_md5sum_WhiteList=`md5sum /etc/pcap-dnsproxy/WhiteList.txt |awk '{print $1}'`
|
||||
if [ ! -z "$version_WhiteList2" ];then
|
||||
version_WhiteList1=$(uci_get_by_type global_rules pcap_WhiteList_version)
|
||||
if [ "$version_WhiteList1" != "$version_WhiteList2" -o "$md5sum_WhiteList2" != "$local_md5sum_WhiteList" ];then
|
||||
echo $Date: 检测到新版本WhiteList,开始更新... >> $LOG_FILE
|
||||
echo $Date: 下载WhiteList到临时文件... >> $LOG_FILE
|
||||
status4=`curl -w %{http_code} --connect-timeout 10 $url_main/WhiteList_new.txt --silent -o /tmp/WhiteList.txt`
|
||||
if [ -z "$status4" ] || [ "$status4" == "404" ];then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >> $LOG_FILE
|
||||
exit
|
||||
fi
|
||||
#wget --no-check-certificate --timeout=10 -qO - $url_main/WhiteList_new.txt > /tmp/WhiteList.txt
|
||||
md5sum_WhiteList1=$(md5sum /tmp/WhiteList.txt | sed 's/ /\n/g'| sed -n 1p)
|
||||
if [ "$md5sum_WhiteList1"x = "$md5sum_WhiteList2"x ];then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始WhiteList文件 >> $LOG_FILE
|
||||
mkdir -p /etc/pcap-dnsproxy
|
||||
mv /tmp/WhiteList.txt /etc/pcap-dnsproxy/WhiteList.txt
|
||||
uci set $CONFIG.@global_rules[0].pcap_WhiteList_version=$version_WhiteList2
|
||||
reboot="1"
|
||||
echo $Date: 你的WhiteList已经更新到最新了哦~ >> $LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到WhiteList本地版本号和在线版本号相同,不用更新! >> $LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: WhiteList文件下载失败! >> $LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/WhiteList.txt
|
||||
fi
|
||||
|
||||
echo $Date: 更新进程运行完毕! >> $LOG_FILE
|
||||
rm -rf /tmp/version1
|
||||
# write number
|
||||
uci set $CONFIG.@global_rules[0].gfwlist_update=$gfwlist_update
|
||||
uci set $CONFIG.@global_rules[0].chnroute_update=$chnroute_update
|
||||
uci set $CONFIG.@global_rules[0].Pcap_Routing_update=$Pcap_Routing_update
|
||||
uci set $CONFIG.@global_rules[0].Pcap_WhiteList_update=$Pcap_WhiteList_update
|
||||
uci commit
|
||||
# reboot ss
|
||||
if [ "$reboot" == "1" ];then
|
||||
echo $Date: 重启软件,以应用新的规则文件!请稍后! >> $LOG_FILE
|
||||
/etc/init.d/$CONFIG restart
|
||||
fi
|
||||
exit
|
||||
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=80-20190824
|
||||
PKG_RELEASE:=86-20191024
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PO2LMO:=./po2lmo
|
||||
@ -107,10 +107,10 @@ end
|
||||
|
||||
function get_log()
|
||||
-- luci.sys.exec("[ -f /var/log/passwall.log ] && sed '1!G;h;$!d' /var/log/passwall.log > /var/log/passwall_show.log")
|
||||
luci.http.write(luci.sys.exec("cat /var/log/passwall.log"))
|
||||
luci.http.write(luci.sys.exec("[ -f '/var/log/passwall.log' ] && cat /var/log/passwall.log"))
|
||||
end
|
||||
|
||||
function clear_log() luci.sys.call("rm -rf > /var/log/passwall.log") end
|
||||
function clear_log() luci.sys.call("echo '' > /var/log/passwall.log") end
|
||||
|
||||
function server_status()
|
||||
local tcp_redir_port = luci.sys.exec(
|
||||
@ -14,7 +14,47 @@ local function has_udp_relay()
|
||||
end
|
||||
-%>
|
||||
|
||||
<fieldset id="_ss_status_fieldset" class="cbi-section">
|
||||
<style>
|
||||
/* @media screen and (min-width: 1600px) {
|
||||
#_passwall_status_fieldset > fieldset {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#_passwall_status_fieldset > fieldset > div {
|
||||
width: 200px;
|
||||
height: 60px;
|
||||
background: #f7fafd;
|
||||
float: left;
|
||||
margin: 5px;
|
||||
padding: 0.3rem 1rem;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
clear: unset;
|
||||
}
|
||||
|
||||
#_passwall_status_fieldset > fieldset > div > .cbi-value-title {
|
||||
text-align: left;
|
||||
width: unset;
|
||||
padding-top: unset;
|
||||
}
|
||||
|
||||
#_passwall_status_fieldset > fieldset > div > .cbi-value-field {
|
||||
padding-top: unset;
|
||||
}
|
||||
|
||||
#_passwall_status_fieldset > fieldset > div > .cbi-value-field > font {
|
||||
padding-top: unset;
|
||||
}
|
||||
|
||||
#_server_status > font {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
*/
|
||||
</style>
|
||||
|
||||
<fieldset id="_passwall_status_fieldset" class="cbi-section">
|
||||
<legend>
|
||||
<%:Running Status%>
|
||||
</legend>
|
||||
@ -97,8 +137,8 @@ end
|
||||
</label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="button" class="cbi-button cbi-input-apply" value="<%:Check%>" onclick="return check_port(this)" />
|
||||
<input id="clear_check_port_btn" type="button" class="cbi-button cbi-button-remove" style="display:none" value="<%:Clear%>" onclick="return clear_check_port(this)" />
|
||||
<font id="_server_status"></font>
|
||||
<input id="clear_check_port_btn" type="button" class="cbi-button cbi-button-remove" style="display:none" value="<%:Clear%>" onclick="return clear_check_port(this)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
@ -148,16 +188,18 @@ end
|
||||
var s = document.getElementById('_' + type + '_status');
|
||||
if(s) {
|
||||
if(rv.status) {
|
||||
s.setAttribute("color","green");
|
||||
s.innerHTML = '<%:Working...%> ✓';
|
||||
//s.setAttribute("color","green");
|
||||
btn.setAttribute("style","background-color: green !important; border-color: green !important;");
|
||||
btn.value = '<%:Working...%> ✓';
|
||||
}
|
||||
else {
|
||||
s.setAttribute("color","red");
|
||||
s.innerHTML = '<%:Problem detected!%> X';
|
||||
//s.setAttribute("color","red");
|
||||
btn.setAttribute("style","background-color:red !important; border-color: red !important;");
|
||||
btn.value = '<%:Problem detected!%> X';
|
||||
}
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Check%>';
|
||||
//btn.value = '<%:Check%>';
|
||||
}
|
||||
);
|
||||
return false;
|
||||
@ -1,6 +1,6 @@
|
||||
<%
|
||||
local brook_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].brook_client_file`")
|
||||
local brook_version = luci.sys.exec(brook_path.." -v | awk '{print $3}'")
|
||||
local brook_version = luci.sys.exec("[ -f '" .. brook_path .. "' ] && " .. brook_path .. " -v | awk '{print $3}'")
|
||||
local dsp = require "luci.dispatcher"
|
||||
-%>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<%
|
||||
local kcptun_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].kcptun_client_file`")
|
||||
local kcptun_version = luci.sys.exec(kcptun_path.." -v | awk '{print $3}'")
|
||||
local kcptun_version = luci.sys.exec("[ -f '" .. kcptun_path .. "' ] && " .. kcptun_path .. " -v | awk '{print $3}'")
|
||||
local dsp = require "luci.dispatcher"
|
||||
-%>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<%
|
||||
local V2ray_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].v2ray_client_file`")
|
||||
local V2ray_version = luci.sys.exec(V2ray_path.."/v2ray -version | awk '{print $2}' | sed -n 1P")
|
||||
local V2ray_version = luci.sys.exec("[ -f '" .. V2ray_path .. "/v2ray' ] && " .. V2ray_path .. "/v2ray -version | awk '{print $2}' | sed -n 1P")
|
||||
local dsp = require "luci.dispatcher"
|
||||
-%>
|
||||
|
||||
0
package/Lienol/luci-app-passwall/po2lmo → package/lienol/luci-app-passwall/po2lmo
Executable file → Normal file
0
package/Lienol/luci-app-passwall/po2lmo → package/lienol/luci-app-passwall/po2lmo
Executable file → Normal file
@ -45,11 +45,11 @@ config global_other
|
||||
config global_rules
|
||||
option gfwlist_update '1'
|
||||
option chnroute_update '1'
|
||||
option Pcap_Routing_update '1'
|
||||
option Pcap_WhiteList_update '1'
|
||||
option Pcap_Routing_update '0'
|
||||
option Pcap_WhiteList_update '0'
|
||||
option auto_update '0'
|
||||
option gfwlist_version '2019-08-14'
|
||||
option chnroute_version '2019-08-14'
|
||||
option gfwlist_version '2019-10-18'
|
||||
option chnroute_version '2019-10-18'
|
||||
|
||||
config global_app
|
||||
option v2ray_client_file '/usr/bin/v2ray/'
|
||||
0
package/Lienol/luci-app-passwall/root/etc/init.d/passwall → package/lienol/luci-app-passwall/root/etc/init.d/passwall
Executable file → Normal file
0
package/Lienol/luci-app-passwall/root/etc/init.d/passwall → package/lienol/luci-app-passwall/root/etc/init.d/passwall
Executable file → Normal file
768
package/Lienol/luci-app-passwall/root/usr/share/passwall/app.sh → package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh
Executable file → Normal file
768
package/Lienol/luci-app-passwall/root/usr/share/passwall/app.sh → package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
IPSET_LANIPLIST="laniplist"
|
||||
IPSET_VPSIPLIST="vpsiplist"
|
||||
IPSET_ROUTER="router"
|
||||
IPSET_ROUTER="router"
|
||||
IPSET_GFW="gfwlist"
|
||||
IPSET_CHN="chnroute"
|
||||
IPSET_BLACKLIST="blacklist"
|
||||
@ -12,7 +12,7 @@ iptables_nat="iptables -t nat"
|
||||
iptables_mangle="iptables -t mangle"
|
||||
ip6tables_nat="ip6tables -t nat"
|
||||
|
||||
factor(){
|
||||
factor() {
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo ""
|
||||
else
|
||||
@ -20,18 +20,18 @@ factor(){
|
||||
fi
|
||||
}
|
||||
|
||||
get_jump_mode(){
|
||||
get_jump_mode() {
|
||||
case "$1" in
|
||||
disable)
|
||||
echo "j"
|
||||
disable)
|
||||
echo "j"
|
||||
;;
|
||||
*)
|
||||
echo "g"
|
||||
*)
|
||||
echo "g"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_ip_mark(){
|
||||
get_ip_mark() {
|
||||
if [ -z "$1" ]; then
|
||||
echo ""
|
||||
else
|
||||
@ -41,46 +41,46 @@ get_ip_mark(){
|
||||
|
||||
get_action_chain() {
|
||||
case "$1" in
|
||||
disable)
|
||||
echo "RETURN"
|
||||
disable)
|
||||
echo "RETURN"
|
||||
;;
|
||||
global)
|
||||
echo "SS_GLO"
|
||||
global)
|
||||
echo "SS_GLO"
|
||||
;;
|
||||
gfwlist)
|
||||
echo "SS_GFW"
|
||||
gfwlist)
|
||||
echo "SS_GFW"
|
||||
;;
|
||||
chnroute)
|
||||
echo "SS_CHN"
|
||||
chnroute)
|
||||
echo "SS_CHN"
|
||||
;;
|
||||
gamemode)
|
||||
echo "SS_GAME"
|
||||
gamemode)
|
||||
echo "SS_GAME"
|
||||
;;
|
||||
returnhome)
|
||||
echo "SS_HOME"
|
||||
returnhome)
|
||||
echo "SS_HOME"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_action_chain_name() {
|
||||
case "$1" in
|
||||
disable)
|
||||
echo "不代理"
|
||||
disable)
|
||||
echo "不代理"
|
||||
;;
|
||||
global)
|
||||
echo "全局"
|
||||
global)
|
||||
echo "全局"
|
||||
;;
|
||||
gfwlist)
|
||||
echo "GFW"
|
||||
gfwlist)
|
||||
echo "GFW"
|
||||
;;
|
||||
chnroute)
|
||||
echo "大陆白名单"
|
||||
chnroute)
|
||||
echo "大陆白名单"
|
||||
;;
|
||||
gamemode)
|
||||
echo "游戏"
|
||||
gamemode)
|
||||
echo "游戏"
|
||||
;;
|
||||
returnhome)
|
||||
echo "回国"
|
||||
returnhome)
|
||||
echo "回国"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@ -96,10 +96,10 @@ gen_laniplist() {
|
||||
192.168.0.0/16
|
||||
224.0.0.0/4
|
||||
240.0.0.0/4
|
||||
EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
load_acl(){
|
||||
load_acl() {
|
||||
local enabled
|
||||
local aclremarks
|
||||
local ipaddr
|
||||
@ -121,60 +121,60 @@ load_acl(){
|
||||
[ -z "$proxy_mode" -o "$proxy_mode" = "default" ] && proxy_mode=$PROXY_MODE
|
||||
[ -z "$tcp_redir_ports" -o "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ -z "$udp_redir_ports" -o "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
local ip_mark=`get_ip_mark $ipaddr`
|
||||
local ip_mark=$(get_ip_mark $ipaddr)
|
||||
[ "$enabled" == "1" -a -n "$proxy_mode" ] && {
|
||||
if [ -n "$ipaddr" ] || [ -n "$macaddr" ]; then
|
||||
if [ -n "$ipaddr" -a -n "$macaddr" ]; then
|
||||
echolog "访问控制:IP:$ipaddr,MAC:$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
echolog "访问控制:IP:$ipaddr,MAC:$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
else
|
||||
[ -n "$ipaddr" ] && echolog "访问控制:IP:$ipaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
[ -n "$macaddr" ] && echolog "访问控制:MAC:$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
[ -n "$ipaddr" ] && echolog "访问控制:IP:$ipaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
[ -n "$macaddr" ] && echolog "访问控制:MAC:$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
|
||||
fi
|
||||
[ "$tcp_redir_server" != "nil" ] && {
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TTL --ttl-set 14$tcp_redir_server
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TTL --ttl-set 14$tcp_redir_server
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p tcp $(factor $macaddr "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") -m comment --comment "$aclremarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$tcp_redir_server
|
||||
}
|
||||
[ "$udp_redir_server" != "nil" ] && {
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p udp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TPROXY --on-port 104$udp_redir_server --tproxy-mark 0x1/0x1
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p udp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TPROXY --on-port 104$udp_redir_server --tproxy-mark 0x1/0x1
|
||||
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p udp $(factor $macaddr "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") -m comment --comment "$aclremarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$udp_redir_server
|
||||
}
|
||||
[ -z "$ipaddr" ] && {
|
||||
lower_macaddr=`echo $macaddr | tr '[A-Z]' '[a-z]'`
|
||||
ipaddr=`ip neigh show | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $lower_macaddr | awk '{print $1}'`
|
||||
lower_macaddr=$(echo $macaddr | tr '[A-Z]' '[a-z]')
|
||||
ipaddr=$(ip neigh show | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $lower_macaddr | awk '{print $1}')
|
||||
[ -z "$ipaddr" ] && {
|
||||
dhcp_index=`uci show dhcp | grep $lower_macaddr |awk -F'.' '{print $2}'`
|
||||
ipaddr=`uci -q get dhcp.$dhcp_index.ip`
|
||||
dhcp_index=$(uci show dhcp | grep $lower_macaddr | awk -F'.' '{print $2}')
|
||||
ipaddr=$(uci -q get dhcp.$dhcp_index.ip)
|
||||
}
|
||||
[ -z "$ipaddr" ] && ipaddr=`cat /tmp/dhcp.leases | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" |grep $lower_macaddr |awk '{print $3}'`
|
||||
[ -z "$ipaddr" ] && ipaddr=$(cat /tmp/dhcp.leases | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep $lower_macaddr | awk '{print $3}')
|
||||
}
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
filter_vpsip(){
|
||||
filter_vpsip() {
|
||||
local server_host server_ip use_ipv6 network_type
|
||||
server_host=$(config_get $1 server)
|
||||
use_ipv6=$(config_get $1 use_ipv6)
|
||||
network_type="ipv4"
|
||||
[ "$use_ipv6" == "1" ] && network_type="ipv6"
|
||||
server_ip=$(get_host_ip $network_type $server_host)
|
||||
|
||||
|
||||
[ -n "$server_ip" -a "$server_ip" != "$TCP_REDIR_SERVER_IP" ] && {
|
||||
[ "$network_type" == "ipv4" ] && ipset add $IPSET_VPSIPLIST $server_ip >/dev/null 2>&1 &
|
||||
}
|
||||
}
|
||||
|
||||
dns_hijack(){
|
||||
dns_hijack() {
|
||||
dnshijack=$(config_t_get global_dns dns_53)
|
||||
if [ "$dnshijack" = "1" -o "$1" = "force" ];then
|
||||
chromecast_nu=`$iptables_nat -L SS -v -n --line-numbers|grep "dpt:53"|awk '{print $1}'`
|
||||
is_right_lanip=`$iptables_nat -L SS -v -n --line-numbers|grep "dpt:53" |grep "$lanip"`
|
||||
if [ "$dnshijack" = "1" -o "$1" = "force" ]; then
|
||||
chromecast_nu=$($iptables_nat -L SS -v -n --line-numbers | grep "dpt:53" | awk '{print $1}')
|
||||
is_right_lanip=$($iptables_nat -L SS -v -n --line-numbers | grep "dpt:53" | grep "$lanip")
|
||||
if [ -z "$chromecast_nu" ]; then
|
||||
echolog "添加接管局域网DNS解析规则..."
|
||||
echolog "添加接管局域网DNS解析规则..."
|
||||
$iptables_nat -I SS -i br-lan -p udp --dport 53 -j DNAT --to $lanip 2>/dev/null
|
||||
else
|
||||
if [ -z "$is_right_lanip" ]; then
|
||||
echolog "添加接管局域网DNS解析规则..."
|
||||
echolog "添加接管局域网DNS解析规则..."
|
||||
$iptables_nat -D SS $chromecast_nu >/dev/null 2>&1 &
|
||||
$iptables_nat -I SS -i br-lan -p udp --dport 53 -j DNAT --to $lanip 2>/dev/null
|
||||
else
|
||||
@ -185,8 +185,8 @@ dns_hijack(){
|
||||
}
|
||||
|
||||
add_firewall_rule() {
|
||||
echolog "开始加载防火墙规则..."
|
||||
echolog "默认代理模式:$(get_action_chain_name $PROXY_MODE)"
|
||||
echolog "开始加载防火墙规则..."
|
||||
echolog "默认代理模式:$(get_action_chain_name $PROXY_MODE)"
|
||||
ipset -! create $IPSET_LANIPLIST nethash && ipset flush $IPSET_LANIPLIST
|
||||
ipset -! create $IPSET_VPSIPLIST nethash && ipset flush $IPSET_VPSIPLIST
|
||||
ipset -! create $IPSET_ROUTER nethash && ipset flush $IPSET_ROUTER
|
||||
@ -194,58 +194,55 @@ add_firewall_rule() {
|
||||
ipset -! create $IPSET_CHN nethash && ipset flush $IPSET_CHN
|
||||
ipset -! create $IPSET_BLACKLIST nethash && ipset flush $IPSET_BLACKLIST
|
||||
ipset -! create $IPSET_WHITELIST nethash && ipset flush $IPSET_WHITELIST
|
||||
|
||||
|
||||
sed -e "s/^/add $IPSET_CHN &/g" $APP_PATH_RULE/chnroute | awk '{print $0} END{print "COMMIT"}' | ipset -R
|
||||
sed -e "s/^/add $IPSET_BLACKLIST &/g" $APP_PATH_RULE/blacklist_ip | awk '{print $0} END{print "COMMIT"}' | ipset -R
|
||||
sed -e "s/^/add $IPSET_WHITELIST &/g" $APP_PATH_RULE/whitelist_ip | awk '{print $0} END{print "COMMIT"}' | ipset -R
|
||||
|
||||
|
||||
ipset -! -R <<-EOF || return 1
|
||||
$(gen_laniplist | sed -e "s/^/add $IPSET_LANIPLIST /")
|
||||
EOF
|
||||
|
||||
ISP_DNS=`cat /tmp/resolv.conf.auto 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort -u |grep -v 0.0.0.0 |grep -v 127.0.0.1`
|
||||
$(gen_laniplist | sed -e "s/^/add $IPSET_LANIPLIST /")
|
||||
EOF
|
||||
|
||||
ISP_DNS=$(cat /tmp/resolv.conf.auto 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort -u | grep -v 0.0.0.0 | grep -v 127.0.0.1)
|
||||
[ -n "$ISP_DNS" ] && {
|
||||
for ispip in $ISP_DNS
|
||||
do
|
||||
for ispip in $ISP_DNS; do
|
||||
ipset -! add $IPSET_WHITELIST $ispip >/dev/null 2>&1 &
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# 忽略特殊IP段
|
||||
lan_ip=`ifconfig br-lan | grep "inet addr" | awk '{print $2}' | awk -F : '{print $2}'` #路由器lan IP
|
||||
lan_ipv4=`ip address show br-lan | grep -w "inet" |awk '{print $2}'` #当前LAN IPv4段
|
||||
lan_ip=$(ifconfig br-lan | grep "inet addr" | awk '{print $2}' | awk -F : '{print $2}') #路由器lan IP
|
||||
lan_ipv4=$(ip address show br-lan | grep -w "inet" | awk '{print $2}') #当前LAN IPv4段
|
||||
[ -n "$lan_ipv4" ] && ipset add $IPSET_LANIPLIST $lan_ipv4 >/dev/null 2>&1 &
|
||||
|
||||
|
||||
# 过滤所有节点IP
|
||||
config_foreach filter_vpsip "servers"
|
||||
|
||||
|
||||
$iptables_mangle -N SS
|
||||
$iptables_mangle -A SS -m set --match-set $IPSET_LANIPLIST dst -j RETURN
|
||||
$iptables_mangle -A SS -m set --match-set $IPSET_VPSIPLIST dst -j RETURN
|
||||
$iptables_mangle -A SS -m set --match-set $IPSET_WHITELIST dst -j RETURN
|
||||
$iptables_mangle -N SS_ACL
|
||||
|
||||
if [[ "$TCP_REDIR_SERVER_NUM" -ge 1 ]] || [[ "$UDP_REDIR_SERVER_NUM" -ge 1 ]] ;then
|
||||
|
||||
if [[ "$TCP_REDIR_SERVER_NUM" -ge 1 ]] || [[ "$UDP_REDIR_SERVER_NUM" -ge 1 ]]; then
|
||||
local max_num=1
|
||||
[ "$TCP_REDIR_SERVER_NUM" -ge "$UDP_REDIR_SERVER_NUM" ] && max_num=$TCP_REDIR_SERVER_NUM
|
||||
if [ "$max_num" -ge 1 ] ;then
|
||||
for i in $(seq 1 $max_num)
|
||||
do
|
||||
if [ "$max_num" -ge 1 ]; then
|
||||
for i in $(seq 1 $max_num); do
|
||||
$iptables_mangle -N SS_GLO$i
|
||||
$iptables_mangle -N SS_GFW$i
|
||||
$iptables_mangle -N SS_CHN$i
|
||||
$iptables_mangle -N SS_HOME$i
|
||||
$iptables_mangle -N SS_GAME$i
|
||||
|
||||
|
||||
ip rule add fwmark 1 lookup 100
|
||||
ip route add local 0.0.0.0/0 dev lo table 100
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$TCP_REDIR_SERVER_NUM" -ge 1 ] ;then
|
||||
for i in $(seq 1 $TCP_REDIR_SERVER_NUM)
|
||||
do
|
||||
|
||||
if [ "$TCP_REDIR_SERVER_NUM" -ge 1 ]; then
|
||||
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
|
||||
local k=$i
|
||||
local local_port=104$k
|
||||
local ttl=14$k
|
||||
@ -256,7 +253,7 @@ EOF
|
||||
temp_server=$TCP_REDIR_SERVER
|
||||
}
|
||||
# 生成TCP转发规则
|
||||
if [ "$temp_server" != "nil" ];then
|
||||
if [ "$temp_server" != "nil" ]; then
|
||||
local server_host=$(config_get $temp_server server)
|
||||
local TCP_REDIR_SERVER_PORT=$(config_get $temp_server server_port)
|
||||
local TCP_REDIR_SERVER_IP=$(get_host_ip "ipv4" $server_host)
|
||||
@ -265,25 +262,25 @@ EOF
|
||||
if [ "$TCP_REDIR_SERVER_TYPE" == "brook" ]; then
|
||||
$iptables_mangle -A PREROUTING -p tcp -m socket -j MARK --set-mark 1
|
||||
$iptables_mangle -A PREROUTING -p tcp -j SS$k
|
||||
|
||||
|
||||
$iptables_mangle -A SS$k -p tcp -m set --match-set $IPSET_BLACKLIST dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
# 全局模式
|
||||
$iptables_mangle -A SS_GLO$k -p tcp -j TPROXY --tproxy-mark 0x1/0x1 --on-port $local_port
|
||||
|
||||
|
||||
# GFWLIST模式
|
||||
$iptables_mangle -A SS_GFW$k -p tcp -m set --match-set $IPSET_GFW dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
$iptables_mangle -A SS_GFW$k -p tcp -m set --match-set $IPSET_ROUTER dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 大陆白名单模式
|
||||
$iptables_mangle -A SS_CHN$k -p tcp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
$iptables_mangle -A SS_CHN$k -p tcp -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 回国模式
|
||||
$iptables_mangle -A SS_HOME$k -p tcp -m set --match-set $IPSET_CHN dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 游戏模式
|
||||
$iptables_mangle -A SS_GAME$k -p tcp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
|
||||
|
||||
# 用于本机流量转发,默认只走router
|
||||
$iptables_mangle -A SS$k -s $lan_ip -p tcp -m set --match-set $IPSET_ROUTER dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
$iptables_mangle -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_ROUTER dst -j MARK --set-mark 1
|
||||
@ -291,47 +288,47 @@ EOF
|
||||
#$iptables_mangle -I SS_ACL 1 -p tcp -m set --match-set $IPSET_BLACKLIST dst -j TTL --ttl-set $ttl
|
||||
# 全局模式
|
||||
$iptables_mangle -A SS_GLO$k -p tcp -j TTL --ttl-set $ttl
|
||||
|
||||
|
||||
# GFWLIST模式
|
||||
$iptables_mangle -A SS_GFW$k -p tcp -m set --match-set $IPSET_GFW dst -j TTL --ttl-set $ttl
|
||||
$iptables_mangle -A SS_GFW$k -p tcp -m set --match-set $IPSET_ROUTER dst -j TTL --ttl-set $ttl
|
||||
|
||||
|
||||
# 大陆白名单模式
|
||||
$iptables_mangle -A SS_CHN$k -p tcp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
#$iptables_mangle -A SS_CHN$k -p tcp -m geoip ! --destination-country CN -j TTL --ttl-set $ttl
|
||||
$iptables_mangle -A SS_CHN$k -p tcp -j TTL --ttl-set $ttl
|
||||
|
||||
|
||||
# 回国模式
|
||||
#$iptables_mangle -A SS_HOME$k -p tcp -m geoip --destination-country CN -j TTL --ttl-set $ttl
|
||||
$iptables_mangle -A SS_HOME$k -p tcp -m set --match-set $IPSET_CHN dst -j TTL --ttl-set $ttl
|
||||
|
||||
|
||||
# 游戏模式
|
||||
$iptables_mangle -A SS_GAME$k -p tcp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
|
||||
|
||||
[ "$k" == 1 ] && {
|
||||
$iptables_nat -N SS
|
||||
|
||||
|
||||
is_add_prerouting=0
|
||||
|
||||
KP_INDEX=`$iptables_nat -L PREROUTING|tail -n +3|sed -n -e '/^KOOLPROXY/='`
|
||||
|
||||
KP_INDEX=$($iptables_nat -L PREROUTING | tail -n +3 | sed -n -e '/^KOOLPROXY/=')
|
||||
if [ -n "$KP_INDEX" ]; then
|
||||
let KP_INDEX+=1
|
||||
#确保添加到KOOLPROXY规则之后
|
||||
$iptables_nat -I PREROUTING $KP_INDEX -j SS
|
||||
is_add_prerouting=1
|
||||
fi
|
||||
|
||||
ADBYBY_INDEX=`$iptables_nat -L PREROUTING|tail -n +3|sed -n -e '/^ADBYBY/='`
|
||||
|
||||
ADBYBY_INDEX=$($iptables_nat -L PREROUTING | tail -n +3 | sed -n -e '/^ADBYBY/=')
|
||||
if [ -n "$ADBYBY_INDEX" ]; then
|
||||
let ADBYBY_INDEX+=1
|
||||
#确保添加到ADBYBY规则之后
|
||||
$iptables_nat -I PREROUTING $ADBYBY_INDEX -j SS
|
||||
is_add_prerouting=1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$is_add_prerouting" == 0 ]; then
|
||||
#如果去广告没有运行,确保添加到prerouting_rule规则之后
|
||||
PR_INDEX=`$iptables_nat -L PREROUTING|tail -n +3|sed -n -e '/^prerouting_rule/='`
|
||||
PR_INDEX=$($iptables_nat -L PREROUTING | tail -n +3 | sed -n -e '/^prerouting_rule/=')
|
||||
if [ -z "$PR_INDEX" ]; then
|
||||
PR_INDEX=1
|
||||
else
|
||||
@ -341,32 +338,30 @@ EOF
|
||||
fi
|
||||
# 用于本机流量转发,默认只走router
|
||||
#$iptables_nat -I OUTPUT -j SS
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_LANIPLIST dst -j RETURN
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_VPSIPLIST dst -j RETURN
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_WHITELIST dst -j RETURN
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_ROUTER dst -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_BLACKLIST dst -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
|
||||
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_GFW dst -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_LANIPLIST dst -m comment --comment "PassWall" -j RETURN
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_VPSIPLIST dst -m comment --comment "PassWall" -j RETURN
|
||||
$iptables_nat -A OUTPUT -m set --match-set $IPSET_WHITELIST dst -m comment --comment "PassWall" -j RETURN
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_ROUTER dst -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
|
||||
[ "$LOCALHOST_PROXY_MODE" == "global" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
[ "$LOCALHOST_PROXY_MODE" == "gfwlist" ] && $iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_GFW dst -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
[ "$LOCALHOST_PROXY_MODE" == "chnroute" ] && {
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set ! --match-set $IPSET_CHN dst -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT
|
||||
}
|
||||
}
|
||||
# 重定所有流量到透明代理端口
|
||||
$iptables_nat -A SS -p tcp -m ttl --ttl-eq $ttl -j REDIRECT --to $local_port
|
||||
echolog "IPv4 防火墙TCP转发规则加载完成!"
|
||||
echolog "IPv4 防火墙TCP转发规则加载完成!"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
echolog "主服务器未选择,无法转发TCP!"
|
||||
echolog "主服务器未选择,无法转发TCP!"
|
||||
fi
|
||||
|
||||
if [ "$UDP_REDIR_SERVER_NUM" -ge 1 ] ;then
|
||||
for i in $(seq 1 $UDP_REDIR_SERVER_NUM)
|
||||
do
|
||||
|
||||
if [ "$UDP_REDIR_SERVER_NUM" -ge 1 ]; then
|
||||
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
|
||||
local k=$i
|
||||
local local_port=104$k
|
||||
local ttl=14$k
|
||||
@ -377,7 +372,7 @@ EOF
|
||||
temp_server=$UDP_REDIR_SERVER
|
||||
}
|
||||
# 生成UDP转发规则
|
||||
if [ "$temp_server" != "nil" ];then
|
||||
if [ "$temp_server" != "nil" ]; then
|
||||
local server_host=$(config_get $temp_server server)
|
||||
local UDP_REDIR_SERVER_PORT=$(config_get $temp_server server_port)
|
||||
local UDP_REDIR_SERVER_IP=$(get_host_ip "ipv4" $server_host)
|
||||
@ -389,43 +384,42 @@ EOF
|
||||
#$iptables_mangle -I SS_ACL$k 1 -p udp -m set --match-set $IPSET_BLACKLIST dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
# 全局模式
|
||||
$iptables_mangle -A SS_GLO$k -p udp -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# GFWLIST模式
|
||||
$iptables_mangle -A SS_GFW$k -p udp -m set --match-set $IPSET_GFW dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
$iptables_mangle -A SS_GFW$k -p udp -m set --match-set $IPSET_ROUTER dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 大陆白名单模式
|
||||
$iptables_mangle -A SS_CHN$k -p udp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
$iptables_mangle -A SS_CHN$k -p udp -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 回国模式
|
||||
$iptables_mangle -A SS_HOME$k -p udp -m set --match-set $IPSET_CHN dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
# 游戏模式
|
||||
$iptables_mangle -A SS_GAME$k -p udp -m set --match-set $IPSET_CHN dst -j RETURN
|
||||
$iptables_mangle -A SS_GAME$k -p udp -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
|
||||
|
||||
|
||||
echolog "IPv4 防火墙UDP转发规则加载完成!"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echolog "UDP服务器未选择,无法转发UDP!"
|
||||
echolog "UDP服务器未选择,无法转发UDP!"
|
||||
fi
|
||||
|
||||
|
||||
$iptables_mangle -A PREROUTING -j SS
|
||||
$iptables_mangle -A SS -j SS_ACL
|
||||
|
||||
|
||||
local max_num=1
|
||||
[ "$TCP_REDIR_SERVER_NUM" -ge "$UDP_REDIR_SERVER_NUM" ] && max_num=$TCP_REDIR_SERVER_NUM
|
||||
if [ "$max_num" -ge 1 ] ;then
|
||||
for i in $(seq 1 $max_num)
|
||||
do
|
||||
if [ "$max_num" -ge 1 ]; then
|
||||
for i in $(seq 1 $max_num); do
|
||||
local k=$i
|
||||
# 加载ACLS
|
||||
[ "$k" == 1 ] && config_foreach load_acl "acl_rule"
|
||||
|
||||
|
||||
# 加载默认代理模式
|
||||
if [ "$PROXY_MODE" == "disable" ];then
|
||||
if [ "$PROXY_MODE" == "disable" ]; then
|
||||
[ "$TCP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p tcp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
|
||||
[ "$UDP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p udp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
|
||||
else
|
||||
@ -433,15 +427,14 @@ EOF
|
||||
[ "$TCP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p tcp -m multiport --dport $TCP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)$k
|
||||
[ "$UDP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p udp -m multiport --dport $UDP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)$k
|
||||
fi
|
||||
|
||||
if [ "$PROXY_IPV6" == "1" ];then
|
||||
lan_ipv6=`ip address show br-lan | grep -w "inet6" |awk '{print $2}'` #当前LAN IPv6段
|
||||
|
||||
if [ "$PROXY_IPV6" == "1" ]; then
|
||||
lan_ipv6=$(ip address show br-lan | grep -w "inet6" | awk '{print $2}') #当前LAN IPv6段
|
||||
$ip6tables_nat -N SS
|
||||
$ip6tables_nat -N SS_ACL
|
||||
$ip6tables_nat -A PREROUTING -j SS
|
||||
[ -n "$lan_ipv6" ] && {
|
||||
for ip in $lan_ipv6
|
||||
do
|
||||
for ip in $lan_ipv6; do
|
||||
$ip6tables_nat -A SS -d $ip -j RETURN
|
||||
done
|
||||
}
|
||||
@ -453,7 +446,7 @@ EOF
|
||||
$ip6tables_nat -A SS_GLO$k -p tcp -j REDIRECT --to $TCP_REDIR_PORT
|
||||
$ip6tables_nat -A SS -j SS_GLO$k
|
||||
#$ip6tables_nat -I OUTPUT -p tcp -j SS
|
||||
echolog "IPv6防火墙规则加载完成!"
|
||||
echolog "IPv6防火墙规则加载完成!"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -461,79 +454,73 @@ EOF
|
||||
|
||||
del_firewall_rule() {
|
||||
echolog "删除所有防火墙规则..."
|
||||
ipv4_output_exist=`$iptables_nat -L OUTPUT 2>/dev/null | grep -c -E "SS|$TCP_REDIR_PORTS|$IPSET_LANIPLIST|$IPSET_VPSIPLIST|$IPSET_WHITELIST|$IPSET_ROUTER|$IPSET_BLACKLIST|$IPSET_GFW|$IPSET_CHN"`
|
||||
ipv4_output_exist=$($iptables_nat -L OUTPUT 2>/dev/null | grep -c -E "PassWall")
|
||||
[ -n "$ipv4_output_exist" ] && {
|
||||
until [ "$ipv4_output_exist" = 0 ]
|
||||
do
|
||||
rules=`$iptables_nat -L OUTPUT --line-numbers | grep -E "SS|$TCP_REDIR_PORTS|$IPSET_LANIPLIST|$IPSET_VPSIPLIST|$IPSET_WHITELIST|$IPSET_ROUTER|$IPSET_BLACKLIST|$IPSET_GFW|$IPSET_CHN" | awk '{print $1}'`
|
||||
for rule in $rules
|
||||
do
|
||||
$iptables_nat -D OUTPUT $rule 2> /dev/null
|
||||
until [ "$ipv4_output_exist" = 0 ]; do
|
||||
rules=$($iptables_nat -L OUTPUT --line-numbers | grep -E "PassWall" | awk '{print $1}')
|
||||
for rule in $rules; do
|
||||
$iptables_nat -D OUTPUT $rule 2>/dev/null
|
||||
break
|
||||
done
|
||||
ipv4_output_exist=`expr $ipv4_output_exist - 1`
|
||||
ipv4_output_exist=$(expr $ipv4_output_exist - 1)
|
||||
done
|
||||
}
|
||||
|
||||
ipv6_output_ss_exist=`$ip6tables_nat -L OUTPUT 2>/dev/null | grep -c "SS"`
|
||||
|
||||
ipv6_output_ss_exist=$($ip6tables_nat -L OUTPUT 2>/dev/null | grep -c "SS")
|
||||
[ -n "$ipv6_output_ss_exist" ] && {
|
||||
until [ "$ipv6_output_ss_exist" = 0 ]
|
||||
do
|
||||
rules=`$ip6tables_nat -L OUTPUT --line-numbers | grep "SS" | awk '{print $1}'`
|
||||
for rule in $rules
|
||||
do
|
||||
$ip6tables_nat -D OUTPUT $rule 2> /dev/null
|
||||
until [ "$ipv6_output_ss_exist" = 0 ]; do
|
||||
rules=$($ip6tables_nat -L OUTPUT --line-numbers | grep "SS" | awk '{print $1}')
|
||||
for rule in $rules; do
|
||||
$ip6tables_nat -D OUTPUT $rule 2>/dev/null
|
||||
break
|
||||
done
|
||||
ipv6_output_ss_exist=`expr $ipv6_output_ss_exist - 1`
|
||||
ipv6_output_ss_exist=$(expr $ipv6_output_ss_exist - 1)
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
$iptables_mangle -D PREROUTING -p tcp -m socket -j MARK --set-mark 1 2>/dev/null
|
||||
$iptables_mangle -D PREROUTING -p udp -m socket -j MARK --set-mark 1 2>/dev/null
|
||||
$iptables_mangle -D OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_ROUTER dst -j MARK --set-mark 1 2>/dev/null
|
||||
$iptables_mangle -D OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_GFW dst -j MARK --set-mark 1 2>/dev/null
|
||||
$iptables_mangle -D OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -j MARK --set-mark 1 2>/dev/null
|
||||
|
||||
$iptables_nat -D PREROUTING -j SS 2> /dev/null
|
||||
|
||||
$iptables_nat -D PREROUTING -j SS 2>/dev/null
|
||||
$iptables_nat -F SS 2>/dev/null && $iptables_nat -X SS 2>/dev/null
|
||||
$iptables_mangle -D PREROUTING -j SS$k 2>/dev/null
|
||||
$iptables_mangle -F SS 2>/dev/null && $iptables_mangle -X SS 2>/dev/null
|
||||
$iptables_mangle -F SS_ACL 2>/dev/null && $iptables_mangle -X SS_ACL 2>/dev/null
|
||||
|
||||
|
||||
$ip6tables_nat -D PREROUTING -j SS 2>/dev/null
|
||||
$ip6tables_nat -F SS 2>/dev/null && $ip6tables_nat -X SS 2>/dev/null
|
||||
$ip6tables_nat -F SS_ACL 2>/dev/null && $ip6tables_nat -X SS_ACL 2>/dev/null
|
||||
|
||||
|
||||
local max_num=1
|
||||
[ "$TCP_REDIR_SERVER_NUM" -ge "$UDP_REDIR_SERVER_NUM" ] && max_num=$TCP_REDIR_SERVER_NUM
|
||||
if [ "$max_num" -ge 1 ] ;then
|
||||
for i in $(seq 1 $max_num)
|
||||
do
|
||||
if [ "$max_num" -ge 1 ]; then
|
||||
for i in $(seq 1 $max_num); do
|
||||
local k=$i
|
||||
$iptables_mangle -F SS_GLO$k 2>/dev/null && $iptables_mangle -X SS_GLO$k 2>/dev/null
|
||||
$iptables_mangle -F SS_GFW$k 2>/dev/null && $iptables_mangle -X SS_GFW$k 2>/dev/null
|
||||
$iptables_mangle -F SS_CHN$k 2>/dev/null && $iptables_mangle -X SS_CHN$k 2>/dev/null
|
||||
$iptables_mangle -F SS_GAME$k 2>/dev/null && $iptables_mangle -X SS_GAME$k 2>/dev/null
|
||||
$iptables_mangle -F SS_HOME$k 2>/dev/null && $iptables_mangle -X SS_HOME$k 2>/dev/null
|
||||
|
||||
|
||||
$ip6tables_nat -F SS_GLO$k 2>/dev/null && $ip6tables_nat -X SS_GLO$k 2>/dev/null
|
||||
$ip6tables_nat -F SS_GFW$k 2>/dev/null && $ip6tables_nat -X SS_GFW$k 2>/dev/null
|
||||
$ip6tables_nat -F SS_CHN$k 2>/dev/null && $ip6tables_nat -X SS_CHN$k 2>/dev/null
|
||||
$ip6tables_nat -F SS_HOME$k 2>/dev/null && $ip6tables_nat -X SS_HOME$k 2>/dev/null
|
||||
|
||||
ip_rule_exist=`ip rule show | grep "from all fwmark 0x1 lookup 100" | grep -c 100`
|
||||
if [ ! -z "$ip_rule_exist" ];then
|
||||
until [ "$ip_rule_exist" = 0 ]
|
||||
do
|
||||
|
||||
ip_rule_exist=$(ip rule show | grep "from all fwmark 0x1 lookup 100" | grep -c 100)
|
||||
if [ ! -z "$ip_rule_exist" ]; then
|
||||
until [ "$ip_rule_exist" = 0 ]; do
|
||||
ip rule del fwmark 1 lookup 100
|
||||
ip_rule_exist=`expr $ip_rule_exist - 1`
|
||||
ip_rule_exist=$(expr $ip_rule_exist - 1)
|
||||
done
|
||||
fi
|
||||
ip route del local 0.0.0.0/0 dev lo table 100 2>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
ipset -F $IPSET_ROUTER >/dev/null 2>&1 && ipset -X $IPSET_ROUTER >/dev/null 2>&1 &
|
||||
ipset -F $IPSET_GFW >/dev/null 2>&1 && ipset -X $IPSET_GFW >/dev/null 2>&1 &
|
||||
#ipset -F $IPSET_CHN >/dev/null 2>&1 && ipset -X $IPSET_CHN >/dev/null 2>&1 &
|
||||
@ -543,12 +530,12 @@ del_firewall_rule() {
|
||||
ipset -F $IPSET_LANIPLIST >/dev/null 2>&1 && ipset -X $IPSET_LANIPLIST >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
start(){
|
||||
start() {
|
||||
add_firewall_rule
|
||||
dns_hijack
|
||||
}
|
||||
|
||||
stop(){
|
||||
stop() {
|
||||
del_firewall_rule
|
||||
}
|
||||
|
||||
@ -559,5 +546,5 @@ stop)
|
||||
start)
|
||||
start
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
*) ;;
|
||||
esac
|
||||
@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG=passwall
|
||||
CONFIG_PATH=/var/etc/$CONFIG
|
||||
|
||||
uci_get_by_name() {
|
||||
local ret=$(uci get $CONFIG.$1.$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $CONFIG.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
TCP_REDIR_SERVER=$(uci_get_by_type global tcp_redir_server nil)
|
||||
TCP_REDIR_PORT=$(uci_get_by_type global_proxy tcp_redir_port nil)
|
||||
UDP_REDIR_SERVER=$(uci_get_by_type global udp_redir_server nil)
|
||||
UDP_REDIR_PORT=$(uci_get_by_type global_proxy udp_redir_port nil)
|
||||
[ "$UDP_REDIR_SERVER" == "default" ] && UDP_REDIR_SERVER=$TCP_REDIR_SERVER
|
||||
SOCKS5_PROXY_SERVER=$(uci_get_by_type global socks5_proxy_server nil)
|
||||
dns_mode=$(uci_get_by_type global dns_mode)
|
||||
use_haproxy=$(uci_get_by_type global_haproxy balancing_enable 0)
|
||||
use_kcp=$(uci_get_by_name $TCP_REDIR_SERVER use_kcp 0)
|
||||
kcp_port=$(uci_get_by_type global_proxy kcptun_port 11183)
|
||||
|
||||
#tcp
|
||||
if [ $TCP_REDIR_SERVER != "nil" ]; then
|
||||
icount=$(ps -w | grep -i -E "ss-redir|ssr-redir|v2ray|brook tproxy -l 0.0.0.0:$TCP_REDIR_PORT" | grep $CONFIG_PATH/TCP.json | grep -v grep | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#udp
|
||||
if [ $UDP_REDIR_SERVER != "nil" ]; then
|
||||
icount=$(ps -w | grep -i -E "ss-redir|ssr-redir|v2ray|brook tproxy -l 0.0.0.0:$UDP_REDIR_PORT" | grep $CONFIG_PATH/UDP.json | grep -v grep | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#socks5
|
||||
if [ $SOCKS5_PROXY_SERVER != "nil" ]; then
|
||||
icount=$(ps -w | grep -i -E "ss-redir|ssr-redir|v2ray|brook client" | grep $CONFIG_PATH/SOCKS5.json | grep -v grep | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#dns
|
||||
icount=$(netstat -apn | grep 7913 | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#kcptun
|
||||
if [ $use_kcp -gt 0 ]; then
|
||||
icount=$(ps -w | grep kcptun_client | grep $kcp_port | grep -v grep | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#haproxy
|
||||
if [ $use_haproxy -gt 0 ]; then
|
||||
icount=$(ps -w | grep haproxy | grep $CONFIG_PATH/haproxy.cfg | grep -v grep | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
@ -1,3 +1,4 @@
|
||||
formyip.com
|
||||
myepisodecalendar.com
|
||||
subhd.com
|
||||
subhd.com
|
||||
msi.com
|
||||
@ -71,12 +71,9 @@
|
||||
1.202.0.0/15
|
||||
1.204.0.0/14
|
||||
8.128.0.0/10
|
||||
8.208.64.0/18
|
||||
8.209.0.0/21
|
||||
8.209.8.0/23
|
||||
8.209.12.0/22
|
||||
8.209.16.0/20
|
||||
8.209.32.0/19
|
||||
8.209.36.0/22
|
||||
8.209.40.0/21
|
||||
8.209.48.0/20
|
||||
8.209.128.0/17
|
||||
8.210.0.0/15
|
||||
8.212.0.0/14
|
||||
@ -102,7 +99,6 @@
|
||||
14.208.0.0/12
|
||||
20.134.160.0/20
|
||||
20.139.160.0/20
|
||||
23.48.214.0/24
|
||||
27.0.128.0/21
|
||||
27.0.160.0/21
|
||||
27.0.188.0/22
|
||||
@ -313,7 +309,6 @@
|
||||
43.224.44.0/22
|
||||
43.224.52.0/22
|
||||
43.224.56.0/22
|
||||
43.224.64.0/24
|
||||
43.224.68.0/22
|
||||
43.224.72.0/22
|
||||
43.224.80.0/22
|
||||
@ -573,12 +568,12 @@
|
||||
43.255.224.0/21
|
||||
43.255.232.0/22
|
||||
43.255.244.0/22
|
||||
45.12.227.0/24
|
||||
45.40.192.0/20
|
||||
45.40.208.0/21
|
||||
45.40.224.0/19
|
||||
45.65.16.0/20
|
||||
45.94.120.0/22
|
||||
45.85.196.0/22
|
||||
45.88.101.0/24
|
||||
45.112.132.0/22
|
||||
45.112.188.0/22
|
||||
45.112.208.0/22
|
||||
@ -600,7 +595,6 @@
|
||||
45.113.252.0/22
|
||||
45.114.0.0/22
|
||||
45.114.32.0/22
|
||||
45.114.40.0/22
|
||||
45.114.52.0/22
|
||||
45.114.96.0/22
|
||||
45.114.136.0/22
|
||||
@ -712,7 +706,11 @@
|
||||
45.127.128.0/22
|
||||
45.127.144.0/21
|
||||
45.127.156.0/22
|
||||
45.133.148.0/22
|
||||
45.136.44.0/24
|
||||
45.136.46.0/24
|
||||
45.136.180.0/22
|
||||
45.138.160.0/22
|
||||
45.248.8.0/22
|
||||
45.248.80.0/22
|
||||
45.248.88.0/22
|
||||
@ -785,7 +783,9 @@
|
||||
45.253.136.0/21
|
||||
45.253.144.0/20
|
||||
45.253.160.0/19
|
||||
45.253.192.0/18
|
||||
45.253.192.0/19
|
||||
45.253.224.0/20
|
||||
45.253.240.0/22
|
||||
45.254.0.0/20
|
||||
45.254.16.0/21
|
||||
45.254.28.0/22
|
||||
@ -1316,7 +1316,6 @@
|
||||
103.42.76.0/22
|
||||
103.42.232.0/22
|
||||
103.43.26.0/23
|
||||
103.43.86.0/23
|
||||
103.43.96.0/21
|
||||
103.43.104.0/22
|
||||
103.43.124.0/22
|
||||
@ -1326,7 +1325,6 @@
|
||||
103.43.220.0/22
|
||||
103.43.224.0/22
|
||||
103.43.240.0/22
|
||||
103.44.56.0/24
|
||||
103.44.58.0/23
|
||||
103.44.80.0/22
|
||||
103.44.120.0/21
|
||||
@ -1465,7 +1463,7 @@
|
||||
103.60.164.0/22
|
||||
103.60.228.0/22
|
||||
103.60.236.0/22
|
||||
103.61.60.0/22
|
||||
103.61.60.0/24
|
||||
103.61.104.0/22
|
||||
103.61.140.0/22
|
||||
103.61.152.0/21
|
||||
@ -1557,7 +1555,8 @@
|
||||
103.72.16.0/20
|
||||
103.72.32.0/20
|
||||
103.72.48.0/21
|
||||
103.72.112.0/20
|
||||
103.72.112.0/21
|
||||
103.72.124.0/22
|
||||
103.72.128.0/21
|
||||
103.72.149.0/24
|
||||
103.72.150.0/23
|
||||
@ -1945,8 +1944,6 @@
|
||||
103.118.72.0/22
|
||||
103.118.88.0/22
|
||||
103.118.173.0/24
|
||||
103.119.104.0/23
|
||||
103.119.106.0/24
|
||||
103.119.115.0/24
|
||||
103.119.156.0/22
|
||||
103.119.180.0/22
|
||||
@ -1988,7 +1985,7 @@
|
||||
103.125.196.0/22
|
||||
103.125.236.0/22
|
||||
103.126.0.0/22
|
||||
103.126.16.0/22
|
||||
103.126.16.0/23
|
||||
103.126.44.0/22
|
||||
103.126.124.0/22
|
||||
103.126.128.0/22
|
||||
@ -2015,8 +2012,6 @@
|
||||
103.133.12.0/22
|
||||
103.133.40.0/22
|
||||
103.133.128.0/22
|
||||
103.133.136.0/23
|
||||
103.133.138.0/24
|
||||
103.133.232.0/22
|
||||
103.134.196.0/22
|
||||
103.135.80.0/22
|
||||
@ -2037,7 +2032,6 @@
|
||||
103.137.180.0/22
|
||||
103.137.236.0/22
|
||||
103.138.2.0/23
|
||||
103.138.13.0/24
|
||||
103.138.81.0/24
|
||||
103.138.82.0/23
|
||||
103.138.134.0/23
|
||||
@ -2055,15 +2049,35 @@
|
||||
103.140.70.0/23
|
||||
103.140.140.0/23
|
||||
103.140.144.0/23
|
||||
103.140.152.0/23
|
||||
103.140.192.0/23
|
||||
103.140.228.0/23
|
||||
103.141.10.0/23
|
||||
103.141.58.0/23
|
||||
103.141.128.0/23
|
||||
103.141.186.0/23
|
||||
103.141.190.0/23
|
||||
103.141.242.0/23
|
||||
103.142.0.0/23
|
||||
103.142.28.0/23
|
||||
103.142.58.0/23
|
||||
103.142.82.0/23
|
||||
103.142.96.0/23
|
||||
103.142.122.0/23
|
||||
103.142.128.0/23
|
||||
103.142.140.0/24
|
||||
103.142.154.0/23
|
||||
103.142.156.0/23
|
||||
103.142.180.0/23
|
||||
103.142.186.0/23
|
||||
103.142.190.0/23
|
||||
103.142.220.0/23
|
||||
103.142.230.0/24
|
||||
103.142.234.0/23
|
||||
103.142.238.0/23
|
||||
103.143.16.0/22
|
||||
103.143.31.0/24
|
||||
103.143.74.0/23
|
||||
103.143.174.0/23
|
||||
103.143.228.0/23
|
||||
103.192.0.0/19
|
||||
103.192.48.0/21
|
||||
103.192.56.0/22
|
||||
@ -2229,7 +2243,6 @@
|
||||
103.212.164.0/22
|
||||
103.212.196.0/22
|
||||
103.212.200.0/22
|
||||
103.212.230.0/23
|
||||
103.212.252.0/22
|
||||
103.213.40.0/21
|
||||
103.213.48.0/20
|
||||
@ -2299,9 +2312,8 @@
|
||||
103.220.200.0/22
|
||||
103.220.240.0/20
|
||||
103.221.0.0/19
|
||||
103.221.32.0/20
|
||||
103.221.48.0/22
|
||||
103.221.88.0/21
|
||||
103.221.32.0/22
|
||||
103.221.88.0/22
|
||||
103.221.96.0/19
|
||||
103.221.128.0/18
|
||||
103.221.192.0/20
|
||||
@ -2391,7 +2403,6 @@
|
||||
103.231.244.0/22
|
||||
103.232.4.0/22
|
||||
103.232.144.0/22
|
||||
103.232.213.0/24
|
||||
103.233.4.0/22
|
||||
103.233.44.0/22
|
||||
103.233.52.0/22
|
||||
@ -2922,7 +2933,13 @@
|
||||
116.196.16.0/20
|
||||
116.196.32.0/19
|
||||
116.196.64.0/18
|
||||
116.196.128.0/17
|
||||
116.196.128.0/18
|
||||
116.196.192.0/21
|
||||
116.196.200.0/23
|
||||
116.196.203.0/24
|
||||
116.196.204.0/22
|
||||
116.196.208.0/20
|
||||
116.196.224.0/19
|
||||
116.197.160.0/21
|
||||
116.197.180.0/23
|
||||
116.198.0.0/16
|
||||
@ -3005,7 +3022,6 @@
|
||||
117.128.0.0/10
|
||||
118.24.0.0/15
|
||||
118.26.0.0/19
|
||||
118.26.34.0/23
|
||||
118.26.36.0/22
|
||||
118.26.40.0/21
|
||||
118.26.48.0/20
|
||||
@ -3071,7 +3087,10 @@
|
||||
118.191.24.0/21
|
||||
118.191.32.0/19
|
||||
118.191.64.0/18
|
||||
118.191.144.0/20
|
||||
118.191.144.0/21
|
||||
118.191.153.0/24
|
||||
118.191.154.0/23
|
||||
118.191.156.0/22
|
||||
118.191.160.0/19
|
||||
118.191.192.0/20
|
||||
118.191.209.0/24
|
||||
@ -3228,21 +3247,13 @@
|
||||
120.90.0.0/15
|
||||
120.92.0.0/17
|
||||
120.92.128.0/18
|
||||
120.92.194.0/23
|
||||
120.92.192.0/22
|
||||
120.92.198.0/23
|
||||
120.92.200.0/21
|
||||
120.92.208.0/20
|
||||
120.92.224.0/19
|
||||
120.94.0.0/15
|
||||
120.128.0.0/14
|
||||
120.132.0.0/17
|
||||
120.132.128.0/18
|
||||
120.132.192.0/19
|
||||
120.132.224.0/21
|
||||
120.132.232.0/22
|
||||
120.132.240.0/20
|
||||
120.133.0.0/16
|
||||
120.134.0.0/15
|
||||
120.128.0.0/13
|
||||
120.136.16.0/21
|
||||
120.136.128.0/18
|
||||
120.137.0.0/17
|
||||
@ -3361,7 +3372,6 @@
|
||||
123.0.160.0/19
|
||||
123.4.0.0/14
|
||||
123.8.0.0/13
|
||||
123.49.129.0/24
|
||||
123.49.130.0/23
|
||||
123.49.132.0/22
|
||||
123.49.136.0/22
|
||||
@ -3454,7 +3464,24 @@
|
||||
124.108.8.0/21
|
||||
124.108.40.0/21
|
||||
124.109.96.0/21
|
||||
124.112.0.0/13
|
||||
124.112.0.0/14
|
||||
124.116.0.0/15
|
||||
124.118.0.0/16
|
||||
124.119.0.0/17
|
||||
124.119.128.0/18
|
||||
124.119.192.0/19
|
||||
124.119.224.0/20
|
||||
124.119.240.0/22
|
||||
124.119.244.0/23
|
||||
124.119.246.0/25
|
||||
124.119.246.128/26
|
||||
124.119.246.192/27
|
||||
124.119.246.224/28
|
||||
124.119.246.240/29
|
||||
124.119.246.248/30
|
||||
124.119.246.254/31
|
||||
124.119.247.0/24
|
||||
124.119.248.0/21
|
||||
124.126.0.0/15
|
||||
124.128.0.0/13
|
||||
124.147.128.0/17
|
||||
@ -3474,12 +3501,7 @@
|
||||
124.243.192.0/18
|
||||
124.248.0.0/17
|
||||
124.249.0.0/16
|
||||
124.250.0.0/17
|
||||
124.250.136.0/21
|
||||
124.250.144.0/20
|
||||
124.250.160.0/19
|
||||
124.250.192.0/18
|
||||
124.251.0.0/16
|
||||
124.250.0.0/15
|
||||
124.254.0.0/18
|
||||
125.31.192.0/18
|
||||
125.32.0.0/12
|
||||
@ -3510,15 +3532,10 @@
|
||||
129.204.0.0/16
|
||||
129.211.0.0/16
|
||||
129.223.254.0/24
|
||||
129.227.0.0/20
|
||||
129.227.32.0/19
|
||||
129.227.64.0/18
|
||||
129.227.128.0/23
|
||||
129.227.132.0/22
|
||||
129.227.136.0/21
|
||||
129.227.144.0/20
|
||||
129.227.160.0/19
|
||||
129.227.192.0/18
|
||||
129.227.98.0/23
|
||||
129.227.100.0/22
|
||||
129.227.104.0/21
|
||||
129.227.112.0/20
|
||||
130.214.218.0/23
|
||||
131.228.96.0/24
|
||||
131.253.12.0/29
|
||||
@ -3657,6 +3674,7 @@
|
||||
150.129.192.0/22
|
||||
150.129.252.0/22
|
||||
150.138.0.0/15
|
||||
150.158.0.0/16
|
||||
150.222.88.0/23
|
||||
150.223.0.0/16
|
||||
150.242.0.0/21
|
||||
@ -3683,10 +3701,11 @@
|
||||
150.242.248.0/22
|
||||
150.255.0.0/16
|
||||
152.32.178.0/23
|
||||
152.32.205.0/24
|
||||
152.32.206.0/23
|
||||
152.32.208.0/20
|
||||
152.32.224.0/19
|
||||
152.32.225.0/24
|
||||
152.32.226.0/23
|
||||
152.32.228.0/22
|
||||
152.32.232.0/21
|
||||
152.32.240.0/20
|
||||
152.104.128.0/17
|
||||
152.136.0.0/16
|
||||
153.0.0.0/16
|
||||
@ -3697,6 +3716,7 @@
|
||||
153.101.0.0/16
|
||||
153.118.0.0/15
|
||||
154.8.128.0/17
|
||||
155.126.176.0/23
|
||||
156.107.160.0/24
|
||||
156.107.170.0/24
|
||||
156.154.62.0/23
|
||||
@ -3771,6 +3791,7 @@
|
||||
163.179.0.0/16
|
||||
163.204.0.0/16
|
||||
163.244.246.0/24
|
||||
164.52.80.0/24
|
||||
165.156.30.0/24
|
||||
166.111.0.0/16
|
||||
167.139.0.0/16
|
||||
@ -3786,6 +3807,7 @@
|
||||
170.225.224.0/23
|
||||
170.252.152.0/21
|
||||
171.8.0.0/13
|
||||
171.22.147.0/24
|
||||
171.34.0.0/15
|
||||
171.36.0.0/14
|
||||
171.40.0.0/13
|
||||
@ -3794,6 +3816,7 @@
|
||||
171.112.0.0/12
|
||||
171.208.0.0/12
|
||||
172.81.192.0/18
|
||||
173.39.200.0/23
|
||||
175.0.0.0/12
|
||||
175.16.0.0/13
|
||||
175.24.0.0/14
|
||||
@ -3868,7 +3891,12 @@
|
||||
180.210.236.0/22
|
||||
180.212.0.0/15
|
||||
180.222.224.0/19
|
||||
180.223.0.0/18
|
||||
180.223.0.0/19
|
||||
180.223.32.0/20
|
||||
180.223.48.0/21
|
||||
180.223.57.0/24
|
||||
180.223.58.0/23
|
||||
180.223.60.0/22
|
||||
180.223.80.0/20
|
||||
180.223.96.0/19
|
||||
180.223.128.0/17
|
||||
@ -3934,6 +3962,9 @@
|
||||
183.184.0.0/13
|
||||
183.192.0.0/10
|
||||
185.109.236.0/24
|
||||
185.203.36.0/22
|
||||
185.223.134.0/23
|
||||
185.224.116.0/22
|
||||
188.131.128.0/17
|
||||
192.11.23.0/24
|
||||
192.11.26.0/24
|
||||
@ -3957,6 +3988,7 @@
|
||||
192.144.128.0/17
|
||||
192.163.11.0/24
|
||||
192.232.97.0/24
|
||||
193.17.120.0/22
|
||||
193.20.64.0/22
|
||||
193.112.0.0/16
|
||||
194.138.136.0/24
|
||||
@ -4085,6 +4117,7 @@
|
||||
202.27.12.0/24
|
||||
202.27.14.0/24
|
||||
202.27.136.0/23
|
||||
202.30.124.0/24
|
||||
202.36.226.0/24
|
||||
202.38.0.0/22
|
||||
202.38.8.0/21
|
||||
@ -4225,7 +4258,6 @@
|
||||
202.84.24.0/21
|
||||
202.85.208.0/20
|
||||
202.86.249.0/24
|
||||
202.86.252.0/22
|
||||
202.87.80.0/20
|
||||
202.88.32.0/22
|
||||
202.89.8.0/21
|
||||
@ -4349,8 +4381,7 @@
|
||||
202.162.75.0/24
|
||||
202.164.0.0/20
|
||||
202.164.96.0/19
|
||||
202.165.96.0/21
|
||||
202.165.104.0/22
|
||||
202.165.96.0/22
|
||||
202.165.176.0/20
|
||||
202.165.208.0/20
|
||||
202.165.239.0/24
|
||||
@ -4732,7 +4763,9 @@
|
||||
203.20.122.0/24
|
||||
203.20.126.0/23
|
||||
203.20.135.0/24
|
||||
203.20.136.0/21
|
||||
203.20.137.0/24
|
||||
203.20.138.0/23
|
||||
203.20.140.0/22
|
||||
203.20.150.0/24
|
||||
203.20.230.0/24
|
||||
203.20.232.0/24
|
||||
@ -5567,12 +5600,10 @@
|
||||
220.242.124.0/23
|
||||
220.242.126.0/24
|
||||
220.242.173.0/24
|
||||
220.242.196.0/23
|
||||
220.242.197.0/24
|
||||
220.242.205.0/24
|
||||
220.242.206.0/23
|
||||
220.242.209.0/24
|
||||
220.242.210.0/23
|
||||
220.242.212.0/22
|
||||
220.242.214.0/23
|
||||
220.242.216.0/21
|
||||
220.242.224.0/19
|
||||
220.243.0.0/17
|
||||
@ -5,3 +5,4 @@ github-production-release-asset-2e65be.s3.amazonaws.com
|
||||
openwrt.proxy.ustclug.org
|
||||
easylist-downloads.adblockplus.org
|
||||
adblockplus.org
|
||||
caddyserver.com
|
||||
@ -0,0 +1,223 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG=passwall
|
||||
LOG_FILE=/var/log/$CONFIG.log
|
||||
url_main="https://raw.githubusercontent.com/hq450/fancyss/master/rules"
|
||||
SS_PATH=/usr/share/$CONFIG
|
||||
DNSMASQ_PATH=$SS_PATH/dnsmasq.d
|
||||
RULE_PATH=$SS_PATH/rule
|
||||
Date=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
update=$1
|
||||
gfwlist_update=0
|
||||
chnroute_update=0
|
||||
Pcap_Routing_update=0
|
||||
Pcap_WhiteList_update=0
|
||||
if [ -n "$update" ]; then
|
||||
[ -n "$(echo $update | grep "gfwlist_update")" ] && gfwlist_update=1
|
||||
[ -n "$(echo $update | grep "chnroute_update")" ] && chnroute_update=1
|
||||
[ -n "$(echo $update | grep "Pcap_Routing_update")" ] && Pcap_Routing_update=1
|
||||
[ -n "$(echo $update | grep "Pcap_WhiteList_update")" ] && Pcap_WhiteList_update=1
|
||||
else
|
||||
gfwlist_update=$(uci get $CONFIG.@global_rules[0].gfwlist_update)
|
||||
chnroute_update=$(uci get $CONFIG.@global_rules[0].chnroute_update)
|
||||
Pcap_Routing_update=$(uci get $CONFIG.@global_rules[0].Pcap_Routing_update)
|
||||
Pcap_WhiteList_update=$(uci get $CONFIG.@global_rules[0].Pcap_WhiteList_update)
|
||||
fi
|
||||
|
||||
if [ "$gfwlist_update" == 0 -a "$chnroute_update" == 0 -a "$Pcap_Routing_update" == 0 -a "$Pcap_WhiteList_update" == 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
# detect ss version
|
||||
#ss_basic_version_web1=`curl -s https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/shadowsocks/version | sed -n 1p`
|
||||
|
||||
# rule update
|
||||
echo $Date: 开始更新规则,请等待... >$LOG_FILE
|
||||
#wget -q --no-check-certificate --timeout=15 https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/version1 -O /tmp/version1
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/version1
|
||||
status1=$(curl -w %{http_code} --connect-timeout 10 $url_main/version1 --silent -o /tmp/version1)
|
||||
if [ -z "$status1" ] || [ "$status1" == "404" ]; then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
online_content=$(cat /tmp/version1 2>/dev/null)
|
||||
if [ -z "$online_content" ]; then
|
||||
rm -rf /tmp/version1
|
||||
echo $Date: 没有检测到在线版本,可能是访问github有问题,去大陆白名单模式试试吧! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
|
||||
# update gfwlist
|
||||
if [ "$gfwlist_update" == 1 ]; then
|
||||
gfwlist=$(cat /tmp/version1 | sed -n 1p)
|
||||
version_gfwlist2=$(echo $gfwlist | sed 's/ /\n/g' | sed -n 1p)
|
||||
md5sum_gfwlist2=$(echo $gfwlist | sed 's/ /\n/g' | tail -n 2 | head -n 1)
|
||||
local_md5sum_gfwlist=$(md5sum $DNSMASQ_PATH/gfwlist.conf | awk '{print $1}')
|
||||
if [ ! -z "$version_gfwlist2" ]; then
|
||||
version_gfwlist1=$(uci_get_by_type global_rules gfwlist_version)
|
||||
if [ "$version_gfwlist1" != "$version_gfwlist2" -o "$md5sum_gfwlist2" != "$local_md5sum_gfwlist" ]; then
|
||||
echo $Date: 检测到新版本gfwlist,开始更新... >>$LOG_FILE
|
||||
echo $Date: 下载gfwlist到临时文件... >>$LOG_FILE
|
||||
#wget --no-check-certificate --timeout=15 -q https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/gfwlist.conf -O /tmp/gfwlist.conf
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/gfwlist.conf
|
||||
status2=$(curl -w %{http_code} --connect-timeout 10 $url_main/gfwlist.conf --silent -o /tmp/gfwlist.conf)
|
||||
if [ -z "$status2" ] || [ "$status2" == "404" ]; then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_gfwlist1=$(md5sum /tmp/gfwlist.conf | sed 's/ /\n/g' | sed -n 1p)
|
||||
if [ "$md5sum_gfwlist1"x = "$md5sum_gfwlist2"x ]; then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始gfwlist文件 >>$LOG_FILE
|
||||
mv /tmp/gfwlist.conf $DNSMASQ_PATH/gfwlist.conf
|
||||
uci set $CONFIG.@global_rules[0].gfwlist_version=$version_gfwlist2
|
||||
rm -rf /tmp/dnsmasq.d/gfwlist.conf
|
||||
reboot="1"
|
||||
echo $Date: 你的gfwlist已经更新到最新了哦~ >>$LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到gfwlist本地版本号和在线版本号相同,不用更新! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: gfwlist文件下载失败! >>$LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/gfwlist.conf
|
||||
fi
|
||||
|
||||
# update chnroute
|
||||
if [ "$chnroute_update" == 1 ]; then
|
||||
chnroute=$(cat /tmp/version1 | sed -n 2p)
|
||||
version_chnroute2=$(echo $chnroute | sed 's/ /\n/g' | sed -n 1p)
|
||||
md5sum_chnroute2=$(echo $chnroute | sed 's/ /\n/g' | tail -n 2 | head -n 1)
|
||||
local_md5sum_chnroute=$(md5sum $RULE_PATH/chnroute | awk '{print $1}')
|
||||
if [ ! -z "$version_chnroute2" ]; then
|
||||
version_chnroute1=$(uci_get_by_type global_rules chnroute_version)
|
||||
if [ "$version_chnroute1" != "$version_chnroute2" -o "$md5sum_chnroute2" != "$local_md5sum_chnroute" ]; then
|
||||
echo $Date: 检测到新版本chnroute,开始更新... >>$LOG_FILE
|
||||
echo $Date: 下载chnroute到临时文件... >>$LOG_FILE
|
||||
#wget --no-check-certificate --timeout=15 -q https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/chnroute.txt -O /tmp/chnroute
|
||||
#旧接口https://raw.githubusercontent.com/monokoo/koolshare.github.io/acelan_softcenter_ui/maintain_files/chnroute.txt
|
||||
status3=$(curl -w %{http_code} --connect-timeout 10 $url_main/chnroute.txt --silent -o /tmp/chnroute)
|
||||
if [ -z "$status3" ] || [ "$status3" == "404" ]; then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_chnroute1=$(md5sum /tmp/chnroute | sed 's/ /\n/g' | sed -n 1p)
|
||||
if [ "$md5sum_chnroute1"x = "$md5sum_chnroute2"x ]; then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始chnroute文件 >>$LOG_FILE
|
||||
mv /tmp/chnroute $RULE_PATH/chnroute
|
||||
uci set $CONFIG.@global_rules[0].chnroute_version=$version_chnroute2
|
||||
ipset flush chnroute
|
||||
ipset destroy chnroute
|
||||
reboot="1"
|
||||
echo $Date: 你的chnroute已经更新到最新了哦~ >>$LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到chnroute本地版本号和在线版本号相同,不用更新! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: chnroute文件下载失败! >>$LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/chnroute
|
||||
fi
|
||||
|
||||
# update Routing
|
||||
if [ "$Pcap_Routing_update" == 1 ]; then
|
||||
Routing=$(cat /tmp/version1 | sed -n 5p)
|
||||
version_Routing2=$(echo $Routing | sed 's/ /\n/g' | sed -n 1p)
|
||||
md5sum_Routing2=$(echo $Routing | sed 's/ /\n/g' | tail -n 2 | head -n 1)
|
||||
local_md5sum_Routing=$(md5sum /etc/pcap-dnsproxy/Routing.txt | awk '{print $1}')
|
||||
if [ ! -z "$version_Routing2" ]; then
|
||||
version_Routing1=$(uci_get_by_type global_rules pcap_Routing_version)
|
||||
if [ "$version_Routing1" != "$version_Routing2" -o "$md5sum_Routing2" != "$local_md5sum_Routing" ]; then
|
||||
echo $Date: 检测到新版本Routing,开始更新... >>$LOG_FILE
|
||||
echo $Date: 下载Routing到临时文件... >>$LOG_FILE
|
||||
status4=$(curl -w %{http_code} --connect-timeout 10 $url_main/Routing.txt --silent -o /tmp/Routing.txt)
|
||||
if [ -z "$status4" ] || [ "$status4" == "404" ]; then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
md5sum_Routing1=$(md5sum /tmp/Routing.txt | sed 's/ /\n/g' | sed -n 1p)
|
||||
if [ "$md5sum_Routing1"x = "$md5sum_Routing2"x ]; then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始Routing文件 >>$LOG_FILE
|
||||
mkdir -p /etc/pcap-dnsproxy
|
||||
mv /tmp/Routing.txt /etc/pcap-dnsproxy/Routing.txt
|
||||
uci set $CONFIG.@global_rules[0].pcap_Routing_version=$version_Routing2
|
||||
reboot="1"
|
||||
echo $Date: 你的Routing已经更新到最新了哦~ >>$LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到Routing本地版本号和在线版本号相同,不用更新! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: Routing文件下载失败! >>$LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/Routing.txt
|
||||
fi
|
||||
|
||||
# update WhiteList
|
||||
if [ "$Pcap_WhiteList_update" == 1 ]; then
|
||||
WhiteList=$(cat /tmp/version1 | sed -n 7p)
|
||||
version_WhiteList2=$(echo $WhiteList | sed 's/ /\n/g' | sed -n 1p)
|
||||
md5sum_WhiteList2=$(echo $WhiteList | sed 's/ /\n/g' | tail -n 2 | head -n 1)
|
||||
local_md5sum_WhiteList=$(md5sum /etc/pcap-dnsproxy/WhiteList.txt | awk '{print $1}')
|
||||
if [ ! -z "$version_WhiteList2" ]; then
|
||||
version_WhiteList1=$(uci_get_by_type global_rules pcap_WhiteList_version)
|
||||
if [ "$version_WhiteList1" != "$version_WhiteList2" -o "$md5sum_WhiteList2" != "$local_md5sum_WhiteList" ]; then
|
||||
echo $Date: 检测到新版本WhiteList,开始更新... >>$LOG_FILE
|
||||
echo $Date: 下载WhiteList到临时文件... >>$LOG_FILE
|
||||
status4=$(curl -w %{http_code} --connect-timeout 10 $url_main/WhiteList_new.txt --silent -o /tmp/WhiteList.txt)
|
||||
if [ -z "$status4" ] || [ "$status4" == "404" ]; then
|
||||
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
|
||||
exit
|
||||
fi
|
||||
#wget --no-check-certificate --timeout=10 -qO - $url_main/WhiteList_new.txt > /tmp/WhiteList.txt
|
||||
md5sum_WhiteList1=$(md5sum /tmp/WhiteList.txt | sed 's/ /\n/g' | sed -n 1p)
|
||||
if [ "$md5sum_WhiteList1"x = "$md5sum_WhiteList2"x ]; then
|
||||
echo $Date: 下载完成,校验通过,将临时文件覆盖到原始WhiteList文件 >>$LOG_FILE
|
||||
mkdir -p /etc/pcap-dnsproxy
|
||||
mv /tmp/WhiteList.txt /etc/pcap-dnsproxy/WhiteList.txt
|
||||
uci set $CONFIG.@global_rules[0].pcap_WhiteList_version=$version_WhiteList2
|
||||
reboot="1"
|
||||
echo $Date: 你的WhiteList已经更新到最新了哦~ >>$LOG_FILE
|
||||
else
|
||||
echo $Date: 下载完成,但是校验没有通过! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: 检测到WhiteList本地版本号和在线版本号相同,不用更新! >>$LOG_FILE
|
||||
fi
|
||||
else
|
||||
echo $Date: WhiteList文件下载失败! >>$LOG_FILE
|
||||
fi
|
||||
rm -rf /tmp/WhiteList.txt
|
||||
fi
|
||||
|
||||
echo $Date: 更新进程运行完毕! >>$LOG_FILE
|
||||
rm -rf /tmp/version1
|
||||
# write number
|
||||
uci set $CONFIG.@global_rules[0].gfwlist_update=$gfwlist_update
|
||||
uci set $CONFIG.@global_rules[0].chnroute_update=$chnroute_update
|
||||
uci set $CONFIG.@global_rules[0].Pcap_Routing_update=$Pcap_Routing_update
|
||||
uci set $CONFIG.@global_rules[0].Pcap_WhiteList_update=$Pcap_WhiteList_update
|
||||
uci commit
|
||||
# reboot ss
|
||||
if [ "$reboot" == "1" ]; then
|
||||
echo $Date: 重启软件,以应用新的规则文件!请稍后! >>$LOG_FILE
|
||||
/etc/init.d/$CONFIG restart
|
||||
fi
|
||||
exit
|
||||
@ -17,19 +17,19 @@ start() {
|
||||
#防止并发开启服务
|
||||
[ -f "$LOCK_FILE" ] && return 3
|
||||
touch "$LOCK_FILE"
|
||||
echo "$Date: 开始执行在线订阅脚本..." >> $LOG_FILE
|
||||
echo "$Date: 开始执行在线订阅脚本..." >>$LOG_FILE
|
||||
/usr/share/$CONFIG/subscription_ssr.sh start 2>/dev/null
|
||||
/usr/share/$CONFIG/subscription_v2ray.sh start 2>/dev/null
|
||||
echo "$Date: 在线订阅脚本执行完毕..." >> $LOG_FILE
|
||||
echo "$Date: 在线订阅脚本执行完毕..." >>$LOG_FILE
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "$Date: 开始执行删除所有订阅脚本..." >> $LOG_FILE
|
||||
echo "$Date: 开始执行删除所有订阅脚本..." >>$LOG_FILE
|
||||
/usr/share/$CONFIG/subscription_ssr.sh stop 2>/dev/null
|
||||
/usr/share/$CONFIG/subscription_v2ray.sh stop 2>/dev/null
|
||||
echo "$Date: 删除所有订阅脚本执行完毕..." >> $LOG_FILE
|
||||
echo "$Date: 删除所有订阅脚本执行完毕..." >>$LOG_FILE
|
||||
rm -f "$LOCK_FILE"
|
||||
exit 0
|
||||
}
|
||||
86
package/Lienol/luci-app-passwall/root/usr/share/passwall/test.sh → package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh
Executable file → Normal file
86
package/Lienol/luci-app-passwall/root/usr/share/passwall/test.sh → package/lienol/luci-app-passwall/root/usr/share/passwall/test.sh
Executable file → Normal file
@ -3,23 +3,23 @@
|
||||
CONFIG=passwall
|
||||
LOCK_FILE=/var/lock/passwall_test.lock
|
||||
|
||||
get_date(){
|
||||
get_date() {
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
}
|
||||
|
||||
test_url(){
|
||||
status=$(curl -I -o /dev/null -s --connect-timeout 5 -w %{http_code} "$1" |grep 200)
|
||||
test_url() {
|
||||
status=$(curl -I -o /dev/null -s --connect-timeout 5 -w %{http_code} "$1" | grep 200)
|
||||
echo $status
|
||||
}
|
||||
|
||||
test_proxy(){
|
||||
test_proxy() {
|
||||
result=0
|
||||
status=$(test_url "https://www.google.com")
|
||||
if [ "$status" = "200" ];then
|
||||
if [ "$status" = "200" ]; then
|
||||
result=0
|
||||
else
|
||||
status2=$(test_url "https://www.baidu.com")
|
||||
if [ "$status2" = "200" ];then
|
||||
if [ "$status2" = "200" ]; then
|
||||
result=1
|
||||
else
|
||||
result=2
|
||||
@ -28,47 +28,45 @@ test_proxy(){
|
||||
echo $result
|
||||
}
|
||||
|
||||
test_auto_switch(){
|
||||
if [ -f "/var/etc/passwall/tcp_server_id" ];then
|
||||
TCP_REDIR_SERVER=`cat /var/etc/passwall/tcp_server_id`
|
||||
test_auto_switch() {
|
||||
if [ -f "/var/etc/passwall/tcp_server_id" ]; then
|
||||
TCP_REDIR_SERVER=$(cat /var/etc/passwall/tcp_server_id)
|
||||
else
|
||||
rm -f $LOCK_FILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
failcount=1
|
||||
while [ "$failcount" -lt "6" ]
|
||||
do
|
||||
while [ "$failcount" -lt "6" ]; do
|
||||
status=$(test_proxy)
|
||||
if [ "$status" == 2 ];then
|
||||
echo "$(get_date): 自动切换检测:无法连接到网络,请检查网络是否正常!" >> /var/log/passwall.log
|
||||
if [ "$status" == 2 ]; then
|
||||
echo "$(get_date): 自动切换检测:无法连接到网络,请检查网络是否正常!" >>/var/log/passwall.log
|
||||
break
|
||||
elif [ "$status" == 1 ];then
|
||||
echo "$(get_date): 自动切换检测:第$failcount次检测异常" >> /var/log/passwall.log
|
||||
elif [ "$status" == 1 ]; then
|
||||
echo "$(get_date): 自动切换检测:第$failcount次检测异常" >>/var/log/passwall.log
|
||||
let "failcount++"
|
||||
[ "$failcount" -ge 6 ] && {
|
||||
echo "$(get_date): 自动切换检测:检测异常,切换节点" >> /var/log/passwall.log
|
||||
TCP_REDIR_SERVERS=`uci get passwall.@auto_switch[0].tcp_redir_server`
|
||||
has_backup_server=`echo $TCP_REDIR_SERVERS | grep $TCP_REDIR_SERVER`
|
||||
echo "$(get_date): 自动切换检测:检测异常,切换节点" >>/var/log/passwall.log
|
||||
TCP_REDIR_SERVERS=$(uci get passwall.@auto_switch[0].tcp_redir_server)
|
||||
has_backup_server=$(echo $TCP_REDIR_SERVERS | grep $TCP_REDIR_SERVER)
|
||||
setserver=
|
||||
if [ -z "$has_backup_server" ];then
|
||||
setserver=`echo $TCP_REDIR_SERVERS | awk -F ' ' '{print $1}'`
|
||||
if [ -z "$has_backup_server" ]; then
|
||||
setserver=$(echo $TCP_REDIR_SERVERS | awk -F ' ' '{print $1}')
|
||||
else
|
||||
setserver=$TCP_REDIR_SERVER
|
||||
flag=0
|
||||
for server in $has_backup_server
|
||||
do
|
||||
if [ "$flag" == 0 ];then
|
||||
if [ "$TCP_REDIR_SERVER" == "$server" ];then
|
||||
for server in $has_backup_server; do
|
||||
if [ "$flag" == 0 ]; then
|
||||
if [ "$TCP_REDIR_SERVER" == "$server" ]; then
|
||||
flag=1
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [ "$flag" == 1 ];then
|
||||
if [ "$flag" == 1 ]; then
|
||||
flag=2
|
||||
continue
|
||||
fi
|
||||
if [ "$flag" == 2 ];then
|
||||
if [ "$flag" == 2 ]; then
|
||||
setserver=$server
|
||||
break
|
||||
fi
|
||||
@ -81,48 +79,46 @@ test_auto_switch(){
|
||||
exit 1
|
||||
}
|
||||
sleep 5s
|
||||
elif [ "$status" == 0 ];then
|
||||
echo "$(get_date): 自动切换检测:检测正常" >> /var/log/passwall.log
|
||||
elif [ "$status" == 0 ]; then
|
||||
echo "$(get_date): 自动切换检测:检测正常" >>/var/log/passwall.log
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
test_reconnection(){
|
||||
test_reconnection() {
|
||||
failcount=1
|
||||
while [ "$failcount" -lt "6" ]
|
||||
do
|
||||
while [ "$failcount" -lt "6" ]; do
|
||||
status=$(test_proxy)
|
||||
if [ "$status" == 2 ];then
|
||||
echo "$(get_date): 掉线重连检测:无法连接到网络,请检查网络是否正常!" >> /var/log/passwall.log
|
||||
if [ "$status" == 2 ]; then
|
||||
echo "$(get_date): 掉线重连检测:无法连接到网络,请检查网络是否正常!" >>/var/log/passwall.log
|
||||
break
|
||||
elif [ "$status" == 1 ];then
|
||||
echo "$(get_date): 掉线重连检测:第$failcount次检测异常" >> /var/log/passwall.log
|
||||
elif [ "$status" == 1 ]; then
|
||||
echo "$(get_date): 掉线重连检测:第$failcount次检测异常" >>/var/log/passwall.log
|
||||
let "failcount++"
|
||||
[ "$failcount" -ge 6 ] && {
|
||||
echo "$(get_date): 掉线重连检测:检测异常,重启服务" >> /var/log/passwall.log
|
||||
echo "$(get_date): 掉线重连检测:检测异常,重启服务" >>/var/log/passwall.log
|
||||
rm -f $LOCK_FILE
|
||||
/etc/init.d/passwall restart
|
||||
exit 1
|
||||
}
|
||||
sleep 5s
|
||||
elif [ "$status" == 0 ];then
|
||||
echo "$(get_date): 掉线重连检测:检测正常" >> /var/log/passwall.log
|
||||
elif [ "$status" == 0 ]; then
|
||||
echo "$(get_date): 掉线重连检测:检测正常" >>/var/log/passwall.log
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#防止并发执行
|
||||
if [ -f "$LOCK_FILE" ];then
|
||||
exit 1
|
||||
if [ -f "$LOCK_FILE" ]; then
|
||||
exit 1
|
||||
else
|
||||
touch $LOCK_FILE
|
||||
touch $LOCK_FILE
|
||||
fi
|
||||
|
||||
is_auto_switch=`uci show $CONFIG.@auto_switch[0] | grep "tcp_redir_server"`
|
||||
if [ -z "$is_auto_switch" ];then
|
||||
is_auto_switch=$(uci show $CONFIG.@auto_switch[0] | grep "tcp_redir_server")
|
||||
if [ -z "$is_auto_switch" ]; then
|
||||
test_reconnection
|
||||
else
|
||||
test_auto_switch
|
||||
Loading…
Reference in New Issue
Block a user