Skip to content

Commit

Permalink
Update version v0.18.1<Refine version>
Browse files Browse the repository at this point in the history
  • Loading branch information
houzi- committed Jul 17, 2022
1 parent c0acf61 commit d05a9fb
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 76 deletions.
4 changes: 2 additions & 2 deletions config.json.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"module":"koolclash",
"version":"0.18.1",
"md5":"17eae5e6767aa5f47bd06e9e38dcf08e",
"md5":"42244b3a6b42bb009f386ce42b97236d",
"home_url":"Module_koolclash.asp",
"title":"koolclash",
"description":"基于规则的代理程序 Clash",
"changelog":"更新修复",
"build_date":"2022-07-16_10:47:22"
"build_date":"2022-07-17_11:03:20"
}
Binary file modified koolclash.tar.gz
Binary file not shown.
10 changes: 5 additions & 5 deletions koolclash/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ echo_date "KoolClash: 复制安装包内的文件到路由器..."
#cp -rf /tmp/koolclash/bin/* $KSROOT/bin/
cp -rf /tmp/koolclash/bin/clash-linux-amd64 $KSROOT/bin/clash
cp -rf /tmp/koolclash/bin/yq_linux_amd64 $KSROOT/bin/yq
tar -zxvf /tmp/koolclash/bin/subconverter.tar.gz -C $KSROOT/bin
tar -zxf /tmp/koolclash/bin/subconverter.tar.gz -C $KSROOT/bin
cp -rf /tmp/koolclash/scripts/* $KSROOT/scripts/
cp -rf /tmp/koolclash/init.d/* $KSROOT/init.d/
cp -rf /tmp/koolclash/webs/* $KSROOT/webs/
Expand Down Expand Up @@ -105,10 +105,10 @@ chmod 755 $KSROOT/init.d/S99koolclash.sh
local_version=$(cat $KSROOT/webs/res/koolclash_.version)
echo_date "KoolClash: 设置版本号为 $local_version..."
dbus set koolclash_version=$local_version
echo_date "KoolClash: 设置代理模式为 规则模式..."
dbus set koolclash_switch_config_mode=1
echo_date "KoolClash: 设置运行模式为 Fake-IP(增强)..."
dbus set koolclash_switch_run_mode=1
#echo_date "KoolClash: 设置代理模式为 规则模式..."
#dbus set koolclash_switch_config_mode=1
#echo_date "KoolClash: 设置运行模式为 Fake-IP(增强)..."
#dbus set koolclash_switch_run_mode=1

sleep 1

Expand Down
33 changes: 22 additions & 11 deletions koolclash/scripts/koolclash_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,18 @@ kill_process() {
#}

load_rule_mode () {
[ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: rule")" == "mode: rule" ] && dbus set koolclash_switch_config_mode=1
[ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: rule")" == "mode: global" ] && dbus set koolclash_switch_config_mode=1
[ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: rule")" == "mode: direct" ] && dbus set koolclash_switch_config_mode=1
if [ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: Rule")" == "mode: Rule" ]; then
echo_date "代理模式为 Rule"
dbus set koolclash_switch_config_mode=1
fi
if [ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: Global")" == "mode: Global" ]; then
echo_date "代理模式为 Global"
dbus set koolclash_switch_config_mode=2
fi
if [ "$(cat /koolshare/koolclash/config/config.yaml | grep "mode: Direct")" == "mode: Direct" ]; then
echo_date "代理模式为 Direct"
dbus set koolclash_switch_config_mode=3
fi
}

restart_dnsmasq() {
Expand Down Expand Up @@ -226,16 +235,16 @@ add_white_black_ip() {
if [ ! -z $koolclash_firewall_whitedomain_base64 ]; then
ip_white_domain=$(echo $koolclash_firewall_whitedomain_base64 | base64_decode)
echo_date '应用外网目标域名白名单'
ISP_DNS=$(ubus call network.interface.wan status | jsonfilter -e '@["dns-server"][0]')
rm -rf /tmp/dnsmasq.d/koolclash_ipset.conf >/dev/null 2>&1
rm -rf /tmp/dnsmasq.d/koolclash_white_server.conf >/dev/null 2>&1
echo "#for koolclash white_domain" >> /tmp/dnsmasq.d/koolclash_ipset.conf
echo "#for koolclash white_domain_server" >> /tmp/dnsmasq.d/koolclash_white_server.conf
ISP_DNS=$(ubus call network.interface.wan status | jsonfilter -e '@["dns-server"][0]')
rm -rf /tmp/dnsmasq.d/koolclash_ipset.conf >/dev/null 2>&1
rm -rf /tmp/dnsmasq.d/koolclash_white_server.conf >/dev/null 2>&1
echo "#for koolclash white_domain" >> /tmp/dnsmasq.d/koolclash_ipset.conf
echo "#for koolclash white_domain_server" >> /tmp/dnsmasq.d/koolclash_white_server.conf
for domain in $ip_white_domain; do
echo "$domain" | sed "s/^/ipset=&\/./g" | sed "s/$/\/koolclash_white/g" >> /tmp/dnsmasq.d/koolclash_ipset.conf
echo "$domain" | sed "s/^/server=&\//g" | sed "s/$/\/$ISP_DNS/g" >> /tmp/dnsmasq.d/koolclash_white_server.conf
echo "$domain" | sed "s/^/ipset=&\/./g" | sed "s/$/\/koolclash_white/g" >> /tmp/dnsmasq.d/koolclash_ipset.conf
echo "$domain" | sed "s/^/server=&\//g" | sed "s/$/\/$ISP_DNS/g" >> /tmp/dnsmasq.d/koolclash_white_server.conf
done
else
else
rm -rf /tmp/dnsmasq.d/koolclash_ipset.conf >/dev/null 2>&1
rm -rf /tmp/dnsmasq.d/koolclash_white_server.conf >/dev/null 2>&1
fi
Expand Down Expand Up @@ -505,6 +514,8 @@ stop_koolclash() {
creat_update_sub_cron
dbus remove koolclash_switch_run_mode
dbus remove koolclash_switch_config_mode
rm -rf /tmp/dnsmasq.d/koolclash_ipset.conf >/dev/null 2>&1
rm -rf /tmp/dnsmasq.d/koolclash_white_server.conf >/dev/null 2>&1
echo_date ------------------------------- KoolClash 停止完毕 -------------------------------
}

Expand Down
6 changes: 3 additions & 3 deletions koolclash/scripts/koolclash_save_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ yq w -i $KSROOT/koolclash/config/origin.yml allow-lan true

# Change proxy mode
if [ "$koolclash_switch_config_mode" == "1" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "rule"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Rule"
elif [ "$koolclash_switch_config_mode" == "2" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "global"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Global"
elif [ "$koolclash_switch_config_mode" == "3" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "direct"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Direct"
fi

# 如果没有外部监听控制就使用 LAN IP:6170
Expand Down
6 changes: 3 additions & 3 deletions koolclash/scripts/koolclash_subconverter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ update)

# Change proxy mode
if [ "$koolclash_switch_config_mode" == "1" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "rule"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Rule"
elif [ "$koolclash_switch_config_mode" == "2" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "global"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Global"
elif [ "$koolclash_switch_config_mode" == "3" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "direct"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Direct"
fi

cp $KSROOT/koolclash/config/origin.yml $KSROOT/koolclash/config/config.yaml
Expand Down
2 changes: 1 addition & 1 deletion koolclash/scripts/koolclash_switch_direct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ curl -sv \
-X DELETE "http://$ipaddr_port/connections" 2>&1

dbus set koolclash_switch_config_mode=3
yq w -i $KSROOT/koolclash/config/config.yaml mode "direct"
yq w -i $KSROOT/koolclash/config/config.yaml mode "Direct"
http_response 'direct'
2 changes: 1 addition & 1 deletion koolclash/scripts/koolclash_switch_global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ curl -sv \
-X DELETE "http://$ipaddr_port/connections" 2>&1

dbus set koolclash_switch_config_mode=2
yq w -i $KSROOT/koolclash/config/config.yaml mode "global"
yq w -i $KSROOT/koolclash/config/config.yaml mode "Global"
http_response 'global'
2 changes: 1 addition & 1 deletion koolclash/scripts/koolclash_switch_rule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ curl -sv \
-X DELETE "http://$ipaddr_port/connections" 2>&1

dbus set koolclash_switch_config_mode=1
yq w -i $KSROOT/koolclash/config/config.yaml mode "rule"
yq w -i $KSROOT/koolclash/config/config.yaml mode "Rule"
http_response 'rule'
41 changes: 4 additions & 37 deletions koolclash/scripts/koolclash_update_sub_cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ sub_url_update () {
if [ "$?" == "0" ]; then
[ ! -s "$KSROOT/koolclash/config/origin.yml" ] && $curl -4sSk --user-agent "$UA" --connect-timeout 30 "$subconverter_links" > $KSROOT/koolclash/config/origin.yml
if [ ! -s "$KSROOT/koolclash/config/origin.yml" ]; then
http_response 'fail'
exit 1
else
local blank1=$(cat $KSROOT/koolclash/config/origin.yml | grep -E "Redirecting|301")
Expand Down Expand Up @@ -160,39 +159,15 @@ sub_url_update () {
sed -i 's/^mixed-port:/port:/g' $KSROOT/koolclash/config/origin.yml
fi
else
http_response 'fail'
exit 1
fi
else
start_stop_subconverter
http_response 'fail'
exit 1
fi
}
#---------------------------------------------------------------------

start_clash() {
echo_date "启动 Clash 进程..."
start-stop-daemon -S -q -b -m \
-p /tmp/run/koolclash.pid \
-x $KSROOT/bin/clash \
-- -d $KSROOT/koolclash/config/
}

start_clash_watchdog() {
if [ "$koolclash_watchdog_enable" == "1" ]; then
echo_date "启动 Clash 看门狗进程守护..."
start-stop-daemon -S -q -b -m \
-p /tmp/run/koolclash.pid \
-x $KSROOT/scripts/koolclash_watchdog.sh
fi
}

kill_clash() {
[ -n "$(ps | grep koolclash_watchdog.sh | grep -v grep | awk '{print $1}')" ] && echo_date "关闭 Clash 看门狗..." && kill -9 $(ps | grep koolclash_watchdog.sh | grep -v grep | awk '{print $1}') >/dev/null 2>&1
[ -n "$(pidof clash)" ] && echo_date "关闭 Clash 进程..." && killall clash >/dev/null 2>&1
}

case $1 in
update)
sub_url=$(dbus get koolclash_suburl | sed -e 's;?;\\?;g' -e 's;&;\\&;g')
Expand All @@ -216,7 +191,6 @@ update)
sed -i '/^\-\-\-$/ d' $KSROOT/koolclash/config/origin.yml
sed -i '/^\.\.\.$/ d' $KSROOT/koolclash/config/origin.yml
else
http_response 'nocurl'
echo_date "路由器中没有 CURL 不能更新配置文件!"
cp $KSROOT/koolclash/config/origin-backup.yml $KSROOT/koolclash/config/origin.yml
exit 1
Expand All @@ -240,11 +214,11 @@ update)

# Change proxy mode
if [ "$koolclash_switch_config_mode" == "1" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "rule"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Rule"
elif [ "$koolclash_switch_config_mode" == "2" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "global"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Global"
elif [ "$koolclash_switch_config_mode" == "3" ]; then
yq w -i $KSROOT/koolclash/config/origin.yml mode "direct"
yq w -i $KSROOT/koolclash/config/origin.yml mode "Direct"
fi

cp $KSROOT/koolclash/config/origin.yml $KSROOT/koolclash/config/config.yaml
Expand All @@ -269,14 +243,12 @@ update)

overwrite_dns_config
echo_date "Clash 配置文件上传成功!"
http_response 'success'
else
echo_date "在 Clash 配置文件中没有找到 DNS 配置!"
if [ ! -n "$fallbackdns" ]; then
echo_date "没有找到后备 DNS 配置!请前往「配置文件」提交后备 DNS 配置!"
# 设置 DNS Mode 为 3
dbus set koolclash_dnsmode=3
http_response 'nofallbackdns'
else
echo_date "找到后备 DNS 配置!合并到 Clash 配置文件中..."

Expand All @@ -290,21 +262,16 @@ update)
overwrite_dns_config

echo_date "Clash 配置文件上传成功!"
http_response 'success'
fi
fi

kill_clash
start_clash
sleep 1
start_clash_watchdog
$KSROOT/scripts/koolclash_control.sh start
else
# 下载失败了
echo_date "Clash 配置文件下载失败!"
rm -rf $KSROOT/koolclash/config/origin.yml
cp $KSROOT/koolclash/config/origin-backup.yml $KSROOT/koolclash/config/origin.yml
rm -rf $KSROOT/koolclash/config/origin-backup.yml
http_response 'fail'
fi
;;
esac
24 changes: 13 additions & 11 deletions koolclash/webs/Module_koolclash.asp
Original file line number Diff line number Diff line change
Expand Up @@ -1939,17 +1939,19 @@ ${Base64.decode(data.firewall_white_ip)}
$('#koolclash-ip').on('click', function() {
koolclash_CheckIP();
});
if (window.dbus.koolclash_switch_config_mode === '1') {
$('#rule').attr('checked', '');
}
if (window.dbus.koolclash_switch_config_mode === '2') {
$('#global').attr('checked', '');
}
if (window.dbus.koolclash_switch_config_mode === '3') {
$('#direct').attr('checked', '');
}
if (window.dbus.koolclash_switch_run_mode === '1') {
$('#fake-ip-enhanced').attr('checked', '');
if (window.dbus.koolclash_enable === '1') {
if (window.dbus.koolclash_switch_config_mode === '1') {
$('#rule').attr('checked', '');
}
if (window.dbus.koolclash_switch_config_mode === '2') {
$('#global').attr('checked', '');
}
if (window.dbus.koolclash_switch_config_mode === '3') {
$('#direct').attr('checked', '');
}
if (window.dbus.koolclash_switch_run_mode === '1') {
$('#fake-ip-enhanced').attr('checked', '');
}
}
})
},
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.18.1
17eae5e6767aa5f47bd06e9e38dcf08e
42244b3a6b42bb009f386ce42b97236d

0 comments on commit d05a9fb

Please sign in to comment.