OpenClash: bump to v0.37.3-beta

This commit is contained in:
CN_SZTL 2020-04-14 21:05:49 +08:00
parent e5cc21dbf2
commit ce2be712bb
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
14 changed files with 1669 additions and 1215 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.37.2
PKG_VERSION:=0.37.3
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
@ -73,6 +73,7 @@ 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
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
@ -85,16 +86,26 @@ if [ -f "/tmp/config.yaml" ]; then
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
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
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_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
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
@ -113,9 +124,7 @@ endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
if [ ! -f "/tmp/openclash_update.sh" ]; then
rm -rf /etc/openclash/clash >/dev/null 2>&1
fi
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
@ -132,7 +141,7 @@ endef
define Package/$(PKG_NAME)/postrm
#!/bin/sh
if [ -f "/etc/openclash/clash" ]; then
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
@ -149,6 +158,7 @@ fi
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
uci delete firewall.openclash >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1

View File

@ -636,12 +636,9 @@ lan_ac()
}
start()
#配置文件选择
config_choose()
{
#禁止多个实例
status=$(ps|grep -c /etc/init.d/openclash)
[ "$status" -gt "3" ] && exit 0
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
CONFIG_NAME=$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')
if [ ! -z "$CONFIG_NAME" ]; then
@ -661,39 +658,81 @@ if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
fi
else
if [ ! -f "$CONFIG_FILE" ] && [ -f "$BACKUP_FILE" ]; then
cp "$BACKUP_FILE" "$CONFIG_FILE"
cp "$BACKUP_FILE" "$CONFIG_FILE"
fi
fi
CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
}
#运行模式处理
do_run_mode()
{
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
if [ ! -h "/etc/openclash/clash" ] && [ -s "/etc/openclash/clash" ] && [ ! -s "/etc/openclash/core/clash" ]; then
mv "/etc/openclash/clash" "/etc/openclash/core/clash" 2>/dev/null
fi
rm -rf "/etc/openclash/clash" 2>/dev/null
if [ "$en_mode" = "fake-ip-tun" ]; then
en_mode_tun="1"
en_mode="fake-ip"
ln -s /etc/openclash/core/clash_tun /etc/openclash/clash 2>/dev/null
core_type="Tun"
fi
if [ "$en_mode" = "redir-host-tun" ]; then
en_mode_tun="1"
en_mode="redir-host"
ln -s /etc/openclash/core/clash_tun /etc/openclash/clash 2>/dev/null
core_type="Tun"
fi
if [ "$en_mode" = "redir-host-vpn" ]; then
en_mode_tun="2"
en_mode="redir-host"
ln -s /etc/openclash/core/clash_game /etc/openclash/clash 2>/dev/null
core_type="Game"
fi
if [ "$en_mode" = "fake-ip-vpn" ]; then
en_mode_tun="2"
en_mode="fake-ip"
ln -s /etc/openclash/core/clash_game /etc/openclash/clash 2>/dev/null
core_type="Game"
fi
if [ ! -f "/etc/openclash/clash" ] && [ -f "/etc/openclash/core/clash" ]; then
ln -s /etc/openclash/core/clash /etc/openclash/clash 2>/dev/null
fi
#权限检查
[ ! -x "/etc/openclash/core/clash_tun" ] && chmod 4755 /etc/openclash/core/clash_tun 2>/dev/null
[ ! -x "/etc/openclash/core/clash_game" ] && chmod 4755 /etc/openclash/core/clash_game 2>/dev/null
[ ! -x "/etc/openclash/core/clash" ] && chmod 4755 /etc/openclash/core/clash 2>/dev/null
}
start()
{
#禁止多个实例
status=$(ps|grep -c /etc/init.d/openclash)
[ "$status" -gt "3" ] && exit 0
config_choose
enable=$(uci get openclash.config.enable 2>/dev/null)
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
#检查是否存在核心文件
[ ! -f "$CLASH" ] && {
echo "OpenClash 核心文件不存在,开始下载..." >$START_LOG
nohup /usr/share/openclash/openclash_core.sh &
exit 0
}
do_run_mode
[ ! -f "$CLASH" ] && {
echo "内核文件不存在,开始下载..." >$START_LOG
nohup /usr/share/openclash/openclash_core.sh "$core_type" &
exit 0
}
echo "OpenClash 开始启动..." >$START_LOG
echo "第一步: 获取配置..." >$START_LOG
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
if [ "$en_mode" = "fake-ip-tun" ]; then
en_mode_tun="1"
en_mode="fake-ip"
fi
if [ "$en_mode" = "redir-host-tun" ]; then
en_mode_tun="1"
en_mode="redir-host"
fi
if [ "$en_mode" = "redir-host-vpn" ]; then
en_mode_tun="2"
en_mode="redir-host"
fi
if [ "$en_mode" = "fake-ip-vpn" ]; then
en_mode_tun="2"
en_mode="fake-ip"
fi
enable_custom_dns=$(uci get openclash.config.enable_custom_dns 2>/dev/null)
rule_source=$(uci get openclash.config.rule_source 2>/dev/null)
enable_custom_clash_rules=$(uci get openclash.config.enable_custom_clash_rules 2>/dev/null)
@ -1119,7 +1158,7 @@ stop()
sleep 5
fi
rm -rf $START_LOG
rm -rf $START_LOG 2>/dev/null
del_cron
echo "OpenClash Already Stop"
}

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,8 @@ function index()
entry({"admin", "services", "openclash", "update_ma"},call("action_update_ma"))
entry({"admin", "services", "openclash", "opupdate"},call("action_opupdate"))
entry({"admin", "services", "openclash", "coreupdate"},call("action_coreupdate"))
entry({"admin", "services", "openclash", "coretunupdate"},call("action_core_tun_update"))
entry({"admin", "services", "openclash", "coregameupdate"},call("action_core_game_update"))
entry({"admin", "services", "openclash", "ping"}, call("act_ping"))
entry({"admin", "services", "openclash", "download_game_rule"}, call("action_download_rule"))
entry({"admin", "services", "openclash", "settings"},cbi("openclash/settings"),_("Global Settings"), 30).leaf = true
@ -105,17 +107,35 @@ local function coremodel()
end
local function corecv()
if not nixio.fs.access("/etc/openclash/clash") then
if not nixio.fs.access("/etc/openclash/core/clash") and not nixio.fs.access("/etc/openclash/clash") then
return "0"
else
return luci.sys.exec("/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
return luci.sys.exec("/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
end
end
local function coretuncv()
if not nixio.fs.access("/etc/openclash/core/clash_tun") then
return "0"
else
return luci.sys.exec("/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}'")
end
end
local function coregamecv()
if not nixio.fs.access("/etc/openclash/core/clash_game") then
return "0"
else
return luci.sys.exec("/etc/openclash/core/clash_game -v 2>/dev/null |awk -F ' ' '{print $2}'")
end
end
local function corelv()
local new = luci.sys.call(string.format("sh /usr/share/openclash/clash_version.sh"))
local core_lv = luci.sys.exec("sed -n 1p /tmp/clash_last_version 2>/dev/null")
return core_lv .. "," .. new
local core_tun_lv = luci.sys.exec("sed -n 2p /tmp/clash_last_version 2>/dev/null")
local core_game_lv = luci.sys.exec("sed -n 3p /tmp/clash_last_version 2>/dev/null")
return core_lv .. "," .. core_tun_lv .. "," .. core_game_lv .. "," .. new
end
local function opcv()
@ -135,7 +155,17 @@ end
local function coreup()
luci.sys.call("uci set openclash.config.enable=1 && uci commit openclash && rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/clash_version.sh >/dev/null 2>&1")
return luci.sys.call("sh /usr/share/openclash/openclash_core.sh >/dev/null 2>&1 &")
return luci.sys.call("/usr/share/openclash/openclash_core.sh >/dev/null 2>&1 &")
end
local function coretunup()
luci.sys.call("uci set openclash.config.enable=1 && uci commit openclash && rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/clash_version.sh >/dev/null 2>&1")
return luci.sys.call("/usr/share/openclash/openclash_core.sh 'Tun' >/dev/null 2>&1 &")
end
local function coregameup()
luci.sys.call("uci set openclash.config.enable=1 && uci commit openclash && rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/clash_version.sh >/dev/null 2>&1")
return luci.sys.call("/usr/share/openclash/openclash_core.sh 'Game' >/dev/null 2>&1 &")
end
local function corever()
@ -212,6 +242,8 @@ function action_update()
luci.http.write_json({
coremodel = coremodel(),
corecv = corecv(),
coretuncv = coretuncv(),
coregamecv = coregamecv(),
opcv = opcv(),
corever = corever(),
upchecktime = upchecktime(),
@ -224,6 +256,7 @@ function action_update_ma()
luci.http.prepare_content("application/json")
luci.http.write_json({
oplv = oplv(),
corelv = corelv(),
corever = corever();
})
end
@ -242,6 +275,20 @@ function action_coreupdate()
})
end
function action_core_tun_update()
luci.http.prepare_content("application/json")
luci.http.write_json({
coretunup = coretunup();
})
end
function action_core_game_update()
luci.http.prepare_content("application/json")
luci.http.write_json({
coregameup = coregameup();
})
end
function act_ping()
local e={}
e.index=luci.http.formvalue("index")

View File

@ -11,20 +11,18 @@ local uci = require "luci.model.uci".cursor()
m = Map(openclash, translate("Game Rules and Groups"))
m.pageaction = false
m.description=translate("注意事项:<br/>游戏代理为测试功能,不保证可用性 \
m.description=translate("注意事项:<br/>游戏代理为测试功能,不保证可用性 \
<br/>\
<br/>1使:FallBackUDP \
<br/>2使 \
<br/>3 \
<br/> \
<br/>使 \
<br/>1--UDP流量代理 \
<br/>1--UDP流量代理 \
<br/> \
<br/>TUN模式下使用 \
<br/>1https://github.com/Dreamacro/clash/releases/tag/TUN \
<br/>2https://github.com/vernesong/OpenClash/releases/tag/TUN \
<br/>3https://github.com/comzyh/clash \
<br/>4--TUN模式")
<br/>1- \
<br/>2--TUN模式或者游戏模式并重新启动")
function IsRuleFile(e)

View File

@ -4,17 +4,44 @@
<table>
<tr><td width="100%" colspan="4">
<p align="center" id="update_tip">
<b> 注意:如更新失败可手动下载并上传,内核路径为:/etc/openclash </b>
<b> 注意:如更新失败可手动下载并上传 </b>
</p>
</td></tr>
<tr><td width="25%"> 已选择编译版本 </td><td width="25%" align="left" id="CORE_VERSION"><%:Collecting data...%></td><td width="25%"> 上次检查更新时间 </td><td width="25%" align="left" id="CHECKTIME"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 处理器架构PROC </td><td width="25%" align="left" id="CPU_MODEL"><%:Collecting data...%></td><td width="25%"> 处理器架构OPKG </td><td width="25%" align="left" id="CPU_MODEL2"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 当前内核版本 </td><td width="25%" align="left" id="CORE_CV"><%:Collecting data...%></td><td width="25%"> 当前客户端版本 </td><td width="25%" align="left" id="OP_CV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 最新内核版本 </td><td width="25%" align="left" id="CORE_LV"><%:Collecting data...%></td><td width="25%"> 最新客户端版本 </td><td width="25%" align="left" id="OP_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 更新内核</td><td width="25%" align="left" id="core_up"><%:Collecting data...%></td><td width="25%"> 更新客户端 </td><td width="25%" align="left" id="op_up"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 下载最新版本内核</td><td width="25%" align="left" id="ma_core_up"><%:Collecting data...%></td><td width="25%"> 下载最新版本客户端 </td><td width="25%" align="left" id="ma_op_up"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b> 内核路径:/etc/openclash/core/clash </b>
</p>
</td></tr>
<tr><td width="25%"> 当前【Dev分支】内核版本 </td><td width="25%" align="left" id="CORE_CV"><%:Collecting data...%></td><td width="25%"> 最新【Dev分支】内核版本 </td><td width="25%" align="left" id="CORE_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 更新内核</td><td width="25%" align="left" id="core_up"><%:Collecting data...%></td><td width="25%"> 下载最新版本内核</td><td width="25%" align="left" id="ma_core_up"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b> 内核路径:/etc/openclash/core/clash_tun </b>
</p>
</td></tr>
<tr><td width="25%"> 当前【TUN模式】内核版本 </td><td width="25%" align="left" id="CORE_TUN_CV"><%:Collecting data...%></td><td width="25%"> 最新【TUN模式】内核版本 </td><td width="25%" align="left" id="CORE_TUN_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 更新内核</td><td width="25%" align="left" id="core_tun_up"><%:Collecting data...%></td><td width="25%"> 下载最新版本内核</td><td width="25%" align="left" id="ma_core_tun_up"><%:Collecting data...%></td></tr>
<tr><td width="100%" colspan="4">
<p align="center">
<b> 内核路径:/etc/openclash/core/clash_game </b>
</p>
</td></tr>
<tr><td width="25%"> 当前【游戏模式】内核版本 </td><td width="25%" align="left" id="CORE_GAME_CV"><%:Collecting data...%></td><td width="25%"> 最新【游戏模式】内核版本 </td><td width="25%" align="left" id="CORE_GAME_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 更新内核</td><td width="25%" align="left" id="core_game_up"><%:Collecting data...%></td><td width="25%"> 下载最新版本内核</td><td width="25%" align="left" id="ma_core_game_up"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<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="OP_CV"><%:Collecting data...%></td><td width="25%"> 最新客户端版本 </td><td width="25%" align="left" id="OP_LV"><%:Collecting data...%></td></tr>
<tr><td width="25%"> 更新客户端 </td><td width="25%" align="left" id="op_up"><%:Collecting data...%></td><td width="25%"> 下载最新版本客户端 </td><td width="25%" align="left" id="ma_op_up"><%:Collecting data...%></td></tr>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
@ -24,12 +51,20 @@
var cpu_model2 = document.getElementById('CPU_MODEL2');
var core_cv = document.getElementById('CORE_CV');
var core_lv = document.getElementById('CORE_LV');
var core_tun_cv = document.getElementById('CORE_TUN_CV');
var core_tun_lv = document.getElementById('CORE_TUN_LV');
var core_game_cv = document.getElementById('CORE_GAME_CV');
var core_game_lv = document.getElementById('CORE_GAME_LV');
var op_cv = document.getElementById('OP_CV');
var op_lv = document.getElementById('OP_LV');
var core_up = document.getElementById('core_up');
var core_tun_up = document.getElementById('core_tun_up');
var core_game_up = document.getElementById('core_game_up');
var op_up = document.getElementById('op_up');
var update_tip = document.getElementById('update_tip');
var ma_core_up = document.getElementById('ma_core_up');
var ma_core_tun_up = document.getElementById('ma_core_tun_up');
var ma_core_game_up = document.getElementById('ma_core_game_up');
var ma_op_up = document.getElementById('ma_op_up');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
@ -60,11 +95,31 @@
else {
core_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( status.coretuncv == "0" ) {
core_tun_cv.innerHTML = "<b><font color=red><%:File Not Exist%></font></b>";
}
else if (status.coretuncv != "") {
core_tun_cv.innerHTML = "<b><font color=green>"+status.coretuncv+"</font></b>";
}
else {
core_tun_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( status.coregamecv == "0" ) {
core_game_cv.innerHTML = "<b><font color=red><%:File Not Exist%></font></b>";
}
else if (status.coregamecv != "") {
core_game_cv.innerHTML = "<b><font color=green>"+status.coregamecv+"</font></b>";
}
else {
core_game_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
var corelv = status.corelv;
var arr_core = corelv.split(",");
var corelvis = arr_core[0];
var new_ch = arr_core[1];
if ( new_ch == "2" ) {
var coretunlvis = arr_core[1];
var coregamelvis = arr_core[2];
var new_ch = arr_core[3];
if ( new_ch == "2" || new_ch == "4" ) {
core_lv.innerHTML = "<b><font color=green>"+corelvis+"<%:<New>%></font></b>";
}
else if (corelvis != "" && corelvis != "\n" ) {
@ -73,6 +128,21 @@
else {
core_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( new_ch == "3" || new_ch == "4" ) {
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"<%:<New>%></font></b>";
}
else if (coretunlvis != "" && coretunlvis != "\n" ) {
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"</font></b>";
}
else {
core_tun_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if (coregamelvis != "" && coregamelvis != "\n" ) {
core_game_lv.innerHTML = "<b><font color=green>"+coregamelvis+"</font></b>";
}
else {
core_game_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
var oplv = status.oplv;
var arr_op = oplv.split(",");
var oplvis = arr_op[0];
@ -119,11 +189,31 @@
else {
core_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( status.coretuncv == "0" ) {
core_tun_cv.innerHTML = "<b><font color=red><%:File Not Exist%></font></b>";
}
else if (status.coretuncv != "") {
core_tun_cv.innerHTML = "<b><font color=green>"+status.coretuncv+"</font></b>";
}
else {
core_tun_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( status.coregamecv == "0" ) {
core_game_cv.innerHTML = "<b><font color=red><%:File Not Exist%></font></b>";
}
else if (status.coregamecv != "") {
core_game_cv.innerHTML = "<b><font color=green>"+status.coregamecv+"</font></b>";
}
else {
core_game_cv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
var corelv = status.corelv;
var arr_core = corelv.split(",");
var corelvis = arr_core[0];
var new_ch = arr_core[1];
if ( new_ch == "2" ) {
var coretunlvis = arr_core[1];
var coregamelvis = arr_core[2];
var new_ch = arr_core[3];
if ( new_ch == "2" || new_ch == "4" ) {
core_lv.innerHTML = "<b><font color=green>"+corelvis+"<%:<New>%></font></b>";
}
else if (corelvis != "" && corelvis != "\n" ) {
@ -132,6 +222,21 @@
else {
core_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if ( new_ch == "3" || new_ch == "4" ) {
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"<%:<New>%></font></b>";
}
else if (coretunlvis != "" && coretunlvis != "\n" ) {
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"</font></b>";
}
else {
core_tun_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
if (coregamelvis != "" && coregamelvis != "\n" ) {
core_game_lv.innerHTML = "<b><font color=green>"+coregamelvis+"</font></b>";
}
else {
core_game_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
}
var oplv = status.oplv;
var arr_op = oplv.split(",");
var oplvis = arr_op[0];
@ -150,8 +255,12 @@
});
core_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:检查并更新%>" onclick="return core_update(this)"/>';
core_tun_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:检查并更新%>" onclick="return core_tun_update(this)"/>';
core_game_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:检查并更新%>" onclick="return core_game_update(this)"/>';
op_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:检查并更新%>" onclick="return op_update(this)"/>';
ma_core_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:下载到本地%>" onclick="return ma_core_update(this)"/>';
ma_core_tun_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:下载到本地%>" onclick="return ma_core_tun_update(this)"/>';
ma_core_game_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:下载到本地%>" onclick="return ma_core_game_update(this)"/>';
ma_op_up.innerHTML = '<input type="button" class="cbi-button cbi-button-reload" value="<%:下载到本地%>" onclick="return ma_op_update(this)"/>';
function core_update(btn)
@ -163,6 +272,28 @@
return false;
});
}
function core_tun_update(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "coretunupdate")%>', null, function(x, status) {
btn.value = '<%:检查并更新%>';
btn.disabled = false;
return false;
});
}
function core_game_update(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "coregameupdate")%>', null, function(x, status) {
btn.value = '<%:检查并更新%>';
btn.disabled = false;
return false;
});
}
function op_update(btn)
@ -193,6 +324,48 @@
return false;
}
function ma_core_tun_update(btn)
{
btn.value = '<%:下载到本地%>';
btn.disabled = false;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_ma")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
var corelv = status.corelv;
var arr_core = corelv.split(",");
var coretunlvis = arr_core[1];
if ( status.corever != "0\n" && coretunlvis != "\n" && coretunlvis != "" ) {
url3='https://github.com/Dreamacro/clash/releases/download/TUN/clash-'+status.corever+'-'+coretunlvis+'.gz';
window.open(url3);
}
else if ( status.corever == "0\n" ) {
alert('未选择编译版本,请到常规设置标签中配置!')
}
else if ( coretunlvis == "\n" || coretunlvis == "" ) {
alert('最新版本获取失败,请稍后再试!')
}
}
});
return false;
}
function ma_core_game_update(btn)
{
btn.value = '<%:下载到本地%>';
btn.disabled = false;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_ma")%>', status.corever, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0\n" ) {
url4='https://github.com/vernesong/OpenClash/releases/download/TUN/clash-'+status.corever+'.tar.gz';
window.open(url4);
}
else {
alert('未选择编译版本,请到常规设置标签中配置!')
}
}
});
return false;
}
function ma_op_update(btn)
{
btn.value = '<%:下载到本地%>';
@ -219,7 +392,7 @@
var rdmdl=Math.floor(Math.random()*2)+1;
if(rdmdl==1)
{
update_tip.innerHTML = '<b><font><%: 注意:如更新失败可手动下载并上传,内核路径为:/etc/openclash %></font></b>';
update_tip.innerHTML = '<b><font><%: 注意:如更新失败可手动下载并上传 %></font></b>';
}
if(rdmdl==2)
{

View File

@ -1,8 +1,15 @@
#!/bin/sh
#禁止多个实例
status=$(ps|grep -c /usr/share/openclash/clash_version.sh)
[ "$status" -gt "3" ] && exit 0
CKTIME=$(date "+%Y-%m-%d-%H")
LAST_OPVER="/tmp/clash_last_version"
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
CLASH_VER=$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
CLASH_VER=$(/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
LAST_TUN_VER=$(sed -n 2p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
CLASH_TUN_VER=$(/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$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)
@ -19,12 +26,17 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
fi
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
LAST_TUN_VER=$(sed -n 2p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
echo "CheckTime:$CKTIME" >>$LAST_OPVER
else
rm -rf $LAST_OPVER
fi
fi
if [ "$(expr "$LAST_VER" \> "$CLASH_VER")" -eq 1 ]; then
if [ "$(expr "$LAST_VER" \> "$CLASH_VER")" -eq 1 ] && [ "$(expr "$LAST_TUN_VER" \> "$CLASH_TUN_VER")" -eq 1 ]; then
return 4
elif [ "$(expr "$LAST_VER" \> "$CLASH_VER")" -eq 1 ]; then
return 2
fi 2>/dev/null
elif [ "$(expr "$LAST_TUN_VER" \> "$CLASH_TUN_VER")" -eq 1 ]; then
return 3
fi 2>/dev/null

View File

@ -13,13 +13,23 @@ 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
}
config_download()
{
if [ "$URL_TYPE" == "v2rayn" ]; then
subscribe_url=`echo $subscribe_url |sed 's/{/%7B/g;s/}/%7D/g;s/:/%3A/g;s/\"/%22/g;s/,/%2C/g;s/?/%3F/g;s/=/%3D/g;s/&/%26/g;s/\//%2F/g'`
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=`echo $subscribe_url |sed 's/{/%7B/g;s/}/%7D/g;s/:/%3A/g;s/\"/%22/g;s/,/%2C/g;s/?/%3F/g;s/=/%3D/g;s/&/%26/g;s/\//%2F/g'`
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

View File

@ -1,4 +1,6 @@
#!/bin/sh
#!/bin/bash
. /lib/functions.sh
#禁止多个实例
status=$(ps|grep -c /usr/share/openclash/openclash_core.sh)
[ "$status" -gt "3" ] && exit 0
@ -6,46 +8,125 @@ status=$(ps|grep -c /usr/share/openclash/openclash_core.sh)
START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/openclash.log"
CORE_TYPE="$1"
[ -z "$CORE_TYPE" ] && CORE_TYPE="Dev"
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)
if [ -s "/tmp/openclash.auth" ]; then
PROXY_AUTH=$(cat /tmp/openclash.auth |awk -F '- ' '{print $2}' |sed -n '1p' 2>/dev/null)
fi
if [ "$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}')" != "$(sed -n 1p /tmp/clash_last_version 2>/dev/null)" ] || [ -z "$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}')" ] || [ ! -f /etc/openclash/clash ]; then
if [ "$CPU_MODEL" != 0 ]; then
echo "开始下载 OpenClash 内核,如等待时间过长请尝试手动下载并上传..." >$START_LOG
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
[ -s "/tmp/openclash.auth" ] && {
PROXY_AUTH=$(cat /tmp/openclash.auth |awk -F '- ' '{print $2}' |sed -n '1p' 2>/dev/null)
}
case $CORE_TYPE in
"Tun")
CORE_CV=$(/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}')
CORE_LV=$(sed -n 2p /tmp/clash_last_version 2>/dev/null)
if [ "$en_mode" = "fake-ip-tun" ] || [ "$en_mode" = "redir-host-tun" ] || [ -z "$(pidof clash)" ]; then
if_restart=1
fi
if [ "$?" -eq "0" ] && [ -s "/tmp/clash.tar.gz" ]; then
tar zxvf /tmp/clash.tar.gz -C /tmp >/dev/null 2>&1\
&& rm -rf /tmp/clash.tar.gz >/dev/null 2>&1\
&& chmod 4755 /tmp/clash\
&& chown root:root /tmp/clash
/etc/init.d/openclash stop
echo "OpenClash 内核下载成功,开始更新..." >$START_LOG\
&& rm -rf /etc/openclash/clash\
&& mv /tmp/clash /etc/openclash/clash >/dev/null 2>&1
;;
"Game")
CORE_CV=$(/etc/openclash/core/clash_game -v 2>/dev/null |awk -F ' ' '{print $2}')
CORE_LV=$(sed -n 3p /tmp/clash_last_version 2>/dev/null)
if [ "$en_mode" = "fake-ip-vpn" ] || [ "$en_mode" = "redir-host-vpn" ] || [ -z "$(pidof clash)" ]; then
if_restart=1
fi
;;
*)
CORE_CV=$(/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}')
CORE_LV=$(sed -n 1p /tmp/clash_last_version 2>/dev/null)
if [ "$en_mode" = "fake-ip" ] || [ "$en_mode" = "redir-host" ] || [ -z "$(pidof clash)" ]; then
if_restart=1
fi
esac
if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
if [ "$CPU_MODEL" != 0 ]; then
if pidof clash >/dev/null; then
case $CORE_TYPE in
"Tun")
echo "正在下载【Tun】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/Dreamacro/clash/releases/download/TUN/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash.gz >/dev/null 2>&1
;;
"Game")
echo "正在下载【Game】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/TUN/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
;;
*)
echo "正在下载【Dev】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
esac
else
case $CORE_TYPE in
"Tun")
echo "正在下载【Tun】版本内核如下载失败请尝试手动下载并上传..." >$START_LOG
curl -sL -m 30 --retry 2 https://github.com/Dreamacro/clash/releases/download/TUN/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash.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.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
esac
fi
if [ "$?" -eq "0" ]; then
case $CORE_TYPE in
"Tun")
[ -s "/tmp/clash.gz" ] && {
gzip -d /tmp/clash.gz >/dev/null 2>&1
rm -rf /etc/openclash/core/clash_tun >/dev/null 2>&1
}
;;
"Game")
[ -s "/tmp/clash.tar.gz" ] && {
tar zxvf /tmp/clash.tar.gz -C /tmp >/dev/null 2>&1
rm -rf /etc/openclash/core/clash_game >/dev/null 2>&1
}
;;
*)
[ -s "/tmp/clash.tar.gz" ] && {
tar zxvf /tmp/clash.tar.gz -C /tmp >/dev/null 2>&1
rm -rf /etc/openclash/core/clash >/dev/null 2>&1
}
esac
chmod 4755 /tmp/clash >/dev/null 2>&1
chown root:root /tmp/clash >/dev/null 2>&1
rm -rf /tmp/clash.tar.gz >/dev/null 2>&1
rm -rf /tmp/clash.gz >/dev/null 2>&1
mkdir -p /etc/openclash/core
[ "$if_restart" -eq 1 ] && /etc/init.d/openclash stop
echo "【"$CORE_TYPE"】版本内核下载成功,开始更新..." >$START_LOG
case $CORE_TYPE in
"Tun")
mv /tmp/clash /etc/openclash/core/clash_tun >/dev/null 2>&1
;;
"Game")
mv /tmp/clash /etc/openclash/core/clash_game >/dev/null 2>&1
;;
*)
mv /tmp/clash /etc/openclash/core/clash >/dev/null 2>&1
esac
if [ "$?" -eq "0" ]; then
/etc/init.d/openclash start
echo "核心程序更新成功!" >$START_LOG
echo "${LOGTIME} OpenClash Core Update Successful" >>$LOG_FILE
[ "$if_restart" -eq 1 ] && /etc/init.d/openclash start
echo "【"$CORE_TYPE"】版本内核更新成功!" >$START_LOG
echo "${LOGTIME} OpenClash "$CORE_TYPE"】 Core Update Successful" >>$LOG_FILE
sleep 5
echo "" >$START_LOG
else
echo "核心程序更新失败,请确认设备闪存空间足够后再试!" >$START_LOG
echo "${LOGTIME} OpenClash Core Update Error" >>$LOG_FILE
echo "【"$CORE_TYPE"】版本内核更新失败,请确认设备闪存空间足够后再试!" >$START_LOG
echo "${LOGTIME} OpenClash 【"$CORE_TYPE"】 Core Update Error" >>$LOG_FILE
rm -rf /tmp/clash >/dev/null 2>&1
sleep 5
echo "" >$START_LOG
fi
else
echo "核心程序下载失败,请检查网络或稍后再试!" >$START_LOG
rm -rf /tmp/clash.tar.gz >/dev/null 2>&1
echo "${LOGTIME} OpenClash Core Update Error" >>$LOG_FILE
echo "【"$CORE_TYPE"】版本内核下载失败,请检查网络或稍后再试!" >$START_LOG
echo "${LOGTIME} OpenClash 【"$CORE_TYPE"】 Core Update Error" >>$LOG_FILE
rm -rf /tmp/clash >/dev/null 2>&1
sleep 10
echo "" >$START_LOG
fi
@ -55,9 +136,8 @@ if [ "$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}')" != "$(sed
echo "" >$START_LOG
fi
else
echo "核心程序没有更新,停止继续操作!" >$START_LOG
echo "${LOGTIME} OpenClash Core No Change, Do Nothing" >>$LOG_FILE
rm -rf /tmp/clash >/dev/null 2>&1
echo "【"$CORE_TYPE"】版本内核没有更新,停止继续操作!" >$START_LOG
echo "${LOGTIME} OpenClash 【"$CORE_TYPE"】 Core No Change, Do Nothing" >>$LOG_FILE
sleep 5
echo "" >$START_LOG
fi

View File

@ -19,9 +19,9 @@ fi
if [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 ] && [ -f "$LAST_OPVER" ]; then
echo "开始下载 OpenClash-$LAST_VER ..." >$START_LOG
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --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
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 --connect-timeout 10 --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://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/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,4 +1,5 @@
#!/bin/sh
CLASH="/etc/openclash/clash"
CLASH_CONFIG="/etc/openclash"
LOG_FILE="/tmp/openclash.log"
@ -7,8 +8,16 @@ PROXY_ROUTE_TABLE="0x162"
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
CRASH_NUM=0
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
if [ "$en_mode" = "fake-ip-tun" ] || [ "$en_mode" = "redir-host-tun" ]; then
core_type="Tun"
fi
if [ "$en_mode" = "redir-host-vpn" ] || [ "$en_mode" = "fake-ip-vpn" ]; then
core_type="Game"
fi
while :;
do
@ -23,10 +32,10 @@ if [ "$enable" -eq 1 ]; then
echo "${LOGTIME} Watchdog: Clash Core Problem, Restart." >> $LOG_FILE
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
sleep 3
if [ "$en_mode" = "fake-ip-tun" ] || [ "$en_mode" = "redir-host-tun" ]; then
if [ "$core_type" = "Tun" ]; then
ip route replace default dev utun table "$PROXY_ROUTE_TABLE" 2>/dev/null
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null
elif [ "$en_mode" = "redir-host-vpn" ] || [ "$en_mode" = "fake-ip-vpn" ]; then
elif [ "$core_type" = "Game" ]; then
ip tuntap add user root mode tun clash0 2>/dev/null
ip link set clash0 up 2>/dev/null
ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE" 2>/dev/null

View File

@ -485,54 +485,78 @@ do
server="$(cfg_get "server:" "$single_server")"
#port
port="$(cfg_get "port:" "$single_server")"
#cipher
cipher="$(cfg_get "cipher:" "$single_server")"
#password
password="$(cfg_get "password:" "$single_server")"
if [ "$server_type" = "ss" ]; then
#cipher
cipher="$(cfg_get "cipher:" "$single_server")"
#password
password="$(cfg_get "password:" "$single_server")"
#plugin:
plugin="$(cfg_get "plugin:" "$single_server")"
#path:
path="$(cfg_get "path:" "$single_server")"
#mode:
mode="$(cfg_get "mode:" "$single_server")"
#host:
host="$(cfg_get "host:" "$single_server")"
#mux:
mux="$(cfg_get "mux:" "$single_server")"
#headers_custom:
headers="$(cfg_get "custom:" "$single_server")"
#obfs:
obfs="$(cfg_get "obfs:" "$single_server")"
#obfs-host:
obfs_host="$(cfg_get "obfs-host:" "$single_server")"
fi
if [ "$server_type" = "vmess" ]; then
#uuid:
uuid="$(cfg_get "uuid:" "$single_server")"
#alterId:
alterId="$(cfg_get "alterId:" "$single_server")"
#cipher
cipher="$(cfg_get "cipher:" "$single_server")"
#network:
network="$(cfg_get "network:" "$single_server")"
#ws-path:
ws_path="$(cfg_get "ws-path:" "$single_server")"
#Host:
Host="$(cfg_get "Host:" "$single_server")"
#http_paths:
http_paths="$(cfg_get_dynamic "-" "$single_server")"
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
#username:
username="$(cfg_get "username:" "$single_server")"
#password
password="$(cfg_get "password:" "$single_server")"
fi
if [ "$server_type" = "snell" ]; then
#psk:
psk="$(cfg_get "psk:" "$single_server")"
#mode:
mode="$(cfg_get "mode:" "$single_server")"
#host:
host="$(cfg_get "host:" "$single_server")"
fi
if [ "$server_type" = "trojan" ]; then
#password
password="$(cfg_get "password:" "$single_server")"
#sni:
sni="$(cfg_get "sni:" "$single_server")"
#alpn:
alpns="$(cfg_get_dynamic "-" "$single_server")"
fi
#udp
udp="$(cfg_get "udp:" "$single_server")"
#plugin:
plugin="$(cfg_get "plugin:" "$single_server")"
#plugin-opts:
plugin_opts="$(cfg_get "plugin-opts:" "$single_server")"
#obfs:
obfs="$(cfg_get "obfs:" "$single_server")"
#psk:
psk="$(cfg_get "psk:" "$single_server")"
#obfs-host:
obfs_host="$(cfg_get "obfs-host:" "$single_server")"
#mode:
mode="$(cfg_get "mode:" "$single_server")"
#tls:
tls="$(cfg_get "tls:" "$single_server")"
#skip-cert-verify:
verify="$(cfg_get "skip-cert-verify:" "$single_server")"
#mux:
mux="$(cfg_get "mux:" "$single_server")"
#host:
host="$(cfg_get "host:" "$single_server")"
#Host:
Host="$(cfg_get "Host:" "$single_server")"
#path:
path="$(cfg_get "path:" "$single_server")"
#ws-path:
ws_path="$(cfg_get "ws-path:" "$single_server")"
#headers_custom:
headers="$(cfg_get "custom:" "$single_server")"
#uuid:
uuid="$(cfg_get "uuid:" "$single_server")"
#alterId:
alterId="$(cfg_get "alterId:" "$single_server")"
#network:
network="$(cfg_get "network:" "$single_server")"
#username:
username="$(cfg_get "username:" "$single_server")"
#sni:
sni="$(cfg_get "sni:" "$single_server")"
#alpn:
alpns="$(cfg_get_dynamic "-" "$single_server")"
#http_paths:
http_paths="$(cfg_get_dynamic "-" "$single_server")"
echo "正在读取【$CONFIG_NAME】-【$server_type】-【$server_name】服务器节点配置..." >$START_LOG
@ -546,61 +570,66 @@ do
${uci_set}type="$server_type"
${uci_set}server="$server"
${uci_set}port="$port"
if [ "$server_type" = "vmess" ]; then
${uci_set}securitys="$cipher"
else
${uci_set}cipher="$cipher"
fi
${uci_set}udp="$udp"
${uci_set}obfs="$obfs"
${uci_set}host="$obfs_host"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="none"
[ -z "$mode" ] && [ "$network" = "ws" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "http" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="http"
[ -z "$mode" ] && [ -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
${uci_set}psk="$psk"
${uci_set}tls="$tls"
${uci_set}skip_cert_verify="$verify"
${uci_set}path="$path"
[ -z "$path" ] && [ "$network" = "ws" ] && ${uci_set}path="$ws_path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$headers" ] && [ "$network" = "ws" ] && ${uci_set}custom="$Host"
if [ "$server_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
${uci_set}auth_name="$username"
${uci_set}auth_pass="$password"
else
${uci_set}password="$password"
fi
if [ "$server_type" = "ss" ]; then
${uci_set}cipher="$cipher"
${uci_set}obfs="$obfs"
${uci_set}host="$obfs_host"
${uci_set}path="$path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$obfs" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
fi
[ -z "$obfs_host" ] && ${uci_set}host="$host"
if [ "$server_type" = "snell" ]; then
${uci_set}obfs_snell="$mode"
[ -z "$mode" ] && ${uci_set}obfs_snell="none"
${uci_set}psk="$psk"
fi
if [ "$server_type" = "vmess" ]; then
${uci_set}securitys="$cipher"
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
if [ "$network" = "ws" ]; then
${uci_set}obfs_vmess="websocket"
${uci_set}path="$ws_path"
${uci_set}custom="$Host"
elif [ "$network" = "http" ]; then
${uci_set}obfs_vmess="http"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
else
${uci_set}obfs_vmess="none"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
${uci_set}auth_name="$username"
${uci_set}auth_pass="$password"
else
${uci_set}password="$password"
fi
if [ "$server_type" = "trojan" ]; then
#trojan
${uci_set}sni="$sni"
${uci_del}alpn >/dev/null 2>&1
for alpn in $alpns; do
${uci_add}alpn="$alpn" >/dev/null 2>&1
done
fi
if [ "$server_type" = "trojan" ]; then
${uci_set}sni="$sni"
${uci_del}alpn >/dev/null 2>&1
for alpn in $alpns; do
${uci_add}alpn="$alpn" >/dev/null 2>&1
done
fi
else
#添加新节点
name=openclash
@ -624,60 +653,66 @@ do
${uci_set}type="$server_type"
${uci_set}server="$server"
${uci_set}port="$port"
if [ "$server_type" = "vmess" ]; then
${uci_set}securitys="$cipher"
else
${uci_set}cipher="$cipher"
fi
${uci_set}udp="$udp"
${uci_set}obfs="$obfs"
${uci_set}host="$obfs_host"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="none"
[ -z "$mode" ] && [ "$network" = "ws" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "http" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="http"
[ -z "$mode" ] && [ -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
${uci_set}psk="$psk"
${uci_set}tls="$tls"
${uci_set}skip_cert_verify="$verify"
${uci_set}path="$path"
[ -z "$path" ] && [ "$network" = "ws" ] && ${uci_set}path="$ws_path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$headers" ] && [ "$network" = "ws" ] && ${uci_set}custom="$Host"
if [ "$server_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
${uci_set}auth_name="$username"
${uci_set}auth_pass="$password"
else
${uci_set}password="$password"
fi
if [ "$server_type" = "ss" ]; then
${uci_set}cipher="$cipher"
${uci_set}obfs="$obfs"
${uci_set}host="$obfs_host"
${uci_set}path="$path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$obfs" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
fi
[ -z "$obfs_host" ] && ${uci_set}host="$host"
if [ "$server_type" = "snell" ]; then
${uci_set}obfs_snell="$mode"
[ -z "$mode" ] && ${uci_set}obfs_snell="none"
${uci_set}psk="$psk"
fi
if [ "$server_type" = "vmess" ]; then
${uci_set}securitys="$cipher"
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
if [ "$network" = "ws" ]; then
${uci_set}obfs_vmess="websocket"
${uci_set}path="$ws_path"
${uci_set}custom="$Host"
elif [ "$network" = "http" ]; then
${uci_set}obfs_vmess="http"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
else
${uci_set}obfs_vmess="none"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
${uci_set}auth_name="$username"
${uci_set}auth_pass="$password"
else
${uci_set}password="$password"
fi
if [ "$server_type" = "trojan" ]; then
#trojan
${uci_set}sni="$sni"
for alpn in $alpns; do
${uci_add}alpn="$alpn" >/dev/null 2>&1
done
fi
if [ "$server_type" = "trojan" ]; then
${uci_set}sni="$sni"
${uci_del}alpn >/dev/null 2>&1
for alpn in $alpns; do
${uci_add}alpn="$alpn" >/dev/null 2>&1
done
fi
#加入策略组
if [ "$servers_if_update" = "1" ] && [ ! -z "$new_servers_group" ] && [ ! -z "$config_group_exist" ]; then

View File

@ -799,7 +799,7 @@ msgid "Game Rules Manage"
msgstr "管理游戏规则"
msgid "Proxy UDP Traffics"
msgstr "*代理UDP流量"
msgstr "*UDP流量转发"
msgid "Select Mode For UDP Traffics, The Servers Must Support UDP while Choose Proxy"
msgstr "启用时服务器必须支持UDP转发"