luci-app-openclash: bump to 0.40.6

This commit is contained in:
CN_SZTL 2020-09-30 19:51:21 +08:00
parent 89a879764a
commit 428ea7aeb3
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
152 changed files with 1674 additions and 1083 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.40.4
PKG_VERSION:=0.40.6
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
@ -23,22 +23,23 @@ define Package/$(PKG_NAME)/description
endef
define Build/Prepare
$(CP) $(CURDIR)/files $(PKG_BUILD_DIR)
$(foreach po,$(wildcard ${CURDIR}/i18n/zh-cn/*.po), \
$(CP) $(CURDIR)/root $(PKG_BUILD_DIR)
$(CP) $(CURDIR)/luasrc $(PKG_BUILD_DIR)
$(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
chmod 0755 $(PKG_BUILD_DIR)/files/etc/init.d/openclash
chmod -R 0755 $(PKG_BUILD_DIR)/files/usr/share/openclash/
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/config >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/rule_provider >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/backup >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/core >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/files/usr/share/openclash/backup >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/config/openclash" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/files/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/files/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
chmod 0755 $(PKG_BUILD_DIR)/root/etc/init.d/openclash
chmod -R 0755 $(PKG_BUILD_DIR)/root/usr/share/openclash/
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/config >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/rule_provider >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/backup >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/core >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/usr/share/openclash/backup >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/config/openclash" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
endef
define Build/Configure
@ -47,165 +48,51 @@ endef
define Build/Compile
endef
define Package/$(PKG_NAME)/conffiles
endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
if [ -f "/etc/config/openclash" ]; then
cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1
cp -r "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1
fi
if [ -f "/etc/openclash/custom/openclash_custom_rules.list" ]; then
cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/tmp/openclash_custom_domain_dns.list.bak" >/dev/null 2>&1
cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
fi
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci add ucitrack openclash >/dev/null 2>&1
uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci set firewall.openclash=include >/dev/null 2>&1
uci set firewall.openclash.type=script >/dev/null 2>&1
uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1
uci set firewall.openclash.reload=1 >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
mkdir -p /etc/openclash/config >/dev/null 2>&1
mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1
mkdir -p /etc/openclash/backup >/dev/null 2>&1
mkdir -p /etc/openclash/core >/dev/null 2>&1
mkdir -p /etc/openclash/history >/dev/null 2>&1
mkdir -p /usr/share/openclash/backup >/dev/null 2>&1
cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
if [ -f "/tmp/openclash.bak" ]; then
mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
if [ -d "/tmp/openclash_history/" ]; then
cp -a "/tmp/openclash_history/." "/etc/openclash/history" >/dev/null 2>&1
rm -rf "/tmp/openclash_history" >/dev/null 2>&1
fi
fi
if [ -f "/tmp/config.yaml" ]; then
mv "/tmp/config.yaml" "/etc/openclash/config/config.yaml" >/dev/null 2>&1
elif [ -f "/tmp/config.yml" ]; then
mv "/tmp/config.yml" "/etc/openclash/config/config.yaml" >/dev/null 2>&1
elif [ -d "/tmp/openclash_config/" ]; then
rm -rf "/etc/openclash/config" >/dev/null 2>&1
mv "/tmp/openclash_config" "/etc/openclash/config" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_proxy_provider/" ]; then
rm -rf "/etc/openclash/proxy_provider" >/dev/null 2>&1
mv "/tmp/openclash_proxy_provider" "/etc/openclash/proxy_provider" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_rule_provider/" ]; then
cp -a "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider" >/dev/null 2>&1
rm -rf "/tmp/openclash_rule_provider" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_game_rules/" ]; then
rm -rf "/etc/openclash/game_rules" >/dev/null 2>&1
mv "/tmp/openclash_game_rules" "/etc/openclash/game_rules" >/dev/null 2>&1
fi
if [ -f "/tmp/clash" ]; then
mv "/tmp/clash" "/etc/openclash/core/clash" >/dev/null 2>&1
fi
if [ -f "/etc/openclash/clash" ]; then
mv "/etc/openclash/clash" "/etc/openclash/core/clash" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_core/" ]; then
rm -rf "/etc/openclash/core" >/dev/null 2>&1
mv "/tmp/openclash_core" "/etc/openclash/core" >/dev/null 2>&1
fi
mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1
cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
/etc/openclash/core/
/etc/openclash/custom/
/etc/openclash/config/
/etc/openclash/game_rules/
/etc/openclash/proxy_provider/
/etc/openclash/rule_provider/
EOF
uci set openclash.config.enable=0 >/dev/null 2>&1
uci commit openclash >/dev/null 2>&1
chmod 0755 /etc/init.d/openclash >/dev/null 2>&1
chmod -R 0755 /usr/share/openclash/ >/dev/null 2>&1
rm -rf /tmp/luci*
endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
uci set openclash.config.enable=0 >/dev/null 2>&1
uci commit openclash >/dev/null 2>&1
mv "/etc/openclash/core" "/tmp/openclash_core" >/dev/null 2>&1
mv "/etc/openclash/config.yaml" "/tmp/config.yaml" >/dev/null 2>&1
mv "/etc/openclash/config" "/tmp/openclash_config" >/dev/null 2>&1
mv "/etc/openclash/proxy_provider" "/tmp/openclash_proxy_provider" >/dev/null 2>&1
mv "/etc/openclash/rule_provider" "/tmp/openclash_rule_provider" >/dev/null 2>&1
mv "/etc/openclash/game_rules" "/tmp/openclash_game_rules" >/dev/null 2>&1
mv "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1
cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
cp "/etc/config/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/tmp/openclash_custom_domain_dns.list.bak" >/dev/null 2>&1
cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
endef
define Package/$(PKG_NAME)/postrm
#!/bin/sh
if [ -f "/tmp/openclash_update.sh" ]; then
rm -rf /etc/openclash/config >/dev/null 2>&1
rm -rf /etc/openclash/backup >/dev/null 2>&1
rm -rf /etc/openclash/proxy_provider >/dev/null 2>&1
rm -rf /etc/openclash/rule_provider >/dev/null 2>&1
rm -rf /etc/openclash/game_rules >/dev/null 2>&1
rm -rf /etc/openclash/history >/dev/null 2>&1
else
rm -rf /etc/openclash >/dev/null 2>&1
fi
rm -rf /lib/upgrade/keep.d/luci-app-openclash >/dev/null 2>&1
rm -rf /tmp/openclash.log >/dev/null 2>&1
rm -rf /tmp/openclash_start.log >/dev/null 2>&1
rm -rf /tmp/openclash_last_version >/dev/null 2>&1
rm -rf /tmp/Proxy_Group >/dev/null 2>&1
rm -rf /tmp/rules_name >/dev/null 2>&1
rm -rf /tmp/rule_providers_name >/dev/null 2>&1
rm -rf /tmp/openclash_last_version >/dev/null 2>&1
rm -rf /tmp/clash_last_version >/dev/null 2>&1
rm -rf /etc/openclash/dnsmasq_fake_block.conf >/dev/null 2>&1
rm -rf /etc/openclash/clash >/dev/null 2>&1
rm -rf /usr/share/openclash/backup >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
rm -rf /tmp/luci*
rm -rf /tmp/luci* >/dev/null 2>&1
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) $(PKG_BUILD_DIR)/*.*.lmo $(1)/usr/lib/lua/luci/i18n/
$(CP) $(PKG_BUILD_DIR)/files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/root/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luasrc/* $(1)/usr/lib/lua/luci/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

File diff suppressed because one or more lines are too long

View File

@ -1,52 +0,0 @@
<fieldset class="cbi-section">
<table>
<tr><td width="100%" colspan="4">
<p align="center">
<b> 组件的状态显示,运行前请确保各项目显示正常,需要更新请到全局设置页面操作 </b>
</p>
</td></tr>
<tr><td width="25%"> 策略组节点选择 备份日期 </td><td width="25%" align="left" id="_historychecktime"><%:Collecting data...%></td><td width="25%"> lhie1 规则更新日期 </td><td width="25%" align="left" id="_lhie1"><%:Collecting data...%></td></tr>
<tr><td width="25%"> ConnersHua 规则更新日期 </td><td width="25%" align="left" id="_ConnersHua"><%:Collecting data...%></td><td width="25%"> ConnersHua 回国规则更新日期 </td><td width="25%" align="left" id="_ConnersHua_return"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 大陆IP白名单 更新日期 </td><td width="25%" align="left" id="_chnroute"><%:Collecting data...%></td><td width="25%"> GEOIPBy MaxMind数据库日期 </td><td width="25%" align="left" id="_ipdb"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var ipdb = document.getElementById('_ipdb');
var lhie1 = document.getElementById('_lhie1');
var ConnersHua = document.getElementById('_ConnersHua');
var ConnersHua_return = document.getElementById('_ConnersHua_return');
var chnroute = document.getElementById('_chnroute');
var historychecktime = document.getElementById('_historychecktime');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
ipdb.innerHTML = status.ipdb ? "<b><font color=green>"+status.ipdb+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
lhie1.innerHTML = status.lhie1 ? "<b><font color=green>"+status.lhie1+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua.innerHTML = status.ConnersHua ? "<b><font color=green>"+status.ConnersHua+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua_return.innerHTML = status.ConnersHua_return ? "<b><font color=green>"+status.ConnersHua_return+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
chnroute.innerHTML = status.chnroute ? "<b><font color=green>"+status.chnroute+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
if ( status.historychecktime != "0" ) {
historychecktime.innerHTML = "<b><font color=green>"+status.historychecktime+"</font></b>";
}
else {
historychecktime.innerHTML = "<b><font color=green>"+"<%:暂未备份%>"+"</font></b>";
}
}
});
XHR.poll(10, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
ipdb.innerHTML = status.ipdb ? "<b><font color=green>"+status.ipdb+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
lhie1.innerHTML = status.lhie1 ? "<b><font color=green>"+status.lhie1+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua.innerHTML = status.ConnersHua ? "<b><font color=green>"+status.ConnersHua+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua_return.innerHTML = status.ConnersHua_return ? "<b><font color=green>"+status.ConnersHua_return+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
chnroute.innerHTML = status.chnroute ? "<b><font color=green>"+status.chnroute+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
if ( status.historychecktime != "0" ) {
historychecktime.innerHTML = "<b><font color=green>"+status.historychecktime+"</font></b>";
}
else {
historychecktime.innerHTML = "<b><font color=green>"+"<%:暂未备份%>"+"</font></b>";
}
}
});
//]]></script>

View File

@ -1,241 +0,0 @@
#!/bin/bash
. /lib/functions.sh
. /usr/share/openclash/openclash_ps.sh
status=$(unify_ps_status "openclash.sh")
[ "$status" -gt 3 ] && exit 0
START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/openclash.log"
CFG_FILE="/tmp/config.yaml"
CRON_FILE="/etc/crontabs/root"
CONFIG_PATH=$(uci get openclash.config.config_path 2>/dev/null)
servers_update=$(uci get openclash.config.servers_update 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
if_restart=0
urlencode() {
local data
if [ "$#" -eq 1 ]; then
data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")
if [ ! -z "$data" ]; then
echo "${data##/?}"
fi
fi
}
kill_watchdog() {
watchdog_pids=$(unify_ps_pids "openclash_watchdog.sh")
for watchdog_pid in $watchdog_pids; do
kill -9 "$watchdog_pid" >/dev/null 2>&1
done
}
config_download()
{
if [ "$URL_TYPE" == "v2rayn" ]; then
subscribe_url=$(urlencode "$subscribe_url")
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/v2rayn2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
elif [ "$URL_TYPE" == "surge" ]; then
subscribe_url=$(urlencode "$subscribe_url")
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/surge2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
fi
}
config_cus_up()
{
if [ -z "$CONFIG_PATH" ]; then
CONFIG_PATH="/etc/openclash/config/$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')"
uci set openclash.config.config_path="$CONFIG_PATH"
uci commit openclash
fi
if [ "$servers_update" -eq 1 ] || [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then
echo "配置文件【$name】替换成功,开始挑选节点..." >$START_LOG
uci set openclash.config.config_update_path="/etc/openclash/config/$name.yaml"
uci set openclash.config.servers_if_update=1
uci commit openclash
/usr/share/openclash/yml_groups_get.sh
uci set openclash.config.servers_if_update=1
uci commit openclash
/usr/share/openclash/yml_groups_set.sh
if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
if_restart=1
fi
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
echo "配置文件【$name】更新成功!" >$START_LOG
sleep 3
echo "" >$START_LOG
elif [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
echo "配置文件【$name】更新成功!" >$START_LOG
sleep 3
if_restart=1
else
echo "配置文件【$name】更新成功!" >$START_LOG
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
sleep 3
echo "" >$START_LOG
fi
rm -rf /tmp/Proxy_Group 2>/dev/null
}
config_su_check()
{
echo "配置文件下载成功,检查是否有更新..." >$START_LOG
if [ -f "$CONFIG_FILE" ]; then
cmp -s "$BACKPACK_FILE" "$CFG_FILE"
if [ "$?" -ne 0 ]; then
echo "配置文件【$name】有更新,开始替换..." >$START_LOG
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
else
echo "配置文件【$name】没有任何更新,停止继续操作..." >$START_LOG
rm -rf "$CFG_FILE"
echo "${LOGTIME} Updated Config【$name】 No Change, Do Nothing" >>$LOG_FILE
sleep 5
echo "" >$START_LOG
fi
else
echo "配置文件下载成功,本地没有配置文件,开始创建 ..." >$START_LOG
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
fi
}
config_encode()
{
/usr/share/openclash/yml_field_name_ch.sh "$CFG_FILE"
}
config_error()
{
echo "配置文件【$name】下载失败,请检查网络或稍后再试!" >$START_LOG
echo "${LOGTIME} Config 【$name】Update Error" >>$LOG_FILE
rm -rf "$CFG_FILE" 2>/dev/null
sleep 5
echo "" >$START_LOG
}
change_dns()
{
if pidof clash >/dev/null; then
if [ "$enable_redirect_dns" -ne 0 ]; then
uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=1 >/dev/null 2>&1
[ "$disable_masq_cache" -eq 1 ] && {
uci set dhcp.@dnsmasq[0].cachesize=0 >/dev/null 2>&1
}
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
nohup /usr/share/openclash/openclash_watchdog.sh &
fi
}
config_download_direct()
{
if pidof clash >/dev/null; then
echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG
kill_watchdog
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 3
config_download
if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then
change_dns
config_su_check
else
change_dns
config_error
fi
else
config_error
fi
}
sub_info_get()
{
local section="$1"
config_get_bool "enabled" "$section" "enabled" "1"
config_get "name" "$section" "name" ""
config_get "type" "$section" "type" ""
config_get "address" "$section" "address" ""
config_get "keyword" "$section" "keyword" ""
config_get "ex_keyword" "$section" "ex_keyword" ""
if [ "$enabled" -eq 0 ]; then
return
fi
if [ -z "$address" ]; then
return
else
subscribe_url="$address"
fi
if [ -z "$name" ]; then
name="config"
CONFIG_FILE="/etc/openclash/config/config.yaml"
BACKPACK_FILE="/etc/openclash/backup/config.yaml"
else
CONFIG_FILE="/etc/openclash/config/$name.yaml"
BACKPACK_FILE="/etc/openclash/backup/$name.yaml"
fi
URL_TYPE="$type"
echo "开始更新配置文件【$name】..." >$START_LOG
config_download
if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then
config_encode
if [ -n "$(grep "^ \{0,\}proxy-groups:" "$CFG_FILE")" ]; then
if [ -n "$(grep "^ \{0,\}Proxy:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}proxy-providers:" "$CFG_FILE" 2>/dev/null)" ]; then
if [ -n "$(grep "^ \{0,\}rules:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}script:" "$CFG_FILE" 2>/dev/null)" ]; then
config_su_check
else
config_download_direct
fi
else
config_download_direct
fi
else
config_download_direct
fi
else
config_download_direct
fi
}
#分别获取订阅信息进行处理
config_load "openclash"
config_foreach sub_info_get "config_subscribe"
uci delete openclash.config.config_update_path >/dev/null 2>&1
uci commit openclash
if [ "$if_restart" -eq 1 ]; then
/etc/init.d/openclash restart >/dev/null 2>&1
else
sed -i '/openclash.sh/d' $CRON_FILE 2>/dev/null
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE
/etc/init.d/cron restart
fi

View File

@ -16,6 +16,11 @@ function index()
entry({"admin", "services", "openclash", "startlog"},call("action_start")).leaf=true
entry({"admin", "services", "openclash", "close_all_connection"},call("action_close_all_connection"))
entry({"admin", "services", "openclash", "restore_history"},call("action_restore_history"))
entry({"admin", "services", "openclash", "get_history"},call("action_get_history"))
entry({"admin", "services", "openclash", "reload_firewall"},call("action_reload_firewall"))
entry({"admin", "services", "openclash", "update_subscribe"},call("action_update_subscribe"))
entry({"admin", "services", "openclash", "update_other_rules"},call("action_update_other_rules"))
entry({"admin", "services", "openclash", "update_geoip"},call("action_update_geoip"))
entry({"admin", "services", "openclash", "currentversion"},call("action_currentversion"))
entry({"admin", "services", "openclash", "lastversion"},call("action_lastversion"))
entry({"admin", "services", "openclash", "update"},call("action_update"))
@ -39,6 +44,7 @@ function index()
entry({"admin", "services", "openclash", "proxy-provider-file-manage"},form("openclash/proxy-provider-file-manage"), nil).leaf = true
entry({"admin", "services", "openclash", "rule-providers-file-manage"},form("openclash/rule-providers-file-manage"), nil).leaf = true
entry({"admin", "services", "openclash", "config-subscribe"},cbi("openclash/config-subscribe"),_("Config Update"), 60).leaf = true
entry({"admin", "services", "openclash", "config-subscribe-edit"},cbi("openclash/config-subscribe-edit"), nil).leaf = true
entry({"admin", "services", "openclash", "servers-config"},cbi("openclash/servers-config"), nil).leaf = true
entry({"admin", "services", "openclash", "groups-config"},cbi("openclash/groups-config"), nil).leaf = true
entry({"admin", "services", "openclash", "proxy-provider-config"},cbi("openclash/proxy-provider-config"), nil).leaf = true
@ -79,15 +85,15 @@ local function ipdb()
end
local function lhie1()
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/lhie1.yaml"))
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/lhie1.yaml"))
end
local function ConnersHua()
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/ConnersHua.yaml"))
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/ConnersHua.yaml"))
end
local function ConnersHua_return()
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/ConnersHua_return.yaml"))
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/usr/share/openclash/res/ConnersHua_return.yaml"))
end
local function chnroute()
@ -119,7 +125,7 @@ local function check_lastversion()
end
local function check_currentversion()
return luci.sys.exec("sed -n '/^data:image/,$p' /etc/openclash/openclash_version 2>/dev/null")
return luci.sys.exec("sed -n '/^data:image/,$p' /usr/share/openclash/res/openclash_version 2>/dev/null")
end
local function startlog()
@ -169,7 +175,7 @@ local function corelv()
end
local function opcv()
return luci.sys.exec("sed -n 1p /etc/openclash/openclash_version 2>/dev/null")
return luci.sys.exec("sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null")
end
local function oplv()
@ -386,6 +392,27 @@ function action_restore_history()
return luci.sys.call("sh /usr/share/openclash/openclash_history_set.sh")
end
function action_get_history()
return luci.sys.call("sh /usr/share/openclash/openclash_history_get.sh")
end
function action_reload_firewall()
return luci.sys.call("/etc/init.d/openclash reload")
end
function action_update_subscribe()
fs.unlink("/tmp/Proxy_Group")
return luci.sys.call("/usr/share/openclash/openclash.sh >/dev/null 2>&1")
end
function action_update_other_rules()
return luci.sys.call("/usr/share/openclash/openclash_rule.sh >/dev/null 2>&1")
end
function action_update_geoip()
return luci.sys.call("/usr/share/openclash/openclash_ipdb.sh >/dev/null 2>&1")
end
function act_ping()
local e={}
e.index=luci.http.formvalue("index")

View File

@ -13,7 +13,6 @@ m.description = translate("A Clash Client For OpenWrt")
m.pageaction = false
m:section(SimpleSection).template = "openclash/status"
m:section(SimpleSection).template = "openclash/state"
function IsYamlFile(e)
e=e or""

View File

@ -0,0 +1,147 @@
local m, s, o
local openclash = "openclash"
local uci = luci.model.uci.cursor()
local fs = require "luci.openclash"
local sys = require "luci.sys"
local sid = arg[1]
font_red = [[<font color="red">]]
font_off = [[</font>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map(openclash, translate("Config Subscribe Edit"))
m.pageaction = false
m.description=translate("Convert Subscribe function of Online is Supported By subconverter Written By tindy X") .. translate("<br/> \
<br/>API By tindy X & lhie1 \
<br/> \
<br/>subconverter ()https://github.com/tindy2013/subconverter#external-configuration-file \
<br/> \
<br/>()访使 \
<br/> \
<br/>() /usr/share/openclash/res/sub_ini.list PR")
m.redirect = luci.dispatcher.build_url("admin/services/openclash/config-subscribe")
if m.uci:get(openclash, sid) ~= "config_subscribe" then
luci.http.redirect(m.redirect)
return
end
-- [[ Config Subscribe Setting ]]--
s = m:section(NamedSection, sid, "config_subscribe")
s.anonymous = true
s.addremove = false
---- name
o = s:option(Value, "name", translate("Config Alias"))
o.description = font_red..bold_on..translate("(Name For Distinguishing)")..bold_off..font_off
o.placeholder = translate("config")
o.rmempty = true
---- address
o = s:option(Value, "address", translate("Subscribe Address"))
o.description = font_red..bold_on..translate("(Not Null)")..bold_off..font_off
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o.rmempty = false
---- subconverter
o = s:option(ListValue, "sub_convert", translate("Subscribe Convert Online"))
o.description = translate("Convert Subscribe Online With Template, Mix Proxies and Keep Settings options Will Not Effect")
o:value("0", translate("Disable"))
o:value("1", translate("Enable"))
o.default=0
---- Template
o = s:option(ListValue, "template", translate("Template Name"))
o.rmempty = true
o:depends("sub_convert", "1")
file = io.open("/usr/share/openclash/res/sub_ini.list", "r");
for l in file:lines() do
if l ~= "" and l ~= nil then
o:value(string.sub(luci.sys.exec(string.format("echo '%s' |awk -F ',' '{print $1}' 2>/dev/null",l)),1,-2))
end
end
file:close()
o:value("0", translate("Custom Template"))
---- Custom Template
o = s:option(Value, "custom_template_url", translate("Custom Template URL"))
o.rmempty = true
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o:depends("template", "0")
---- emoji
o = s:option(ListValue, "emoji", translate("Emoji"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default=0
o:depends("sub_convert", "1")
---- udp
o = s:option(ListValue, "udp", translate("UDP Enable"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default=0
o:depends("sub_convert", "1")
---- skip-cert-verify
o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default=0
o:depends("sub_convert", "1")
---- sort
o = s:option(ListValue, "sort", translate("Sort"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default=0
o:depends("sub_convert", "1")
---- node type
o = s:option(ListValue, "node_type", translate("Append Node Type"))
o.rmempty = false
o:value("false", translate("Disable"))
o:value("true", translate("Enable"))
o.default=0
o:depends("sub_convert", "1")
---- key
o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
---- exkey
o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
local t = {
{Commit, Back}
}
a = m:section(Table, t)
o = a:option(Button,"Commit")
o.inputtitle = translate("Commit Configurations")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
luci.http.redirect(m.redirect)
end
o = a:option(Button,"Back")
o.inputtitle = translate("Back Configurations")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash)
luci.http.redirect(m.redirect)
end
return m

View File

@ -62,15 +62,22 @@ o:depends("config_auto_update_mode", "1")
o.rmempty = true
-- [[ Edit Server ]] --
s = m:section(TypedSection, "config_subscribe")
s = m:section(TypedSection, "config_subscribe", translate("Config Subscribe Edit"))
s.anonymous = true
s.addremove = true
s.sortable = false
s.sortable = true
s.template = "cbi/tblsection"
s.rmempty = false
s.extedit = luci.dispatcher.build_url("admin/services/openclash/config-subscribe-edit/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
---- enable flag
o = s:option(Flag, "enabled", translate("Enable"), font_red..bold_on..translate("(Enable or Disable Subscribe)")..bold_off..font_off)
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
@ -78,36 +85,26 @@ o.cfgvalue = function(...)
end
---- name
o = s:option(Value, "name", translate("Config Alias"))
o.description = font_red..bold_on..translate("(Name For Distinguishing)")..bold_off..font_off
o.placeholder = translate("config")
o.rmempty = true
---- type
o = s:option(ListValue, "type", translate("Subscribe Type"))
o.description = font_red..bold_on..translate("(Power By fndroid)")..bold_off..font_off
o:value("clash", translate("Clash"))
o:value("v2rayn", translate("V2rayN"))
o:value("surge", translate("Surge"))
o.default="clash"
o.rempty = false
o = s:option(DummyValue, "name", translate("Config Alias"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("config")
end
---- address
o = s:option(Value, "address", translate("Subscribe Address"))
o.description = font_red..bold_on..translate("(Not Null)")..bold_off..font_off
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o.rmempty = false
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
---- key
o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
---- exkey
o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
---- template
o = s:option(DummyValue, "template", translate("Template Name"))
function o.cfgvalue(...)
if Value.cfgvalue(...) ~= "0" then
return Value.cfgvalue(...) or translate("None")
else
return translate("Custom Template")
end
end
local t = {
{Commit, Apply}

View File

@ -24,6 +24,26 @@ function IsYmlFile(e)
return e == ".yml"
end
function default_config_set(f)
local cf=string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 1, -2)
if cf == "/etc/openclash/config/"..f or not cf or cf == "" or not fs.isfile(cf) then
if CHIF == "1" and cf == "/etc/openclash/config/"..f then
return
end
local fis = fs.glob("/etc/openclash/config/*")[1]
if fis ~= nil then
fcf = fs.basename(fis)
if fcf then
luci.sys.exec(string.format('uci set openclash.config.config_path="/etc/openclash/config/%s"',fcf))
uci:commit("openclash")
end
else
luci.sys.exec("uci set openclash.config.config_path=/etc/openclash/config/config.yaml")
uci:commit("openclash")
end
end
end
function config_check(CONFIG_FILE)
local yaml = fs.isfile(CONFIG_FILE)
local proxy,group,rule
@ -106,11 +126,11 @@ HTTP.setfilehandler(
if not meta then return end
if fp == "config" then
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
elseif fp == "proxy-provider" then
if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end
if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end
elseif fp == "rule-provider" then
if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end
if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end
end
if not fd then
@ -124,23 +144,26 @@ HTTP.setfilehandler(
if eof and fd then
fd:close()
fd = nil
if IsYamlFile(meta.file) and fp == "config" then
local yamlbackup="/etc/openclash/backup/" .. meta.file
local c=fs.copy(dir .. meta.file,yamlbackup)
end
if IsYmlFile(meta.file) and fp == "config" then
local ymlname=string.lower(string.sub(meta.file,0,-5))
local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml"
local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml")
local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup)
end
if fp == "config" then
um.value = translate("File saved to") .. ' "/etc/openclash/config/"'
CHIF = "1"
CHIF = "1"
if IsYamlFile(meta.file) then
local yamlbackup="/etc/openclash/backup/" .. meta.file
local c=fs.copy(dir .. meta.file,yamlbackup)
default_config_set(meta.file)
end
if IsYmlFile(meta.file) then
local ymlname=string.lower(string.sub(meta.file,0,-5))
local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml"
local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml")
local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup)
local yamlname=ymlname .. ".yaml"
default_config_set(yamlname)
end
um.value = translate("File saved to") .. ' "/etc/openclash/config/"'
elseif fp == "proxy-provider" then
um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"'
um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"'
elseif fp == "rule-provider" then
um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"'
um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"'
end
fs.unlink("/tmp/Proxy_Group")
end
@ -259,11 +282,12 @@ Button.render(e,t,a)
end
btnrm.write=function(a,t)
fs.unlink("/tmp/Proxy_Group")
fs.unlink("/etc/openclash/backup/"..luci.openclash.basename(e[t].name))
fs.unlink("/etc/openclash/history/"..luci.openclash.basename(e[t].name))
local a=fs.unlink("/etc/openclash/config/"..luci.openclash.basename(e[t].name))
if a then table.remove(e,t)end
return a
fs.unlink("/etc/openclash/backup/"..fs.basename(e[t].name))
fs.unlink("/etc/openclash/history/"..fs.basename(e[t].name))
local a=fs.unlink("/etc/openclash/config/"..fs.basename(e[t].name))
default_config_set(fs.basename(e[t].name))
if a then table.remove(e,t)end
HTTP.redirect(DISP.build_url("admin", "services", "openclash","config"))
end
p = SimpleForm("provider_file_manage",translate("Provider File Manage"))
@ -301,7 +325,7 @@ local tab = {
s = m:section(Table, tab)
local conf = string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 1, -2)
local dconf = "/etc/openclash/default.yaml"
local dconf = "/usr/share/openclash/res/default.yaml"
local conf_name = fs.basename(conf)
if not conf_name or conf == "" then conf_name = "config.yaml" end

View File

@ -35,7 +35,7 @@ o.write = function()
end
if not NXFS.access("/tmp/rules_name") then
SYS.call("awk -F ',' '{print $1}' /etc/openclash/game_rules.list > /tmp/rules_name 2>/dev/null")
SYS.call("awk -F ',' '{print $1}' /usr/share/openclash/res/game_rules.list > /tmp/rules_name 2>/dev/null")
end
file = io.open("/tmp/rules_name", "r");
@ -49,9 +49,9 @@ for t,o in ipairs(e) do
e[t]={}
e[t].num=string.format(t)
e[t].name=o
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /etc/openclash/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2)
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2)
if e[t].filename == "" then
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /etc/openclash/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2)
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2)
end
RULE_FILE="/etc/openclash/game_rules/".. e[t].filename
if fs.mtime(RULE_FILE) then

View File

@ -95,6 +95,15 @@ o:depends("type", "select")
o:depends("type", "relay")
o.rmempty = true
o = s:option(DynamicList, "other_group_dr", translate("Other Group"))
o.description = font_red..bold_on..translate("The Added Proxy Groups Must Exist Except 'DIRECT' & 'REJECT'")..bold_off..font_off
o:value("DIRECT")
o:value("REJECT")
o:depends("type", "url-test")
o:depends("type", "fallback")
o:depends("type", "load-balance")
o.rmempty = true
local t = {
{Commit, Back}
}
@ -117,4 +126,4 @@ o.write = function()
luci.http.redirect(m.redirect)
end
return m
return m

View File

@ -35,7 +35,7 @@ o.write = function()
end
if not NXFS.access("/tmp/rule_providers_name") then
SYS.call("awk -v d=',' -F ',' '{print $4d$5}' /etc/openclash/rule_providers.list > /tmp/rule_providers_name 2>/dev/null")
SYS.call("awk -v d=',' -F ',' '{print $4d$5}' /usr/share/openclash/res/rule_providers.list > /tmp/rule_providers_name 2>/dev/null")
end
file = io.open("/tmp/rule_providers_name", "r");
@ -58,14 +58,14 @@ end
for t,o in ipairs(e) do
e[t]={}
e[t].num=string.format(t)
e[t].name=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",o)),1,-2)
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null",o)),1,-2)
e[t].name=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",o)),1,-2)
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $6}' 2>/dev/null",o)),1,-2)
if e[t].lfilename == "" then
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null",o)),1,-2)
e[t].lfilename=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $5}' 2>/dev/null",o)),1,-2)
end
e[t].filename=o
e[t].author=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $2}' 2>/dev/null",o)),1,-2)
e[t].rule_type=string.sub(luci.sys.exec(string.format("grep -F '%s' /etc/openclash/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null",o)),1,-2)
e[t].author=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $2}' 2>/dev/null",o)),1,-2)
e[t].rule_type=string.sub(luci.sys.exec(string.format("grep -F '%s' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $3}' 2>/dev/null",o)),1,-2)
RULE_FILE="/etc/openclash/rule_provider/".. e[t].lfilename
if fs.mtime(RULE_FILE) then
e[t].size=i(fs.stat(RULE_FILE).size)

View File

@ -87,7 +87,7 @@ for t,f in ipairs(fs.glob("/etc/openclash/game_rules/*"))do
e[t]={}
e[t].filename=fs.basename(f)
if IsRuleFile(e[t].filename) then
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /etc/openclash/game_rules.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
if e[t].name ~= "" and e[t].name ~= nil then
o:value(e[t].name)
end
@ -149,7 +149,7 @@ for t,f in ipairs(fs.glob("/etc/openclash/rule_provider/*"))do
e[t]={}
e[t].filename=fs.basename(f)
if IsYamlFile(e[t].filename) or IsYmlFile(e[t].filename) then
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /etc/openclash/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
e[t].name=string.gsub(luci.sys.exec(string.format("grep ',%s$' /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $1}' 2>/dev/null",e[t].filename)), "[\r\n]", "")
if e[t].name ~= "" and e[t].name ~= nil then
o:value(e[t].name)
end

View File

@ -194,7 +194,7 @@ o.inputstyle = "reload"
o.write = function()
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
SYS.call("/usr/share/openclash/openclash_fake_filter.sh >/dev/null 2>&1 && /etc/init.d/openclash restart >/dev/null 2>&1 &")
SYS.call("rm -rf /etc/openclash/fake_filter.list >/dev/null 2>&1 && /etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
@ -248,22 +248,31 @@ o:value("0", translate("Black List Mode"))
o:value("1", translate("White List Mode"))
o.default=0
o = s:taboption("lan_ac", DynamicList, "lan_ac_black_ips", translate("LAN Bypassed Host List"))
o:depends("lan_ac_mode", "0")
o.datatype = "ipaddr"
luci.ip.neighbors({ family = 4 }, function(entry)
if entry.reachable then
o:value(entry.dest:string())
end
end)
ip_b = s:taboption("lan_ac", DynamicList, "lan_ac_black_ips", translate("LAN Bypassed Host List"))
ip_b:depends("lan_ac_mode", "0")
ip_b.datatype = "ipaddr"
o = s:taboption("lan_ac", DynamicList, "lan_ac_white_ips", translate("LAN Proxied Host List"))
o:depends("lan_ac_mode", "1")
o.datatype = "ipaddr"
luci.ip.neighbors({ family = 4 }, function(entry)
if entry.reachable then
o:value(entry.dest:string())
end
mac_b = s:taboption("lan_ac", DynamicList, "lan_ac_black_macs", translate("LAN Bypassed Mac List"))
mac_b.datatype = "list(macaddr)"
mac_b.rmempty = true
mac_b:depends("lan_ac_mode", "0")
ip_w = s:taboption("lan_ac", DynamicList, "lan_ac_white_ips", translate("LAN Proxied Host List"))
ip_w:depends("lan_ac_mode", "1")
ip_w.datatype = "ipaddr"
mac_w = s:taboption("lan_ac", DynamicList, "lan_ac_white_macs", translate("LAN Proxied Mac List"))
mac_w.datatype = "list(macaddr)"
mac_w.rmempty = true
mac_w:depends("lan_ac_mode", "1")
luci.ip.neighbors({ family = 4 }, function(n)
if n.mac and n.dest then
ip_b:value(n.dest:string())
ip_w:value(n.dest:string())
mac_b:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
mac_w:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
end
end)
end

View File

@ -1,17 +1,18 @@
<fieldset class="cbi-section">
<table>
<tr>
<td width="9%" align="center" id="_Dreamacro"><%:Collecting data...%></td>
<td width="9%" align="center" id="_vernesong"><%:Collecting data...%></td>
<td width="9%" align="center" id="_frainzy1477"><%:Collecting data...%></td>
<td width="9%" align="center" id="_SukkaW"><%:Collecting data...%></td>
<td width="9%" align="center" id="_lhie1_dev"><%:Collecting data...%></td>
<td width="9%" align="center" id="_ConnersHua_dev"><%:Collecting data...%></td>
<td width="9%" align="center" id="_haishanh"><%:Collecting data...%></td>
<td width="9%" align="center" id="_MaxMind"><%:Collecting data...%></td>
<td width="9%" align="center" id="_FQrabbit"><%:Collecting data...%></td>
<td width="9%" align="center" id="_Fndroid"><%:Collecting data...%></td>
<td width="9%" align="center" id="_Alecthw"><%:Collecting data...%></td>
<td width="8%" align="center" id="_Dreamacro"><%:Collecting data...%></td>
<td width="8%" align="center" id="_vernesong"><%:Collecting data...%></td>
<td width="8%" align="center" id="_frainzy1477"><%:Collecting data...%></td>
<td width="8%" align="center" id="_SukkaW"><%:Collecting data...%></td>
<td width="8%" align="center" id="_lhie1_dev"><%:Collecting data...%></td>
<td width="8%" align="center" id="_ConnersHua_dev"><%:Collecting data...%></td>
<td width="8%" align="center" id="_haishanh"><%:Collecting data...%></td>
<td width="8%" align="center" id="_MaxMind"><%:Collecting data...%></td>
<td width="8%" align="center" id="_FQrabbit"><%:Collecting data...%></td>
<td width="8%" align="center" id="_Fndroid"><%:Collecting data...%></td>
<td width="8%" align="center" id="_Alecthw"><%:Collecting data...%></td>
<td width="8%" align="center" id="_Tindy_X"><%:Collecting data...%></td>
</tr>
</table>
</fieldset>
@ -28,6 +29,7 @@
var FQrabbit = document.getElementById('_FQrabbit');
var Fndroid = document.getElementById('_Fndroid');
var Alecthw = document.getElementById('_Alecthw');
var Tindy_X = document.getElementById('_Tindy_X');
Dreamacro.innerHTML = '<img src="https://avatars3.githubusercontent.com/u/8615343?s=460&v=4" loading="lazy" style="border-radius:50%;" title="Dreamacro" alt="Dreamacro" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Dreamacro_rediret()" />';
vernesong.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/42875168?s=460&v=4" loading="lazy" style="border-radius:50%;" title="vernesong" alt="vernesong" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return vernesong_rediret()" />';
frainzy1477.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/49537471?s=460&v=4" loading="lazy" style="border-radius:50%;" title="frainzy1477" alt="frainzy1477" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return frainzy1477_rediret()" />';
@ -39,7 +41,8 @@
FQrabbit.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/29931248?s=460&v=4" loading="lazy" style="border-radius:50%;" title="FQrabbit" alt="FQrabbit" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return FQrabbit_rediret()" />';
Fndroid.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/16091562?s=400&v=4" loading="lazy" style="border-radius:50%;" title="Fndroid" alt="Fndroid" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Fndroid_rediret()" />';
Alecthw.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/22856212?s=460&u=c8b48950a87572e5887ef836cf7dc1a97be7a7fd&v=4" loading="lazy" style="border-radius:50%;" title="Alecthw" alt="Alecthw" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Alecthw_rediret()" />';
Tindy_X.innerHTML = '<img src="https://avatars0.githubusercontent.com/u/49061470?s=460&u=22a89312bf2de411e87340e04b5f9d149f7366cc&v=4" loading="lazy" style="border-radius:50%;" title="Tindy X" alt="Tindy X" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Tindy_X_rediret()" />';
function Dreamacro_rediret()
{
url1='https://github.com/Dreamacro';
@ -96,6 +99,12 @@
window.open(url13);
};
function Tindy_X_rediret()
{
url14='https://github.com/tindy2013';
window.open(url14);
};
function imgerrorfun(imgobj,imgSrc){
setTimeout(function(){
imgobj.src=imgSrc;

View File

@ -1,3 +1,44 @@
<style>
#hid_btn {
display: block;
width: 18px;
margin:0 auto;
}
.rotate{
transform-origin:center center;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transition: transform 0.2s;
-moz-transition: -moz-transform 0.2s;
-moz-transition: -moz-transform 0.2s;
-o-transition: -o-transform 0.2s;
-ms-transition: -ms-transform 0.2s;
}
.rotate1{
transform-origin:center center;
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transition: transform 0.2s;
-moz-transition: -moz-transform 0.2s;
-moz-transition: -moz-transform 0.2s;
-o-transition: -o-transform 0.2s;
-ms-transition: -ms-transform 0.2s;
}
.rotate2{
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
}
</style>
<fieldset class="cbi-section">
<table width="100%">
<tr>
@ -31,10 +72,31 @@
<tr><td width="25%"> OpenClash 守护程序 </td><td width="25%" align="left" id="_watchdog"><%:Collecting data...%></td><td width="25%"> 控制面板登录端口 </td><td width="25%" align="left" id="_dapo"><%:Collecting data...%></td></tr>
<tr><td width="25%"> OpenClash 运行模式 </td><td width="25%" align="left" id="_mode"><%:Collecting data...%></td><td width="25%"> 控制面板登录密钥 </td><td width="25%" align="left" id="_dase"><%:Collecting data...%></td></tr>
<tr><td width="25%"> Yacd 控制面板 </td><td width="25%" align="left" id="_web"><%:Collecting data...%></td><td width="25%"> Dashboard 控制面板 </td><td width="25%" align="left" id="_webo"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4"><p align="center"><img id="hid_btn" alt="Show More" height="20px" onclick="return hid_btn_action()"/></p></td></tr>
<tr id="hid_1"><td width="100%" colspan="4"><p align="center"><b> 常用操作快捷按钮 </b></p></td></tr>
<tr id="hid_2"><td width="25%" align="center" id="_get_history"><%:Collecting data...%></td>
<td width="25%" align="center" id="_restore_history"><%:Collecting data...%></td>
<td width="25%" align="center" id="_close_all_connection"><%:Collecting data...%></td>
<td width="25%" align="center" id="_reload_firewall"><%:Collecting data...%></td></tr>
<tr id="hid_3"><td width="25%" align="center" id="_update_subscribe"><%:Collecting data...%></td>
<td width="25%" align="center" id="_one_key_update"><%:Collecting data...%></td>
<td width="25%" align="center" id="_update_other_rules"><%:Collecting data...%></td>
<td width="25%" align="center" id="_update_geoip"><%:Collecting data...%></td>
</tr>
</table>
</fieldset>
<fieldset id="state" class="cbi-section">
<table>
<tr><td width="100%" colspan="4">
<p align="center">
<b> 组件的状态显示,运行前请确保各项目显示正常,需要更新请到全局设置页面操作 </b>
</p>
</td></tr>
<tr><td width="25%"> 策略组节点选择 备份日期 </td><td width="25%" align="left" id="_historychecktime"><%:Collecting data...%></td><td width="25%"> lhie1 规则更新日期 </td><td width="25%" align="left" id="_lhie1"><%:Collecting data...%></td></tr>
<tr><td width="25%"> ConnersHua 规则更新日期 </td><td width="25%" align="left" id="_ConnersHua"><%:Collecting data...%></td><td width="25%"> ConnersHua 回国规则更新日期 </td><td width="25%" align="left" id="_ConnersHua_return"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 大陆IP白名单 更新日期 </td><td width="25%" align="left" id="_chnroute"><%:Collecting data...%></td><td width="25%"> GEOIPBy MaxMind数据库日期 </td><td width="25%" align="left" id="_ipdb"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var clash = document.getElementById('_clash');
var mode = document.getElementById('_mode');
@ -48,8 +110,68 @@
var close_all_connection = document.getElementById('_close_all_connection');
var restore_history = document.getElementById('_restore_history');
var get_history = document.getElementById('_get_history');
var reload_firewall = document.getElementById('_reload_firewall');
var one_key_update = document.getElementById('_one_key_update');
var update_subscribe = document.getElementById('_update_subscribe');
var update_other_rules = document.getElementById('_update_other_rules');
var update_geoip = document.getElementById('_update_geoip');
var ipdb = document.getElementById('_ipdb');
var lhie1 = document.getElementById('_lhie1');
var ConnersHua = document.getElementById('_ConnersHua');
var ConnersHua_return = document.getElementById('_ConnersHua_return');
var chnroute = document.getElementById('_chnroute');
var historychecktime = document.getElementById('_historychecktime');
var hid_1 = document.getElementById("hid_1");
var hid_2 = document.getElementById("hid_2");
var hid_3 = document.getElementById("hid_3");
var state = document.getElementById("state");
var hid_btn = document.getElementById("hid_btn");
var hid_btn_if = true;
var arrow="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABoCAMAAACkGAzvAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkYzOTBCNjQ4RkMyMTExRUE4QzgwOUMwRjlGNTNBMzY3IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkYzOTBCNjQ5RkMyMTExRUE4QzgwOUMwRjlGNTNBMzY3Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6RjM5MEI2NDZGQzIxMTFFQThDODA5QzBGOUY1M0EzNjciIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6RjM5MEI2NDdGQzIxMTFFQThDODA5QzBGOUY1M0EzNjciLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7+mRMLAAAAaVBMVEUQEBDv7+/Pz88wMDBQUFAgICC/v79wcHBgYGBAQECfn5+Pj49/f3/f39+vr6/s7Ox9fX2ysrLT09NbW1v09PQ6OjonJyd8fHwRERHk5OSenp4WFhZOTk4BAQHh4eGMjIwDAwMAAAD///+EZwwxAAAAI3RSTlP/////////////////////////////////////////////AGYpg5YAAAKoSURBVHja7Fppd5tADNQCC+ZskzZHz1T+/z+yNvjAhkWaBaXte9XHRDvPHoOkGS3tLYPeBd1VGTFzWuQrwNo6S5nKK8YJvT5CD1Emsdi7C4bPx+jXvx+jjgLvaIzRXNFvwQ8f38HY7h6jOKN3fB+Esp+kE4xuQHfE02gg8GoGwg/oFc8FwM6ElSGqHj2b/R9TF89KH1mPThyIQgVeh877Hp2DkbYyK1n4uIAus5N4jkeX2KkXz/bo5WJKmkSxcjzZoxeLOUxVDCvD1z6gtyzEzuGsHCIZKsFOypthx5XSoexUZ5yXMifs5CQececamYi5nN2w04j5lFzru0vFdJ8ArJyzSf1pLk1FZuXyHJCeyRM7Claq6Uyg+b75vpWzRk8YQb8VF3pWJvOMgh3s2SWkcshxV7MJfb+hikpobYK6AaF1FepkFFP91H2GkC6/xEqun7DdDgQPTD8ETFfhaFB1ALATnjoJnd+gmZDUEznKiqibWqip4KqsgBoirPmW2ZE0kKgoF9jxon5T6NUmjhWtGp5tKsEBENbaMy03ValapZJvVKNltE+Qe5QVyIUYNRUdK6DHUUNiDXZQHp+Zf3x7sPJnPr99+vjh73N//qOvQ//6/eWLFfrPp1/Mr50N+rmRWLxNoxFBYX2A6DfjzdZV7H4027ICzwzd23WPWcGwVeerIesDQ1+QIusnjtxyWmoMJz29mRGBrpPedRx6YagOWktl0xmqMlcYKkpTNVyRnZKHdTbiQpg6KJbuz3rnKgmjr2BFdt0sHUNdQYx0O02d2m1d5uzGZTZ1yE3dfZvNRLtfsVUR37vTVsV2I2S7zbLdxNluEf/UBnSL7e3KzXO1vHm23ZrbbvxtbysY3bTI3+WWiPENF+PbOdvdLCrZT28W/ZPe0m8BBgDHY8G52E6VGwAAAABJRU5ErkJggg=="
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
hid_1.style.display = "none";
hid_2.style.display = "none";
hid_3.style.display = "none";
state.style.display="none";
hid_btn.src=arrow;
function hid_btn_action() {
if (hid_btn_if) {
hid_1.style.display = "";
hid_2.style.display = "";
hid_3.style.display = "";
state.style.display = "block";
hid_btn.className="rotate";
hid_btn_if = false;
} else {
hid_1.style.display = "none";
hid_2.style.display = "none";
hid_3.style.display = "none";
state.style.display = "none";
hid_btn.className="rotate1";
hid_btn_if = true;
}
if (hid_btn.className == "rotate1"){
setTimeout('hid_btn.className="rotate2"',200);
}
}
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
ipdb.innerHTML = status.ipdb ? "<b><font color=green>"+status.ipdb+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
lhie1.innerHTML = status.lhie1 ? "<b><font color=green>"+status.lhie1+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua.innerHTML = status.ConnersHua ? "<b><font color=green>"+status.ConnersHua+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua_return.innerHTML = status.ConnersHua_return ? "<b><font color=green>"+status.ConnersHua_return+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
chnroute.innerHTML = status.chnroute ? "<b><font color=green>"+status.chnroute+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
if ( status.historychecktime != "0" ) {
historychecktime.innerHTML = "<b><font color=green>"+status.historychecktime+"</font></b>";
}
else {
historychecktime.innerHTML = "<b><font color=green>"+"<%:暂未备份%>"+"</font></b>";
}
}
});
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
clash.innerHTML = status.clash ? '<b><font color=green><%:RUNNING%></font></b>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
if ( status.mode == "fake-ip\n" )
@ -90,9 +212,31 @@
dapo.innerHTML = status.cn_port ? "<b><font color=green>"+status.cn_port+"</font></b>" : "<b><font color=red>"+"<%:Not Set%>"+"</font></b>";
web.innerHTML = status.web ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:打开控制面板%>" onclick="return ycad_dashboard(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
webo.innerHTML = status.web ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:打开控制面板%>" onclick="return net_dashboard(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
close_all_connection.innerHTML = status.clash ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:重置所有链接%>" onclick="return b_close_all_connection(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
restore_history.innerHTML = status.clash ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:还原策略组节点选择%>" onclick="return b_restore_history(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
get_history.innerHTML = status.clash ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:保存策略组节点选择%>" onclick="return b_get_history(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
reload_firewall.innerHTML = status.clash ? '<input type="button" class="cbi-button cbi-button-reload" value="<%:重置防火墙规则%>" onclick="return b_reload_firewall(this)"/>' : '<b><font color=red><%:NOT RUNNING%></font></b>';
one_key_update.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:插件和内核检查更新%>" onclick="return all_one_key_update(this)"/>';
update_subscribe.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:配置文件检查更新%>" onclick="return b_update_subscribe(this)"/>';
update_other_rules.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:第三方规则检查更新%>" onclick="return b_update_other_rules(this)"/>';
update_geoip.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:GEOIP数据库检查更新%>" onclick="return b_update_geoip(this)"/>';
}
});
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "openclash", "state")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
ipdb.innerHTML = status.ipdb ? "<b><font color=green>"+status.ipdb+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
lhie1.innerHTML = status.lhie1 ? "<b><font color=green>"+status.lhie1+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua.innerHTML = status.ConnersHua ? "<b><font color=green>"+status.ConnersHua+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
ConnersHua_return.innerHTML = status.ConnersHua_return ? "<b><font color=green>"+status.ConnersHua_return+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
chnroute.innerHTML = status.chnroute ? "<b><font color=green>"+status.chnroute+"</font></b>" : "<b><font color=red>"+"<%:File Not Exist%>"+"</font></b>";
if ( status.historychecktime != "0" ) {
historychecktime.innerHTML = "<b><font color=green>"+status.historychecktime+"</font></b>";
}
else {
historychecktime.innerHTML = "<b><font color=green>"+"<%:暂未备份%>"+"</font></b>";
}
}
});
function winOpen(url)
{
var winOpen = window.open(url);
@ -101,6 +245,102 @@
}
}
function all_one_key_update(btn)
{
btn.value = '<%:插件和内核检查更新%>';
btn.disabled = true;
var r = confirm("确定要一键检查并更新所有内核及插件吗?")
if (r == true) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0\n" ) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
alert('一键检查更新正在进行...')
}
else {
alert('一键检查更新失败,请稍后再试!')
}
});
}
else {
alert('未选择编译版本,请到常规设置标签中配置!')
}
}
else {
alert('一键检查更新失败,请稍后再试!')
}
});
}
else {
}
btn.disabled = false;
return false;
}
function b_update_other_rules(btn)
{
btn.disabled = true;
btn.value = '<%:正在检查更新...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_other_rules")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:第三方规则检查更新%>';
}
else {
btn.disabled = false;
btn.value = '<%:第三方规则检查更新%>';
}
return false;
});
}
function b_update_geoip(btn)
{
btn.disabled = true;
btn.value = '<%:正在检查更新...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_geoip")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:GEOIP数据库检查更新%>';
}
else {
btn.disabled = false;
btn.value = '<%:GEOIP数据库检查更新%>';
}
return false;
});
}
function b_update_subscribe(btn)
{
btn.disabled = true;
btn.value = '<%:正在检查更新...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_subscribe")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:配置文件检查更新%>';
}
else {
btn.disabled = false;
btn.value = '<%:配置文件检查更新%>';
}
return false;
});
}
function b_reload_firewall(btn)
{
btn.disabled = true;
btn.value = '<%:正在重置...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "reload_firewall")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:重置防火墙规则%>';
}
else {
btn.disabled = false;
btn.value = '<%:防火墙规则重置失败%>';
}
return false;
});
}
function b_close_all_connection(btn)
{
btn.disabled = true;
@ -110,6 +350,10 @@
btn.disabled = false;
btn.value = '<%:重置所有链接%>';
}
else {
btn.disabled = false;
btn.value = '<%:重置链接失败%>';
}
return false;
});
}
@ -120,7 +364,11 @@
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "restore_history")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:手动还原策略组选择%>';
btn.value = '<%:还原策略组节点选择%>';
}
else {
btn.disabled = false;
btn.value = '<%:还原失败%>';
}
return false;
});
@ -132,7 +380,11 @@
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "get_history")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
btn.disabled = false;
btn.value = '<%:手动保存策略组选择%>';
btn.value = '<%:保存策略组节点选择%>';
}
else {
btn.disabled = false;
btn.value = '<%:保存失败%>';
}
return false;
});
@ -287,3 +539,4 @@
}
});
//]]></script>

View File

@ -41,6 +41,9 @@ msgstr "DNS设置"
msgid "Config Update"
msgstr "配置文件订阅"
msgid "Config Subscribe Edit"
msgstr "编辑配置文件订阅信息"
msgid "Rules Update"
msgstr "第三方规则订阅"
@ -840,12 +843,6 @@ msgstr "(用于区分,请勿重名)"
msgid "Subscribe Address"
msgstr "订阅地址"
msgid "Subscribe Type"
msgstr "订阅地址类型"
msgid "(Power By fndroid)"
msgstr "API提供Fndroid"
msgid "(Not Null)"
msgstr "(空值无效)"
@ -982,14 +979,20 @@ msgid "White List Mode"
msgstr "白名单模式"
msgid "LAN Bypassed Host List"
msgstr "不走代理的局域网LAN IP"
msgstr "不走代理的局域网设备 IP"
msgid "LAN Proxied Host List"
msgstr "走代理的局域网LAN IP"
msgstr "走代理的局域网设备 IP"
msgid "WAN Bypassed Host List"
msgstr "不走代理的WAN IP"
msgid "LAN Bypassed Mac List"
msgstr "不走代理的局域网设备 Mac"
msgid "LAN Proxied Mac List"
msgstr "走代理的局域网设备 Mac"
msgid "In The Fake-IP Mode, Only Pure IP Requests Are Supported"
msgstr "在Fake-IP模式下只支持过滤纯IP类型的请求"
@ -1006,4 +1009,34 @@ msgid "Config File Edit"
msgstr "配置文件编辑"
msgid "Delete All File"
msgstr "删除所有文件"
msgstr "删除所有文件"
msgid "Template Name"
msgstr "订阅转换模板"
msgid "Subscribe Convert Online"
msgstr "在线订阅转换"
msgid "Custom Template URL"
msgstr "自定义模板地址"
msgid "Custom Template"
msgstr "自定义模板"
msgid "Emoji"
msgstr "添加Emoji"
msgid "skip-cert-verify"
msgstr "跳过证书验证"
msgid "Sort"
msgstr "排序"
msgid "Append Node Type"
msgstr "插入节点类型"
msgid "Convert Subscribe Online With Template, Mix Proxies and Keep Settings options Will Not Effect"
msgstr "根据模板在线转换配置文件,混合节点和保留配置功能将不可用"
msgid "Convert Subscribe function of Online is Supported By subconverter Written By tindy X"
msgstr "在线订阅转换功能由tindy X通过subconverter提供支持"

View File

@ -27,6 +27,7 @@ config openclash 'config'
option lan_ac_mode '0'
option operation_mode 'redir-host'
option enable_rule_proxy '0'
option redirect_dns '0'
config dns_servers
option group 'nameserver'
@ -52,6 +53,12 @@ config dns_servers
option ip '223.5.5.5'
option enabled '1'
config dns_servers
option enabled '1'
option group 'nameserver'
option ip 'doh.rixcloud.dev/dns-query'
option type 'https'
config dns_servers
option type 'https'
option group 'fallback'

View File

@ -0,0 +1,55 @@
#!/bin/sh
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci add ucitrack openclash >/dev/null 2>&1
uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci set firewall.openclash=include >/dev/null 2>&1
uci set firewall.openclash.type=script >/dev/null 2>&1
uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1
uci set firewall.openclash.reload=1 >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
mkdir -p /etc/openclash/config >/dev/null 2>&1
mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1
mkdir -p /etc/openclash/backup >/dev/null 2>&1
mkdir -p /etc/openclash/core >/dev/null 2>&1
mkdir -p /etc/openclash/history >/dev/null 2>&1
mkdir -p /usr/share/openclash/backup >/dev/null 2>&1
cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1
cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
/etc/openclash/
EOF
if [ -f "/tmp/openclash.bak" ]; then
mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1
cp -rf "/tmp/openclash_config/." "/etc/openclash/config/" >/dev/null 2>&1
cp -rf "/tmp/openclash_core/." "/etc/openclash/core/" >/dev/null 2>&1
cp -rf "/tmp/openclash_history/." "/etc/openclash/history/" >/dev/null 2>&1
cp -rf "/tmp/openclash_proxy_provider/." "/etc/openclash/proxy_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_game_rules/." "/etc/openclash/game_rules/" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash" >/dev/null 2>&1
rm -rf /tmp/openclash* >/dev/null 2>&1
fi
uci set openclash.config.enable=0 >/dev/null 2>&1
uci commit openclash >/dev/null 2>&1
rm -f /tmp/luci-indexcache
exit 0

View File

@ -19,7 +19,7 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core_version -o $LAST_OPVER >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
echo "CheckTime:$CKTIME" >>$LAST_OPVER

View File

@ -0,0 +1,324 @@
#!/bin/bash
. /lib/functions.sh
. /usr/share/openclash/openclash_ps.sh
status=$(unify_ps_status "openclash.sh")
[ "$status" -gt 3 ] && exit 0
START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/openclash.log"
CFG_FILE="/tmp/config.yaml"
CRON_FILE="/etc/crontabs/root"
CONFIG_PATH=$(uci get openclash.config.config_path 2>/dev/null)
servers_update=$(uci get openclash.config.servers_update 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
if_restart=0
urlencode() {
local data
if [ "$#" -eq 1 ]; then
data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")
if [ ! -z "$data" ]; then
echo "$(echo ${data##/?} |sed 's/\//%2f/g' |sed 's/:/%3a/g' |sed 's/?/%3f/g' |sed 's/(/%28/g' |sed 's/)/%29/g' |sed 's/\^/%5e/g' |sed 's/=/%3d/g' |sed 's/|/%7c/g')"
fi
fi
}
kill_watchdog() {
watchdog_pids=$(unify_ps_pids "openclash_watchdog.sh")
for watchdog_pid in $watchdog_pids; do
kill -9 "$watchdog_pid" >/dev/null 2>&1
done
}
config_download()
{
if [ -n "$subscribe_url_param" ]; then
curl -sL --connect-timeout 10 --retry 2 https://api.dler.io/sub"$subscribe_url_param" -o "$CFG_FILE" >/dev/null 2>&1
if [ "$?" -ne 0 ]; then
curl -sL --connect-timeout 10 --retry 2 https://subcon.dlj.tf/sub"$subscribe_url_param" -o "$CFG_FILE" >/dev/null 2>&1
fi
else
curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
fi
}
config_cus_up()
{
if [ -z "$CONFIG_PATH" ]; then
CONFIG_PATH="/etc/openclash/config/$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')"
uci set openclash.config.config_path="$CONFIG_PATH"
uci commit openclash
fi
if [ -z "$subscribe_url_param" ]; then
if [ "$servers_update" -eq 1 ] || [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then
echo "配置文件【$name】替换成功,开始挑选节点..." >$START_LOG
uci set openclash.config.config_update_path="/etc/openclash/config/$name.yaml"
uci set openclash.config.servers_if_update=1
uci commit openclash
/usr/share/openclash/yml_groups_get.sh
uci set openclash.config.servers_if_update=1
uci commit openclash
/usr/share/openclash/yml_groups_set.sh
if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
if_restart=1
fi
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
echo "配置文件【$name】更新成功!" >$START_LOG
sleep 3
echo "" >$START_LOG
elif [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
echo "配置文件【$name】更新成功!" >$START_LOG
sleep 3
if_restart=1
else
echo "配置文件【$name】更新成功!" >$START_LOG
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
sleep 3
echo "" >$START_LOG
fi
else
if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
echo "配置文件【$name】更新成功!" >$START_LOG
sleep 3
if_restart=1
else
echo "配置文件【$name】更新成功!" >$START_LOG
echo "${LOGTIME} Config 【$name】 Update Successful" >>$LOG_FILE
sleep 3
echo "" >$START_LOG
fi
fi
rm -rf /tmp/Proxy_Group 2>/dev/null
}
config_su_check()
{
echo "配置文件下载成功,检查是否有更新..." >$START_LOG
sed -i 's/!<str> //g' "$CFG_FILE" >/dev/null 2>&1
if [ -f "$CONFIG_FILE" ]; then
cmp -s "$BACKPACK_FILE" "$CFG_FILE"
if [ "$?" -ne 0 ]; then
echo "配置文件【$name】有更新,开始替换..." >$START_LOG
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
else
echo "配置文件【$name】没有任何更新,停止继续操作..." >$START_LOG
rm -rf "$CFG_FILE"
echo "${LOGTIME} Updated Config【$name】 No Change, Do Nothing" >>$LOG_FILE
sleep 5
echo "" >$START_LOG
fi
else
echo "配置文件下载成功,本地没有配置文件,开始创建 ..." >$START_LOG
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
fi
}
config_encode()
{
/usr/share/openclash/yml_field_name_ch.sh "$CFG_FILE"
}
config_error()
{
echo "配置文件【$name】下载失败,请检查网络或稍后再试!" >$START_LOG
echo "${LOGTIME} Config 【$name】Update Error" >>$LOG_FILE
rm -rf "$CFG_FILE" 2>/dev/null
sleep 5
echo "" >$START_LOG
}
change_dns()
{
if pidof clash >/dev/null; then
if [ "$enable_redirect_dns" -ne 0 ]; then
uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=1 >/dev/null 2>&1
[ "$disable_masq_cache" -eq 1 ] && {
uci set dhcp.@dnsmasq[0].cachesize=0 >/dev/null 2>&1
}
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi
nohup /usr/share/openclash/openclash_watchdog.sh &
fi
}
config_download_direct()
{
if pidof clash >/dev/null; then
echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG
kill_watchdog
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 3
config_download
if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then
change_dns
config_su_check
else
change_dns
config_error
fi
else
config_error
fi
}
server_key_match()
{
local key_match key_word
if [ -n "$(echo "$1" |grep "^ \{0,\}$")" ] || [ -n "$(echo "$1" |grep "^\t\{0,\}$")" ]; then
return
fi
if [ -n "$(echo "$1" |grep "&")" ]; then
key_word=$(echo "$1" |sed 's/&/ /g')
for k in $key_word
do
if [ -z "$k" ]; then
continue
fi
k="(?=.*$k)"
key_match="$key_match$k"
done
key_match="^($key_match).*"
else
if [ -n "$1" ]; then
key_match="($1)"
fi
fi
if [ "$2" = "keyword" ]; then
if [ -z "$key_match_param" ]; then
key_match_param="$key_match"
else
key_match_param="$key_match_param|$key_match"
fi
elif [ "$2" = "ex_keyword" ]; then
if [ -z "$key_ex_match_param" ]; then
key_ex_match_param="$key_match"
else
key_ex_match_param="$key_ex_match_param|$key_match"
fi
fi
}
sub_info_get()
{
local section="$1" subscribe_url template_path subscribe_url_param template_path_encode key_match_param key_ex_match_param
config_get_bool "enabled" "$section" "enabled" "1"
config_get "name" "$section" "name" ""
config_get "sub_convert" "$section" "sub_convert" ""
config_get "address" "$section" "address" ""
config_get "keyword" "$section" "keyword" ""
config_get "ex_keyword" "$section" "ex_keyword" ""
config_get "emoji" "$section" "emoji" ""
config_get "udp" "$section" "udp" ""
config_get "skip_cert_verify" "$section" "skip_cert_verify" ""
config_get "sort" "$section" "sort" ""
config_get "template" "$section" "template" ""
config_get "node_type" "$section" "node_type" ""
config_get "custom_template_url" "$section" "custom_template_url" ""
if [ "$enabled" -eq 0 ]; then
return
fi
if [ -z "$address" ]; then
return
fi
if [ -z "$name" ]; then
name="config"
CONFIG_FILE="/etc/openclash/config/config.yaml"
BACKPACK_FILE="/etc/openclash/backup/config.yaml"
else
CONFIG_FILE="/etc/openclash/config/$name.yaml"
BACKPACK_FILE="/etc/openclash/backup/$name.yaml"
fi
if [ "$sub_convert" -eq 0 ]; then
subscribe_url=$address
elif [ "$sub_convert" -eq 1 ] && [ -n "$template" ]; then
subscribe_url=$(urlencode "$address")
if [ "$template" != "0" ]; then
template_path=$(grep "^$template," /usr/share/openclash/res/sub_ini.list |awk -F ',' '{print $3}' 2>/dev/null)
else
template_path=$custom_template_url
fi
if [ -n "$template_path" ]; then
template_path_encode=$(urlencode "$template_path")
if [ ! -z "$keyword" ] || [ ! -z "$ex_keyword" ]; then
config_list_foreach "$section" "keyword" server_key_match "keyword"
config_list_foreach "$section" "ex_keyword" server_key_match "ex_keyword"
[ -n "$key_match_param" ] && key_match_param=$(urlencode "$key_match_param")
[ -n "$key_ex_match_param" ] && key_ex_match_param=$(urlencode "$key_ex_match_param")
fi
subscribe_url_param="?target=clash&new_name=true&url=$subscribe_url&config=$template_path_encode&include=$key_match_param&exclude=$key_ex_match_param&emoji=$emoji&list=false&sort=$sort&udp=$udp&scv=$skip_cert_verify&append_type=$node_type&fdn=true"
else
subscribe_url=$address
fi
else
subscribe_url=$address
fi
echo "开始更新配置文件【$name】..." >$START_LOG
config_download
if [ "$?" -eq 0 ] && [ -s "$CFG_FILE" ]; then
config_encode
if [ -n "$(grep "^ \{0,\}proxy-groups:" "$CFG_FILE")" ]; then
if [ -n "$(grep "^ \{0,\}Proxy:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}proxy-providers:" "$CFG_FILE" 2>/dev/null)" ]; then
if [ -n "$(grep "^ \{0,\}rules:" "$CFG_FILE" 2>/dev/null)" ] || [ -n "$(grep "^ \{0,\}script:" "$CFG_FILE" 2>/dev/null)" ]; then
config_su_check
else
config_download_direct
fi
else
config_download_direct
fi
else
config_download_direct
fi
else
config_download_direct
fi
}
#分别获取订阅信息进行处理
config_load "openclash"
config_foreach sub_info_get "config_subscribe"
uci delete openclash.config.config_update_path >/dev/null 2>&1
uci commit openclash
if [ "$if_restart" -eq 1 ]; then
/etc/init.d/openclash restart >/dev/null 2>&1
else
sed -i '/openclash.sh/d' $CRON_FILE 2>/dev/null
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE
/etc/init.d/cron restart
fi

View File

@ -18,7 +18,7 @@
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/RuleSet/Extra/ChinaIP.yaml -o /tmp/ChinaIP.yaml >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ -s "/tmp/ChinaIP.yaml" ]; then
echo "大陆IP白名单下载成功检查版本是否更新..." >$START_LOG
@ -34,7 +34,7 @@
mv /tmp/ChinaIP.yaml /etc/openclash/rule_provider/ChinaIP.yaml >/dev/null 2>&1
echo "删除下载缓存..." >$START_LOG
rm -rf /tmp/ChinaIP.yaml >/dev/null 2>&1
rm -rf /etc/openclash/china_ip_route.ipset >/dev/null 2>&1
rm -rf /usr/share/openclash/res/china_ip_route.ipset >/dev/null 2>&1
[ "$china_ip_route" -eq 1 ] && /etc/init.d/openclash restart
echo "大陆IP白名单更新成功" >$START_LOG
echo "${LOGTIME} Chnroute Lists Update Successful" >>$LOG_FILE

View File

@ -10,6 +10,7 @@ en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
CPU_MODEL=$(uci get openclash.config.core_version 2>/dev/null)
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
[ ! -f "/tmp/clash_last_version" ] && /usr/share/openclash/clash_version.sh 2>/dev/null
mkdir -p /etc/openclash/core
[ -s "/tmp/openclash.auth" ] && {
@ -46,7 +47,6 @@ case $CORE_TYPE in
fi
esac
[ -z "$(pidof clash)" ] && if_restart=0
[ -n "$2" ] || [ "$1" = "one_key_update" ] && if_restart=0
if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
@ -69,15 +69,15 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
case $CORE_TYPE in
"Tun")
echo "正在下载【Tun】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/TUN-Premium/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash_tun.gz >/dev/null 2>&1
curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/premium/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash_tun.gz >/dev/null 2>&1
;;
"Game")
echo "正在下载【Game】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/TUN/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_game.tar.gz >/dev/null 2>&1
curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/game/clash-"$CPU_MODEL".tar.gz -o /tmp/clash_game.tar.gz >/dev/null 2>&1
;;
*)
echo "正在下载【Dev】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
curl -sL -m 30 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/core-lateset/dev/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
esac
fi
if [ "$?" -eq "0" ]; then
@ -130,8 +130,10 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
fi
if [ "$if_restart" -eq 1 ]; then
kill -9 "$(pidof clash|sed 's/$//g')" 2>/dev/null
/etc/init.d/openclash stop
clash_pids=$(pidof clash|sed 's/$//g')
for clash_pid in $clash_pids; do
kill -9 "$clash_pid" 2>/dev/null
done
fi
case $CORE_TYPE in
@ -151,7 +153,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
uci set openclash.config.config_reload=0
uci commit openclash
fi
[ "$if_restart" -eq 1 ] && /etc/init.d/openclash start
[ "$if_restart" -eq 1 ] && /etc/init.d/openclash restart
echo "" >$START_LOG
else
echo "【"$CORE_TYPE"】版本内核更新失败,请确认设备闪存空间足够后再试!" >$START_LOG

View File

@ -29,7 +29,7 @@ core_version=$(/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}'
core_tun_version=$(/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null)
core_game_version=$(/etc/openclash/core/clash_game -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null)
servers_update=$(uci get openclash.config.servers_update 2>/dev/null)
op_version=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null)
op_version=$(sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null)
china_ip_route=$(uci get openclash.config.china_ip_route 2>/dev/null)
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
@ -275,7 +275,8 @@ else
/usr/share/openclash/yml_field_cut.sh "$nameserver_len" "$DNS_FILE" "$CONFIG_FILE"
fi 2>/dev/null
cat "$CONFIG_FILE" "$DNS_FILE" >> "$DEBUG_LOG"
rm -rf /tmp/yaml_general 2>/dev/null
cat "$CHANGE_FILE" "$DNS_FILE" >> "$DEBUG_LOG"
fi
#firewall

View File

@ -1,12 +1,12 @@
#!/bin/sh
RULE_FILE_NAME="$1"
if [ -z "$(grep "$RULE_FILE_NAME" /etc/openclash/rule_providers.list 2>/dev/null)" ]; then
DOWNLOAD_PATH=$(grep -F "$RULE_FILE_NAME" /etc/openclash/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null)
if [ -z "$(grep "$RULE_FILE_NAME" /usr/share/openclash/res/rule_providers.list 2>/dev/null)" ]; then
DOWNLOAD_PATH=$(grep -F "$RULE_FILE_NAME" /usr/share/openclash/res/game_rules.list |awk -F ',' '{print $2}' 2>/dev/null)
RULE_FILE_DIR="/etc/openclash/game_rules/$RULE_FILE_NAME"
RULE_TYPE="game"
else
DOWNLOAD_PATH=$(echo "$RULE_FILE_NAME" |awk -F ',' '{print $1$2}' 2>/dev/null)
RULE_FILE_NAME=$(grep -F "$RULE_FILE_NAME" /etc/openclash/rule_providers.list |awk -F ',' '{print $NF}' 2>/dev/null)
RULE_FILE_NAME=$(grep -F "$RULE_FILE_NAME" /usr/share/openclash/res/rule_providers.list |awk -F ',' '{print $NF}' 2>/dev/null)
RULE_FILE_DIR="/etc/openclash/rule_provider/$RULE_FILE_NAME"
RULE_TYPE="provider"
fi
@ -28,13 +28,13 @@
if pidof clash >/dev/null; then
curl -sL --connect-timeout 5 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
else
curl -sL --connect-timeout 5 --retry 2 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
curl -sL --connect-timeout 5 --retry 2 https://cdn.jsdelivr.net/gh/FQrabbit/SSTap-Rule@master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
fi
elif [ "$RULE_TYPE" = "provider" ]; then
if pidof clash >/dev/null; then
curl -sL --connect-timeout 5 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
else
curl -sL --connect-timeout 5 --retry 2 https://raw.githubusercontent.com/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
curl -sL --connect-timeout 5 --retry 2 https://cdn.jsdelivr.net/gh/"$(echo "$DOWNLOAD_PATH" |awk -F '/master' '{print $1}' 2>/dev/null)"@master"$(echo "$DOWNLOAD_PATH" |awk -F 'master' '{print $2}')" -o "$TMP_RULE_DIR" >/dev/null 2>&1
fi
fi

View File

@ -16,7 +16,7 @@
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/alecthw/mmdb_china_ip_list/release/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 http://www.ideame.top/mmdb/Country.mmdb -o /tmp/Country.mmdb >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ -s "/tmp/Country.mmdb" ]; then
echo "GEOIP 数据库下载成功,检查数据库版本是否更新..." >$START_LOG

View File

@ -24,14 +24,14 @@
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
fi
sed -i '1i rules:' /tmp/rules.yaml
elif [ "$RUlE_SOURCE" = "ConnersHua" ]; then
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/Global.yaml -o /tmp/rules.yaml >/dev/null 2>&1
fi
sed -i -n '/^rule-providers:/,$p' /tmp/rules.yaml 2>/dev/null
sed -i "s/# - RULE-SET,ChinaIP,DIRECT/- RULE-SET,ChinaIP,DIRECT/g" /tmp/rules.yaml 2>/dev/null
@ -40,7 +40,7 @@
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/China.yaml -o /tmp/rules.yaml >/dev/null 2>&1
fi
sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
fi
@ -66,13 +66,14 @@
#合并
cat "$OTHER_RULE_PROVIDER_FILE" "$OTHER_SCRIPT_FILE" "$OTHER_RULE_FILE" > "/tmp/rules.yaml" 2>/dev/null
rm -rf /tmp/other_rule* 2>/dev/null
rm -rf /tmp/yaml_general 2>/dev/null
echo "检查下载的规则文件是否有更新..." >$START_LOG
cmp -s /etc/openclash/"$RUlE_SOURCE".yaml /tmp/rules.yaml
cmp -s /usr/share/openclash/res/"$RUlE_SOURCE".yaml /tmp/rules.yaml
if [ "$?" -ne "0" ]; then
echo "检测到下载的规则文件有更新,开始替换..." >$START_LOG
mv /tmp/rules.yaml /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
sed -i '/^rules:/a\##updated' /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
mv /tmp/rules.yaml /usr/share/openclash/res/"$RUlE_SOURCE".yaml >/dev/null 2>&1
sed -i '/^rules:/a\##updated' /usr/share/openclash/res/"$RUlE_SOURCE".yaml >/dev/null 2>&1
echo "替换成功,重新加载 OpenClash 应用新规则..." >$START_LOG
status=$(unify_ps_prevent)
while ( [ "$status" -gt 1 ] )

View File

@ -20,7 +20,7 @@ LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/openclash.log"
LAST_OPVER="/tmp/openclash_last_version"
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g")
OP_CV=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
OP_CV=$(sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
@ -33,7 +33,7 @@ if [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 ] && [ -f "$LAST_OPVER" ]; then
if pidof clash >/dev/null; then
curl -sL -m 30 --retry 5 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
else
curl -sL -m 30 --retry 5 https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
curl -sL -m 30 --retry 5 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ -s "/tmp/openclash.ipk" ]; then
echo "OpenClash-$LAST_VER 下载成功,开始更新,更新过程请不要刷新页面和进行其他操作..." >$START_LOG

View File

@ -1,7 +1,7 @@
#!/bin/sh
CKTIME=$(date "+%Y-%m-%d-%H")
LAST_OPVER="/tmp/openclash_last_version"
OP_CV=$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
OP_CV=$(sed -n 1p /usr/share/openclash/res/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
@ -15,7 +15,7 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://cdn.jsdelivr.net/gh/vernesong/OpenClash@master/version -o $LAST_OPVER >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null)

View File

@ -334,9 +334,9 @@ script:
"PayPal": "PayPal",
"Microsoft": "Microsoft",
"PROXY": "Proxy",
"Apple": "Apple",
"Domestic": "Domestic",
"Domestic IPs": "Domestic",
"Apple": "Apple"
"Domestic IPs": "Domestic"
}
port = int(metadata["dst_port"])
@ -353,12 +353,12 @@ script:
return "DIRECT"
code = ctx.geoip(ip)
if code == "CN":
return "Domestic"
if code == "LAN":
return "DIRECT"
if code == "CN":
return "Domestic"
return "Others"
rules:
@ -414,9 +414,11 @@ rules:
- RULE-SET,Microsoft,Microsoft
- RULE-SET,PROXY,Proxy
- RULE-SET,Apple,Apple
- RULE-SET,Domestic,Domestic
- RULE-SET,Domestic IPs,Domestic
- RULE-SET,Apple,Apple
- GEOIP,CN,Domestic
- MATCH,Others

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,49 @@
无Urltest,no_urltest.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/no_urltest.ini
带Urltest,urltest.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/urltest.ini
ConnersHua 神机规则 Basic,connershua_basic.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_basic.ini
ConnersHua 神机规则 Pro,connershua_pro.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_pro.ini
ConnersHua 神机规则 BacktoCN 回国专用,connershua_backtocn.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_backtocn.ini
lhie1 洞主规则(使用 Clash 分组规则),lhie1_clash.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_clash.ini
lhie1 洞主规则完整版,lhie1_dler.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_dler.ini
ACL4SSR 规则标准版,acl4ssr_standard.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/acl4ssr_standard.ini
ACL4SSR 规则 GFWList,acl4ssr_gfwlist.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/acl4ssr_gfwlist.ini
ACL4SSR 规则 AdblockPlus,ACL4SSR_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_AdblockPlus.ini
ACL4SSR 规则 BackCN,ACL4SSR_BackCN.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_BackCN.ini
ACL4SSR 规则 Mini,ACL4SSR_Mini.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini.ini
ACL4SSR 规则 Mini Fallback,ACL4SSR_Mini_Fallback.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_Fallback.ini
ACL4SSR 规则 Mini MultiMode,ACL4SSR_Mini_MultiMode.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_MultiMode.ini
ACL4SSR 规则 Mini NoAuto,ACL4SSR_Mini_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Mini_NoAuto.ini
ACL4SSR 规则 NoApple,ACL4SSR_NoApple.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoApple.ini
ACL4SSR 规则 NoAuto,ACL4SSR_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto.ini
ACL4SSR 规则 NoAuto NoApple,ACL4SSR_NoAuto_NoApple.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto_NoApple.ini
ACL4SSR 规则 NoAuto NoApple NoMicrosoft,ACL4SSR_NoAuto_NoApple_NoMicrosoft.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoAuto_NoApple_NoMicrosoft.ini
ACL4SSR 规则 NoMicrosoft,ACL4SSR_NoMicrosoft.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_NoMicrosoft.ini
ACL4SSR 规则 Online,ACL4SSR_Online.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online.ini
ACL4SSR 规则 Online AdblockPlus,ACL4SSR_Online_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_AdblockPlus.ini
ACL4SSR 规则 Online Full,ACL4SSR_Online_Full.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full.ini
ACL4SSR 规则 Online Full AdblockPlus,ACL4SSR_Online_Full_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_AdblockPlus.ini
ACL4SSR 规则 Online Full Netflix,ACL4SSR_Online_Full_Netflix.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_Netflix.ini
ACL4SSR 规则 Online Full NoAuto,ACL4SSR_Online_Full_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Full_NoAuto.ini
ACL4SSR 规则 Online Mini,ACL4SSR_Online_Mini.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini.ini
ACL4SSR 规则 Online Mini AdblockPlus,ACL4SSR_Online_Mini_AdblockPlus.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_AdblockPlus.ini
ACL4SSR 规则 Online Mini Fallback,ACL4SSR_Online_Mini_Fallback.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_Fallback.ini
ACL4SSR 规则 Online Mini MultiMode,ACL4SSR_Online_Mini_MultiMode.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_MultiMode.ini
ACL4SSR 规则 Online Mini NoAuto,ACL4SSR_Online_Mini_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_Mini_NoAuto.ini
ACL4SSR 规则 Online NoAuto,ACL4SSR_Online_NoAuto.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_NoAuto.ini
ACL4SSR 规则 Online NoReject,ACL4SSR_Online_NoReject.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_Online_NoReject.ini
ACL4SSR 规则 WithChinaIp,ACL4SSR_WithChinaIp.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_WithChinaIp.ini
ACL4SSR 规则 WithChinaIp WithGFW,ACL4SSR_WithChinaIp_WithGFW.ini,https://raw.githubusercontent.com/tindy2013/subconverter/master/base/config/ACL4SSR_WithChinaIp_WithGFW.ini
eHpo1 规则,ehpo1_main.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/ehpo1_main.ini
nzw9314 规则,nzw9314_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/nzw9314_custom.ini
maicoo-l 规则,maicoo-l_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/maicoo-l_custom.ini
rixCloud 官方规则,rixcloud_custom.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/rixcloud_custom.ini
Maying,maying_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/maying_optimized.ini
Nexitally,nexitally_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/nexitally_optimized.ini
贼船,zeichuan_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/zeichuan_optimized.ini
N3RO,n3ro_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/n3ro_optimized.ini
Scholar,scholar_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/scholar_optimized.ini
YToo,ytoo_optimized.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/ytoo_optimized.ini
DlerCloud Platinum 李哥定制规则,dlercloud_lige_platinum.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_platinum.ini
DlerCloud Gold 李哥定制规则,dlercloud_lige_gold.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_gold.ini
DlerCloud Silver 李哥定制规则,dlercloud_lige_silver.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_silver.ini
网易云解锁(仅规则分组),netease.ini,https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/netease.ini

Some files were not shown because too many files have changed in this diff Show More