luci-app-clash: bump to 1.5.2

This commit is contained in:
CN_SZTL 2020-02-06 20:33:21 +08:00
parent ac6c573b0a
commit 20abcfebb0
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
14 changed files with 213 additions and 109 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.5.1
PKG_VERSION:=1.5.2
PKG_MAINTAINER:=frainzy1477
@ -22,7 +22,7 @@ define Package/luci-app-clash/description
endef
define Build/Prepare
po2lmo ${CURDIR}/po/zh-cn/clash.po ${CURDIR}/po/zh-cn/clash.zh-cn.lmo
po2lmo ${CURDIR}/po/zh-cn/clash.po ${CURDIR}/po/zh-cn/clash.zh-cn.lmoo
endef
define Build/Configure
@ -96,7 +96,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/clash
$(INSTALL_DIR) $(1)/tmp
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/usr/share/
$(INSTALL_DIR) $(1)/usr/share/clash
@ -106,6 +105,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/img
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/js
$(INSTALL_DIR) $(1)/etc/clash/clashtun
$(INSTALL_DIR) $(1)/etc/clash/dtun
$(INSTALL_DIR) $(1)/usr/share/clashbackup
$(INSTALL_DIR) $(1)/etc/clash/provider
$(INSTALL_DIR) $(1)/usr/share/clash/config
@ -134,7 +134,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/server.list $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash_real.txt $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/logstatus_check $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash.txt $(1)/tmp/
$(INSTALL_BIN) ./root/usr/share/clash/clash.txt $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.0bddb85299f970595cb5.css $(1)/usr/share/clash/dashboard/

View File

@ -20,9 +20,9 @@ function index()
entry({"admin", "services", "clash", "config"},cbi("clash/config"),_("Config"), 30).leaf = true
entry({"admin", "services", "clash", "create"},cbi("clash/create"),_("Create Config"), 40).leaf = true
entry({"admin", "services", "clash", "servers-config"},cbi("clash/servers-config"), nil).leaf = true
entry({"admin", "services", "clash", "provider-config"},cbi("clash/provider-config"), nil).leaf = true
entry({"admin", "services", "clash", "groups"},cbi("clash/groups"), nil).leaf = true
entry({"admin", "services", "clash", "servers"},cbi("clash/servers-config"), nil).leaf = true
entry({"admin", "services", "clash", "provider"},cbi("clash/provider-config"), nil).leaf = true
entry({"admin", "services", "clash", "groups"},cbi("clash/groups"), nil).leaf = true
entry({"admin", "services", "clash", "settings"}, firstchild(),_("Settings"), 50)
entry({"admin", "services", "clash", "settings", "port"},cbi("clash/port"),_("Proxy Ports"), 60).leaf = true
@ -31,7 +31,7 @@ function index()
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 90).leaf = true
entry({"admin", "services", "clash", "settings", "grules"},cbi("clash/game-settings"),_("Game Rules"), 91).dependent = false
entry({"admin", "services", "clash", "g-rules"},cbi("clash/game-rule"), nil).leaf = true
entry({"admin", "services", "clash", "g-rules"},cbi("clash/game-rule"), nil).leaf = true
entry({"admin","services","clash","status"},call("action_status")).leaf=true
entry({"admin", "services", "clash", "log"},cbi("clash/log"),_("Log"), 150).leaf = true
@ -174,15 +174,26 @@ end
local function clash_core()
if nixio.fs.access("/etc/clash/clash") then
return luci.sys.exec("/etc/clash/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
local core=luci.sys.exec("/etc/clash/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
if core ~= "" then
return luci.sys.exec("/etc/clash/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
else
return luci.sys.exec("sed -n 1p /usr/share/clash/core_version")
end
else
return "0"
end
end
local function clashr_core()
if nixio.fs.access("/usr/bin/clash") then
return luci.sys.exec("/usr/bin/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
local core=luci.sys.exec("/usr/bin/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
if core ~= "" then
return luci.sys.exec("/usr/bin/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
else
return luci.sys.exec("sed -n 1p /usr/share/clash/corer_version")
end
else
return "0"
end
@ -203,6 +214,14 @@ local function clashtun_core()
end
local function dtun_core()
if nixio.fs.access("/etc/clash/dtun/clash") then
return luci.sys.exec("/etc/clash/dtun/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
else
return "0"
end
end
local function readlog()
return luci.sys.exec("sed -n '$p' /usr/share/clash/clash_real.txt 2>/dev/null")
@ -268,6 +287,7 @@ function check_status()
clash_core = clash_core(),
clashr_core = clashr_core(),
clashtun_core = clashtun_core(),
dtun_core = dtun_core(),
new_core_version = new_core_version(),
new_clashtun_core_version =new_clashtun_core_version(),
check_clashtun_core = check_clashtun_core(),
@ -285,6 +305,7 @@ function action_status()
current_version = current_version(),
clash_core = clash_core(),
clashr_core = clashr_core(),
dtun_core = dtun_core(),
dash_pass = dash_pass(),
clashtun_core = clashtun_core(),
e_mode = e_mode(),
@ -363,7 +384,7 @@ end
function logstatus_check()
luci.http.prepare_content("text/plain; charset=utf-8")
local fdp=tonumber(fs.readfile("/usr/share/clash/logstatus_check")) or 0
local f=io.open("/tmp/clash.txt", "r+")
local f=io.open("/usr/share/clash/clash.txt", "r+")
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()

View File

@ -22,7 +22,10 @@ if nixio.fs.access("/usr/bin/clash") then
o:value("2", translate("Clashr"))
end
if nixio.fs.access("/etc/clash/clashtun/clash") then
o:value("3", translate("ClashTun"))
o:value("3", translate("Clash(cTun)"))
end
if nixio.fs.access("/etc/clash/dtun/clash") then
o:value("4", translate("Clash(dTun)"))
end
o.description = translate("Select core, clashr support ssr while clash does not.")

View File

@ -150,7 +150,7 @@ s.anonymous = true
s.addremove = true
s.sortable = false
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers-config/%s")
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
@ -192,7 +192,7 @@ s.anonymous = true
s.addremove = true
s.sortable = false
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/clash/provider-config/%s")
s.extedit = luci.dispatcher.build_url("admin/services/clash/provider/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then

View File

@ -90,7 +90,7 @@ o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
else
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash" , "settings", "dns"))

View File

@ -73,9 +73,9 @@ o.description = translate("Dashboard Secret")
o = s:option(ListValue, "p_mode", translate("Proxy Mode"))
o.description = translate("Choose proxy mode")
o:value("Rule", "RULE")
o:value("Global", "GLOBAL")
o:value("Direct", "DIRECT")
o:value("Rule", translate("RULE"))
o:value("Global", translate("GLOBAL"))
o:value("Direct", translate("DIRECT"))
o.default = "Rule"
o = s:option(ListValue, "level", translate("Log level"))

View File

@ -12,6 +12,57 @@ font_off = [[</font>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
ko = Map("clash")
ko.reset = false
ko.submit = false
sul =ko:section(TypedSection, "clash","")
sul.anonymous = true
sul.addremove=false
o = sul:option(FileUpload, "")
o.description = translate("NB: Upload only Dreamacro clash tun core - (https://github.com/Dreamacro/clash/releases/tag/TUN)")
o.title = translate(" ")
o.template = "clash/clash_upload"
um = sul:option(DummyValue, "", nil)
um.template = "clash/clash_dvalue"
local dir, fd
dir = "/etc/clash/dtun/"
http.setfilehandler(
function(meta, chunk, eof)
if not fd then
if not meta then return end
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
if not fd then
um.value = translate("upload file error.")
return
end
end
if chunk and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
SYS.exec("chmod 755 /etc/clash/dtun/clash 2>&1 &")
um.value = translate("File saved to") .. ' "/etc/clash/dtun/"'
end
end
)
if luci.http.formvalue("upload") then
local f = luci.http.formvalue("ulfile")
if #f <= 0 then
um.value = translate("No specify upload file.")
end
end
m = Map("clash")
m:section(SimpleSection).template = "clash/update"
m.pageaction = false
@ -23,7 +74,7 @@ o = s:option(ListValue, "dcore", translate("Core Type"))
o.default = "clashcore"
o:value("1", translate("Clash"))
o:value("2", translate("Clashr"))
o:value("3", translate("ClashTun"))
o:value("3", translate("Clash(ctun)"))
o.description = translate("Select core, clashr support ssr while clash does not.")
@ -57,6 +108,6 @@ o.title = translate("Download")
o.template = "clash/core_check"
return m, k
return m, ko,k

View File

@ -163,8 +163,9 @@ var HTTP = {
ip.innerHTML = status.localip ? '<b><font color="green">'+status.localip+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
port.innerHTML = status.dash_port ? '<b><font color="green">'+status.dash_port+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
secret.innerHTML = status.dash_pass ? '<b><font color="green">'+status.dash_pass+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
emode.innerHTML = status.clash ? '<b><font color="green" style="text-transform: uppercase;">'+status.e_mode+'</font> </b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
conf.innerHTML = status.clash ? '<b><input type="button" class="btn" style="background-color:black;padding: 5px;font-color:green;color:green;font-weight:bold" value="<%:VIEW CONFIG%>" onclick="return view(this)"/></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
emode.innerHTML = status.clash ? '<b><font color="green" style="text-transform: uppercase;">'+status.e_mode+'</font> </b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>'; if(status.typeconf != 0 || status.typeconf != ''){
conf.innerHTML = status.typeconf ? '<b><input type="button" class="btn" style="background-color:black;padding: 5px;font-color:green;color:green;font-weight:bold" value="<%:VIEW CONFIG%>" onclick="return view(this)"/></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
}
if(status.typeconf==1){
conf_path.innerHTML = status.clash ? '<b><font color="green"><%:SUBSCRIBE%> </font></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
}

View File

@ -17,8 +17,11 @@
<td align="center" width="35%">clashr</td> <td align="center" width="35%" id="_corer"><%:Collecting data...%></td> <td width="35%" align="center" id="_corerbutt"></td>
</tr>
<tr>
<td align="center" width="35%">clash(tun)</td> <td align="center" width="35%" id="_coretun"><%:Collecting data...%></td> <td width="35%" align="center" id="_coretunbutt"></td>
</tr>
<td align="center" width="35%">clash(ctun)</td> <td align="center" width="35%" id="_coretun"><%:Collecting data...%></td> <td width="35%" align="center" id="_coretunbutt"></td>
</tr>
<tr>
<td align="center" width="35%">clash(dtun)</td> <td align="center" width="35%" id="_coredtun"><%:Collecting data...%></td> <td width="35%" align="center" id="_coredtunbutt"></td>
</tr>
<tr>
<td align="center" width="35%">luci-app-clash</td> <td align="center" width="35%" id="_version"><%:Collecting data...%> </td> <td width="35%" align="center" id="_versionbutt"></td>
</tr>
@ -41,6 +44,8 @@
var core_butt = document.getElementById('_corebutt');
var corer_butt = document.getElementById('_corerbutt');
var coretun_butt = document.getElementById('_coretunbutt');
var coredtun = document.getElementById('_coredtun');
var coredtun_butt = document.getElementById('_coredtunbutt');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
@ -59,6 +64,11 @@
coretun.innerHTML = status.clashtun_core ? '<b><font color="red"><%:Not Installed%></font> </b>' : '<em><b><font color="red"><%:Checking...%></font></b></em>';
}else{
coretun.innerHTML = status.clashtun_core ? '<b><font color="green">'+status.clashtun_core+'</font> </b>' : '<em><b><font color="red"><%:Checking...%></font></b></em>';
}
if(status.dtun_core==0){
coredtun.innerHTML = status.dtun_core ? '<b><font color="red"><%:Not Installed%></font> </b>' : '<em><b><font color="red"><%:Checking...%></font></b></em>';
}else{
coredtun.innerHTML = status.dtun_core ? '<b><font color="green">'+status.dtun_core+'</font> </b>' : '<em><b><font color="red"><%:Checking...%></font></b></em>';
}
version.innerHTML = status.current_version ? '<b><font color="green">v'+status.current_version+'</font> </b>' : '<em><b><font color="red"><%:Checking...%></font></b></em>';
@ -72,6 +82,7 @@
core_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return core_check(this)"/></center>' : '<em></em>';
corer_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashr_core_check(this)"/></center>' : '<em></em>';
coretun_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashtun_core_check(this)"/></center>' : '<em></em>';
coredtun_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashdtun_core_check(this)"/></center>' : '<em></em>';
@ -148,7 +159,14 @@ function clashr_core_check(btn)
});
}
function clashdtun_core_check(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
url='https://github.com/Dreamacro/clash/releases/tag/TUN';
window.open(url);
return false;
});
}
function clashtun_core_check(btn)
{

View File

@ -952,3 +952,6 @@ msgstr "代理模式"
msgid "Choose proxy mode"
msgstr "选择代理模式"
msgid "NB: Upload only Dreamacro clash tun core - (https://github.com/Dreamacro/clash/releases/tag/TUN)"
msgstr "注意只上传clash tun内核-(https://github.com/Dreamacro/clash/releases/tag/TUN)"

View File

@ -6,6 +6,7 @@ STOP=15
CLASH="/etc/clash/clash"
CLASHR="/usr/bin/clash"
CLASHT="/etc/clash/clashtun/clash"
CLASHD="/etc/clash/dtun/clash"
CLASH_CONFIG="/etc/clash"
CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
@ -34,7 +35,7 @@ add_cron(){
config_type=$(uci get clash.config.config_type 2>/dev/null)
#===========================================================================================================================
sed -i '/clash.txt/d' $CRON_FILE
echo '0 0 * * 0 echo "" >> /tmp/clash.txt' >> $CRON_FILE
echo '0 0 * * 0 echo "" >> /usr/share/clash/clash.txt' >> $CRON_FILE
[ -n "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/clash\/clash.sh/d' $CRON_FILE
[ -n "$(grep -w "/usr/share/clash/v2ssr.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/clash\/v2ssr.sh/d' $CRON_FILE
auto=$(uci get clash.config.auto_update 2>/dev/null)
@ -206,7 +207,8 @@ rules(){
ipv6=$(uci get clash.config.ipv6 2>/dev/null)
core=$(uci get clash.config.core 2>/dev/null)
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)
lan_ip=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
wan=$(ubus call network.interface.wan status 2>/dev/null | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 2>/dev/null)
if [ "${core}" -eq 1 ] || [ "${core}" -eq 2 ];then
iptables -t nat -N clash
iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN
@ -217,15 +219,13 @@ rules(){
iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN
iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
iptables -t nat -A clash -d "${lan_ip}" -j RETURN
if [ ! -z "$wan" ]; then
iptables -t nat -A clash -d "${wan}" -j RETURN
fi
iptables -t nat -A clash -p tcp -j REDIRECT --to-ports "${redir_port}"
if [ -z "$(iptables -nvL zone_lan_prerouting -t nat)" ]; then
iptables -t nat -A PREROUTING -p tcp -j clash
else
iptables -t nat -A zone_lan_prerouting -p tcp -j clash
fi
iptables -t nat -A PREROUTING -p tcp -j clash
fake_ip_range=$(egrep '^ {0,}fake-ip-range' /etc/clash/config.yaml |grep fake-ip-range: |awk -F ': ' '{print $2}')
if [ ! -z "${fake_ip_range}" ];then
@ -238,14 +238,11 @@ rules(){
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
ip6tables -t nat -N clash_ipv6
ip6tables -t nat -A clash_ipv6 -p tcp -j REDIRECT --to-ports "${redir_port}"
if [ -z "$(ip6tables -nvL zone_lan_prerouting -t nat)" ]; then
ip6tables -t nat -A PREROUTING -p tcp -j clash_ipv6
else
ip6tables -t nat -A zone_lan_prerouting -p tcp -j clash_ipv6
fi
ip6tables -t nat -A PREROUTING -p tcp -j clash_ipv6
fi
elif [ "${core}" -eq 3 ];then
elif [ "${core}" -eq 3 ] || [ "${core}" -eq 4 ];then
PROXY_FWMARK="0x162"
PROXY_ROUTE_TABLE="0x162"
PROXY_BYPASS_USER="root"
@ -265,11 +262,19 @@ rules(){
ipset add localnetwork 224.0.0.0/4
ipset add localnetwork 240.0.0.0/4
ipset add localnetwork 172.16.0.0/12
ipset add localnetwork "${lan_ip}"
if [ ! -z "$wan" ]; then
ipset add localnetwork "${wan}"
fi
if [ "${core}" -eq 3 ];then
ip tuntap add user root mode tun $TUN_DEVICE_NAME
ip link set $TUN_DEVICE_NAME up
ip address replace 198.18.0.0/16 dev $TUN_DEVICE_NAME
ip route replace default dev $TUN_DEVICE_NAME table "$PROXY_ROUTE_TABLE"
elif [ "${core}" -eq 4 ];then
ip route replace default dev utun table "$PROXY_ROUTE_TABLE"
fi
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
iptables -t mangle -N clash
@ -311,6 +316,10 @@ enable=$(uci get clash.config.enable 2>/dev/null)
core=$(uci get clash.config.core 2>/dev/null)
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)
if [ -f /etc/clash/config.yaml ];then
rm -rf /etc/clash/config.yaml >/dev/null 2>&1
fi
if [ "${enable}" -eq 1 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Starting Client.. " >$REAL_LOG
@ -323,10 +332,10 @@ if [ "${enable}" -eq 1 ]; then
if [ "${core}" -eq 1 ] && [ ! -f /etc/clash/clash ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - clash core not found, download and install clash from update page " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - clash core not found, download and install clash from update page " >> /usr/share/clash/clash.txt
echo "clash core not found, download and install clash from update page" >> $REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/etc/clash/clash,请从更新页下载clash内核" >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/etc/clash/clash,请从更新页下载clash内核" >> /usr/share/clash/clash.txt
echo "找不到/etc/clash/clash,请从更新页下载clash内核" >> $REAL_LOG
fi
sleep 2
@ -334,10 +343,10 @@ if [ "${core}" -eq 1 ] && [ ! -f /etc/clash/clash ]; then
exit 0
elif [ "${core}" -eq 2 ] && [ ! -f /usr/bin/clash ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - clashr core not found in /usr/bin/clash download and install clashr from update page " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - clashr core not found in /usr/bin/clash download and install clashr from update page " >> /usr/share/clash/clash.txt
echo "clashr core not found, download and install clash from update page" >> $REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/usr/bin/clash,请从更新页下载clashr内核" >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/usr/bin/clash,请从更新页下载clashr内核" >> /usr/share/clash/clash.txt
echo "找不到/usr/bin/clash,请从更新页下载clashr内核" >> $REAL_LOG
fi
sleep 2
@ -345,10 +354,10 @@ elif [ "${core}" -eq 2 ] && [ ! -f /usr/bin/clash ]; then
exit 0
elif [ "${core}" -eq 3 ] && [ ! -f /etc/clash/clashtun/clash ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - clashr Tun core not found in /etc/clash/clashtun/clash " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - clashr Tun core not found in /etc/clash/clashtun/clash " >> /usr/share/clash/clash.txt
echo "clash Tun core not found in /etc/clash/clashtun/clash" >> $REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/etc/clash/clashtun/clash, clash Tun内核" >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/etc/clash/clashtun/clash, clash Tun内核" >> /usr/share/clash/clash.txt
echo "找不到/usr/bin/clash, clash Tun内核" >> $REAL_LOG
fi
sleep 2
@ -412,8 +421,8 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
game_rules >/dev/null 2>&1
if [ "${core}" -eq 1 ];then
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
if [ "${core}" -eq 1 ];then
nohup $CLASH -d "$CLASH_CONFIG" > /usr/share/clash/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core Started Successfully " >$REAL_LOG
@ -422,16 +431,23 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
fi
elif [ "${core}" -eq 3 ];then
nohup $CLASHT -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
nohup $CLASHT -d "$CLASH_CONFIG" > /usr/share/clash/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core Started Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash 计划任务,启动进程守护程序..." >$REAL_LOG
fi
elif [ "${core}" -eq 4 ];then
nohup $CLASHD -d "$CLASH_CONFIG" > /usr/share/clash/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core Started Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash 计划任务,启动进程守护程序..." >$REAL_LOG
fi
elif [ "${core}" -eq 2 ];then
nohup $CLASHR -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
nohup $CLASHR -d "$CLASH_CONFIG" > /usr/share/clash/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clashr Core Started Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
@ -448,11 +464,11 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "设置 Clash iptables" >$REAL_LOG
fi
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
uci set firewall.@defaults[0].forward=ACCEPT >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
/etc/init.d/firewall restart >/dev/null 2>&1
fi
fi
sleep 2
rules >/dev/null 2>&1
@ -494,12 +510,12 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
fi
else
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /usr/share/clash/clash.txt
echo " problem with config file " >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 你的config.yaml有问题还是为了空 0kb " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 你的config.yaml有问题还是为了空 0kb " >> /usr/share/clash/clash.txt
echo " 你的config.yaml有问题还是为了空 0kb " >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
@ -509,12 +525,12 @@ fi
else
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Enable Client and Start Client Again" >$REAL_LOG
echo " $(date "+%Y-%m-%d %H:%M:%S") - Enable Client and Start Client Again" >>/tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - Enable Client and Start Client Again" >>/usr/share/clash/clash.txt
sleep 3
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "启用客户端并重新启动客户端" >$REAL_LOG
echo " $(date "+%Y-%m-%d %H:%M:%S") - 启用客户端并重新启动客户端" >>/tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 启用客户端并重新启动客户端" >>/usr/share/clash/clash.txt
sleep 3
echo "Clash for OpenWRT" >$REAL_LOG
fi
@ -530,19 +546,15 @@ remove_mark(){
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
ip6tables -t nat -F clash_ipv6 2>/dev/null1 && ip6tables -t nat -X clash_ipv6 2>/dev/null
if [ -z "$(ip6tables -nvL zone_lan_prerouting -t nat)" ]; then
ip6tables -t nat -D PREROUTING -p tcp -j clash_ipv6 >/dev/null 2>&1
else
mangle_indexs=$(ip6tables -nvL zone_lan_prerouting -t nat | sed 1,2d | sed -n '/clash_ipv6/=' | sort -r)
ip6tables -t nat -F clash_ipv6 2>/dev/null1 && ip6tables -t nat -X clash_ipv6 2>/dev/null
mangle_indexs=$(ip6tables -nvL PREROUTING -t nat | sed 1,2d | sed -n '/clash_ipv6/=' | sort -r)
for mangle_index in $mangle_indexs; do
ip6tables -t nat -D zone_lan_prerouting $mangle_index 2>/dev/null
ip6tables -t nat -D PREROUTING $mangle_index 2>/dev/null
done
fi
fi
if [ "${core}" -eq 3 ];then
if [ "${core}" -eq 3 ] || [ "${core}" -eq 4 ];then
PROXY_FWMARK="0x162" 2>/dev/null
PROXY_ROUTE_TABLE="0x162" 2>/dev/null
@ -552,11 +564,11 @@ remove_mark(){
else
TUN_DEVICE_NAME=$TUN_DEVICE
fi
if [ "${core}" -eq 3 ];then
ip link set dev $TUN_DEVICE_NAME down 2>/dev/null
ip tuntap del $TUN_DEVICE_NAME mode tun 2>/dev/null
ip route del default dev $TUN_DEVICE_NAME table "$PROXY_ROUTE_TABLE" 2>/dev/null
fi
ip rule del fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null
iptables -t mangle -D OUTPUT -j clash 2>/dev/null
@ -578,7 +590,7 @@ remove_mark(){
ipset destroy localnetwork 2>/dev/null
fi
/etc/init.d/dnsmasq restart >/dev/null 2>&1
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}
stop(){
@ -606,14 +618,11 @@ stop(){
fi
iptables -t nat -F clash >/dev/null 2>&1 && iptables -t nat -X clash >/dev/null 2>&1
if [ -z "$(iptables -nvL zone_lan_prerouting -t nat)" ]; then
iptables -t nat -D PREROUTING -p tcp -j clash >/dev/null 2>&1
else
nat_indexs=$(iptables -nvL zone_lan_prerouting -t nat | sed 1,2d | sed -n '/clash/=' | sort -r)
nat_indexs=$(iptables -nvL PREROUTING -t nat | sed 1,2d | sed -n '/clash/=' | sort -r)
for nat_index in $nat_indexs; do
iptables -t nat -D zone_lan_prerouting $nat_index >/dev/null 2>&1
iptables -t nat -D PREROUTING $nat_index >/dev/null 2>&1
done
fi
fake=$(iptables -nvL OUTPUT -t nat |sed 1,2d |sed -n '/198.18.0.0\/16/=' |sort -r)
for fake in $fake; do
@ -666,26 +675,26 @@ stop(){
revert_dns >/dev/null 2>&1
sleep 1
echo "" >/tmp/clash.txt >/dev/null 2>&1
echo "" >/usr/share/clash/clash.txt >/dev/null 2>&1
echo "0" > /usr/share/clash/logstatus_check >/dev/null 2>&1
rm -rf /etc/clash/*.yaml /etc/clash/*.yml >/dev/null 2>&1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /usr/share/clash/clash.txt
echo "Client is Disabled " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 客户端被禁用 " >> /tmp/clash.txt
echo " $(date "+%Y-%m-%d %H:%M:%S") - 客户端被禁用 " >> /usr/share/clash/clash.txt
echo "客户端被禁用 " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
if pidof clash >/dev/null; then
kill $(pidof clash) >/dev/null 2>&1 || kill -9 $(ps | grep clash | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi
if pidof clash >/dev/null; then
kill $(pidof clash) >/dev/null 2>&1 || kill -9 $(ps | grep clash | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi
#===========================================================================================================================

View File

@ -8,7 +8,7 @@ create=$(uci get clash.config.create 2>/dev/null)
load_from=$(uci get clash.config.loadfrom 2>/dev/null)
config_name=$(uci get clash.config.create_tag 2>/dev/null)
CONFIG_YAML="/usr/share/clash/config/custom/${config_name}.yaml"
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/create_list.conf")
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/create_list.conf")
same_tag=$(uci get clash.config.same_tag 2>/dev/null)
@ -401,17 +401,7 @@ config_load clash
config_foreach servers_set "servers"
fi
if [ -z "${scount}" ] || [ "${scount}" -eq 0 ];then
cat >> "$SERVER_FILE" <<-EOF
- name: Shadowsocks
type: ss
server: 127.0.0.1
port: 1080
cipher: aes-256-gcm
password: "12345"
EOF
fi
if [ ! -z "${scount}" ] || [ "${scount}" -ne 0 ];then
sed -i "1i\ " $SERVER_FILE 2>/dev/null
sed -i "2i\Proxy:" $SERVER_FILE 2>/dev/null
@ -419,7 +409,7 @@ sed -i "2i\Proxy:" $SERVER_FILE 2>/dev/null
egrep '^ {0,}-' $SERVER_FILE |grep name: |awk -F 'name: ' '{print $2}' |sed 's/,.*//' >$Proxy_Group 2>&1
sed -i "s/^ \{0,\}/ - /" $Proxy_Group 2>/dev/null
fi
yml_servers_add()
@ -501,14 +491,14 @@ yml_groups_set()
echo " type: $type" >>$GROUP_FILE 2>/dev/null
group_name="$name"
#echo " proxies: $group_name" >>$GROUP_FILE
echo " proxies: $group_name" >>$GROUP_FILE
if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$type" == "fallback" ] ; then
echo " proxies:" >>$GROUP_FILE 2>/dev/null
#cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
else
echo " proxies:" >>$GROUP_FILE 2>/dev/null
fi
#if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$type" == "fallback" ] ; then
# echo " proxies:" >>$GROUP_FILE 2>/dev/null
# cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
#else
# echo " proxies:" >>$GROUP_FILE 2>/dev/null
#fi
if [ "$name" != "$old_name" ]; then
sed -i "s/,${old_name}$/,${name}#d/g" $load 2>/dev/null
@ -609,12 +599,12 @@ if [ -f $SERVER_FILE ];then
cat $SERVER_FILE >> $TEMP_FILE 2>/dev/null
fi
cat $GROUP_FILE >> $TEMP_FILE 2>/dev/null
if [ -f $PROVIDER_FILE ];then
cat $PROVIDER_FILE >> $TEMP_FILE 2>/dev/null
fi
cat $GROUP_FILE >> $TEMP_FILE 2>/dev/null
if [ -f $CONFIG_YAML ];then
rm -rf $CONFIG_YAML
fi

View File

@ -17,14 +17,14 @@ fi
if [ -z "$(grep "^ \{0,\}tun:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}listen:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}enhanced-mode:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}enable:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}dns:" $CONFIG_YAML)" ] ;then
#===========================================================================================================================
if [ "${core}" -eq 3 ];then
if [ "${core}" -eq 3 ] || [ "${core}" -eq 4 ];then
uci set clash.config.mode="0" && uci set clash.config.tun_mode="1" && uci commit clash
else
uci set clash.config.mode="1" && uci set clash.config.tun_mode="0" && uci commit clash
fi
#===========================================================================================================================
fi
sleep 2
#===========================================================================================================================
mode=$(uci get clash.config.mode 2>/dev/null)
@ -49,9 +49,13 @@ if [ "${mode}" -eq 1 ]; then
fi
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
if [ ! -z "$(grep "^Proxy:" "$CONFIG_YAML")" ]; then
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
elif [ ! -z "$(grep "^proxy-provider:" "$CONFIG_YAML")" ]; then
sed -i "/proxy-provider:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
fi
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
sed -i "/#=============/a\ " $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null
mv /etc/clash/config.yaml /etc/clash/dns.yaml
@ -102,7 +106,11 @@ elif [ "${tun_mode}" -eq 1 ]; then
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
if [ ! -z "$(grep "^Proxy:" "$CONFIG_YAML")" ]; then
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
elif [ ! -z "$(grep "^proxy-provider:" "$CONFIG_YAML")" ]; then
sed -i "/proxy-provider:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
fi
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
sed -i "/#=============/a\ " $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null