Skip to content

Commit

Permalink
Merge pull request #229 from frainzy1477/test
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
frainzy1477 authored Apr 4, 2020
2 parents 5f3e32a + 3aa9e90 commit cde2979
Show file tree
Hide file tree
Showing 23 changed files with 247 additions and 3,521 deletions.
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-clash
PKG_VERSION:=1.6.5
PKG_VERSION:=1.6.6
PKG_MAINTAINER:=frainzy1477


Expand Down Expand Up @@ -116,14 +116,11 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/share/clash/config/sub
$(INSTALL_DIR) $(1)/usr/share/clash/config/upload
$(INSTALL_DIR) $(1)/usr/share/clash/config/custom
$(INSTALL_DIR) $(1)/usr/share/clash/v2ssr


$(INSTALL_BIN) ./root/etc/init.d/clash $(1)/etc/init.d/clash
$(INSTALL_CONF) ./root/etc/config/clash $(1)/etc/config/clash
$(INSTALL_CONF) ./root/etc/clash/* $(1)/etc/clash/

$(INSTALL_BIN) ./root/usr/share/clash/v2ssr/v2ssr_custom_rule.yaml $(1)/usr/share/clash/v2ssr/
$(INSTALL_BIN) ./root/usr/share/clash/v2ssr/policygroup $(1)/usr/share/clash/v2ssr/

$(INSTALL_BIN) ./root/usr/share/clash/*.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dns.yaml $(1)/usr/share/clash/
Expand All @@ -141,10 +138,10 @@ define Package/$(PKG_NAME)/install
$(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.ad0717ae3407e246a9ab.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/33343e6117c37aaef8886179007ba6b5.png $(1)/usr/share/clash/dashboard/img/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.ad0717ae3407e246a9ab.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.ad0717ae3407e246a9ab.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.693efc9234a08d249710.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png $(1)/usr/share/clash/dashboard/img/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.693efc9234a08d249710.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.693efc9234a08d249710.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/yacd/* $(1)/usr/share/clash/yacd/

$(INSTALL_DATA) ./luasrc/clash.lua $(1)/usr/lib/lua/luci/
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
A rule based custom proxy for Openwrt based on <a href="https://github.com/Dreamacro/clash" target="_blank">Clash</a>.
</p>
<p align="center">
<a target="_blank" href="https://github.com/frainzy1477/luci-app-clash/releases/tag/v1.6.5">
<img src="https://img.shields.io/badge/luci%20for%20clash-v1.6.5-blue.svg">
<a target="_blank" href="https://github.com/frainzy1477/luci-app-clash/releases/tag/v1.6.6">
<img src="https://img.shields.io/badge/luci%20for%20clash-v1.6.6-blue.svg">
</a>
<!-- <a href="https://github.com/frainzy1477/luci-app-clash/releases" target="_blank">
<img src="https://img.shields.io/github/downloads/frainzy1477/luci-app-clash/total.svg?style=flat-square"/>
Expand All @@ -22,8 +22,8 @@

- cd /tmp
- opkg update
- opkg install luci-app-clash_1.6.5_all.ipk
- opkg install luci-app-clash_1.6.5_all.ipk --force-depends
- opkg install luci-app-clash_1.6.6_all.ipk
- opkg install luci-app-clash_1.6.6_all.ipk --force-depends

## Features

Expand Down
5 changes: 5 additions & 0 deletions luasrc/model/cbi/clash/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ o:value("4", translate("Clash(dTun)"))
end
o.description = translate("Select core, clashr support ssr while clash does not.")


o = s:option(Flag, "old_conf", translate("Old Config"))
o.description = translate("Proxy/Proxy Groups/Rule")


o = s:option(ListValue, "g_rules", translate("Game Rules"))
o.default = "0"
o:value("0", translate("Disable"))
Expand Down
35 changes: 26 additions & 9 deletions luasrc/model/cbi/clash/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ kr.pageaction = false
o = s:option(ListValue, "subcri", translate("Subcription Type"))
o.default = clash
o:value("clash", translate("clash"))
o:value("v2ssr2clash", translate("v2ssr2clash"))
o:value("ssr2clash", translate("ssr2clash"))
o:value("v2clash", translate("v2clash"))
o.description = translate("Select Subcription Type")

o = s:option(Value, "config_name")
o.title = translate("Config Name")
o.description = translate("Config Name. Do not use a config name that already exist")

o = s:option(Value, "subscribe_url_clash")
o = s:option(Value, "clash_url")
o.title = translate("Subcription Url")
o.description = translate("Clash Subscription Address")
o.rmempty = true
Expand All @@ -46,11 +47,11 @@ o.write = function()
end
o:depends("subcri", 'clash')

o = s:option(Value, "subscribe_url")
o = s:option(Value, "ssr_url")
o.title = translate("Subcription Url")
o.description = translate("V2/SSR Subscription Address, Only input your subscription address without any api conversion url")
o.placeholder = translate("https://www.example.com/link/QkjokZXktyyr35gfj")
o.rmempty = true
o:depends("subcri", 'v2ssr2clash')
o:depends("subcri", 'ssr2clash')


o = s:option(Button,"updatee")
Expand All @@ -59,12 +60,28 @@ o.inputtitle = translate("Download Config")
o.inputstyle = "reload"
o.write = function()
kr.uci:commit("clash")
SYS.call("cp /etc/config/clash /usr/share/clash/v2ssr/config.bak 2>/dev/null")
SYS.call("sleep 1")
luci.sys.call("bash /usr/share/clash/v2ssr.sh >>/usr/share/clash/clash.txt 2>&1 &")
luci.sys.call("bash /usr/share/clash/clash.sh >>/usr/share/clash/clash.txt 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash"))
end
o:depends("subcri", 'ssr2clash')

o = s:option(Value, "v2_url")
o.title = translate("Subcription Url")
o.placeholder = translate("https://www.example.com/link/QkjokZXktyyr35gfj")
o.rmempty = true
o:depends("subcri", 'v2clash')


o = s:option(Button,"updateee")
o.title = translate("Download Config")
o.inputtitle = translate("Download Config")
o.inputstyle = "reload"
o.write = function()
kr.uci:commit("clash")
luci.sys.call("bash /usr/share/clash/clash.sh >>/usr/share/clash/clash.txt 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash"))
end
o:depends("subcri", 'v2ssr2clash')
o:depends("subcri", 'v2clash')


function IsYamlFile(e)
Expand Down
2 changes: 1 addition & 1 deletion luasrc/model/cbi/clash/other.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end


w = Map("clash")
s = w:section(TypedSection, "clash" , translate("Load Groups)"))
s = w:section(TypedSection, "clash" , translate("Load Groups"))
s.anonymous = true


Expand Down
32 changes: 24 additions & 8 deletions luasrc/model/cbi/clash/servers-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ o = s:option(ListValue, "obfs_vmess", translate("obfs-mode"))
o.default = "none"
o:value("none")
o:value("websocket", translate("websocket (ws)"))
o:value("http", translate("http"))
o:depends("type", "vmess")

o = s:option(Value, "host", translate("hosts"))
Expand Down Expand Up @@ -215,22 +216,35 @@ o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")

o = s:option(ListValue, "mux", translate("Mux"))
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o = s:option(DynamicList, "http_path", translate("path"))
o.rmempty = true
o:value("/")
o:value("/video")
o:depends("obfs_vmess", "http")

o = s:option(Value, "custom", translate("headers"))
o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")

o = s:option(Value, "keep_alive", translate("keep-alive"))
o.rmempty = true
o.default = "true"
o:value("true")
o:value("false")
o:depends("obfs_vmess", "http")

o = s:option(ListValue, "mux", translate("Mux"))
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")


-- AlterId
o = s:option(Value, "alterId", translate("AlterId"))
o.datatype = "port"
o.default = 16
o.default = 32
o.rmempty = true
o:depends("type", "vmess")

Expand Down Expand Up @@ -272,10 +286,12 @@ o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("type", "vmess")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("obfs_vmess", "http")
o:depends("type", "socks5")
o:depends("type", "http")
o:depends("obfs_vmess", "none")

-- [[ sni ]]--
o = s:option(Value, "sni", translate("sni"))
Expand Down
5 changes: 4 additions & 1 deletion po/zh-cn/clash.po
Original file line number Diff line number Diff line change
Expand Up @@ -1038,4 +1038,7 @@ msgid "DNS Cache"
msgstr "DNS缓存"

msgid "Set to enable or disable dns cache"
msgstr "设置为启用或禁用dns缓存"
msgstr "设置为启用或禁用dns缓存"

msgid "Old Config"
msgstr "旧配置"
27 changes: 0 additions & 27 deletions root/etc/config/clash
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,6 @@ config clash 'config'
option ping_enable '1'
option dnscache '0'

config groups
option old_name '❌AdBlock'
option old_name_cfg '❌AdBlock'
option type 'select'
list other_group 'REJECT'
option name '❌AdBlock'

config groups
option old_name '🖥️AsianTV'
option old_name_cfg '🖥️AsianTV'
option type 'select'
option name '🖥️AsianTV'
list other_group 'DIRECT'
list other_group '🔑Proxy'

config groups
option old_name '📺GlobalTV'
option old_name_cfg '📺GlobalTV'
option type 'select'
option name '📺GlobalTV'
list other_group 'ALL'

config groups
option type 'select'
option name '🔑Proxy'
list other_group 'ALL'


config addtype
option type 'IP-CIDR'
Expand Down
6 changes: 4 additions & 2 deletions root/etc/init.d/clash
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ enable=$(uci get clash.config.enable 2>/dev/null)
core=$(uci get clash.config.core 2>/dev/null)
mode=$(uci get clash.config.mode 2>/dev/null)
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)

old_conf=$(uci get clash.config.old_conf 2>/dev/null)


if [ -f /etc/clash/config.yaml ];then
Expand Down Expand Up @@ -509,8 +509,10 @@ elif [ "${core}" -eq 3 ] && [ ! -f /etc/clash/clashtun/clash ]; then
exit 0
else
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] ; then


if [ -z "$old_conf" ];then
check >/dev/null 2>&1
fi

yml_change >/dev/null 2>&1

Expand Down
73 changes: 63 additions & 10 deletions root/usr/share/clash/clash.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh


subscribe_url=$(uci get clash.config.subscribe_url_clash 2>/dev/null)
clash_url=$(uci get clash.config.clash_url 2>/dev/null)
ssr_url=$(uci get clash.config.ssr_url 2>/dev/null)
v2_url=$(uci get clash.config.v2_url 2>/dev/null)

config_name=$(uci get clash.config.config_name 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
Expand Down Expand Up @@ -45,11 +46,66 @@ else
echo "开始下载配置" >$REAL_LOG
fi
sleep 1

wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML

if [ "$subtype" = "clash" ];then
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" $clash_url -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$subscribe_url#$subtype" >>/usr/share/clashbackup/confit_list.conf

echo "${config_name}.yaml#$clash_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
fi
fi

if [ "$subtype" = "ssr2clash" ];then
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" "https://ssrsub2clashr.herokuapp.com/ssrsub2clash?sub=$ssr_url" -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$ssr_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
CONFIG_YAMLL="/tmp/conf"
da_password=$(uci get clash.config.dash_pass 2>/dev/null)
redir_port=$(uci get clash.config.redir_port 2>/dev/null)
http_port=$(uci get clash.config.http_port 2>/dev/null)
socks_port=$(uci get clash.config.socks_port 2>/dev/null)
dash_port=$(uci get clash.config.dash_port 2>/dev/null)
bind_addr=$(uci get clash.config.bind_addr 2>/dev/null)
allow_lan=$(uci get clash.config.allow_lan 2>/dev/null)
log_level=$(uci get clash.config.level 2>/dev/null)
p_mode=$(uci get clash.config.p_mode 2>/dev/null)
sed -i "/^Proxy:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null

cat /usr/share/clash/dns.yaml $CONFIG_YAML > $CONFIG_YAMLL 2>/dev/null
mv $CONFIG_YAMLL $CONFIG_YAML 2>/dev/null

sed -i "1i\#****CLASH-CONFIG-START****#" $CONFIG_YAML 2>/dev/null
sed -i "2i\port: ${http_port}" $CONFIG_YAML 2>/dev/null
sed -i "/port: ${http_port}/a\socks-port: ${socks_port}" $CONFIG_YAML 2>/dev/null
sed -i "/socks-port: ${socks_port}/a\redir-port: ${redir_port}" $CONFIG_YAML 2>/dev/null
sed -i "/redir-port: ${redir_port}/a\allow-lan: ${allow_lan}" $CONFIG_YAML 2>/dev/null
if [ $allow_lan == "true" ]; then
sed -i "/allow-lan: ${allow_lan}/a\bind-address: \"${bind_addr}\"" $CONFIG_YAML 2>/dev/null
sed -i "/bind-address: \"${bind_addr}\"/a\mode: ${p_mode}" $CONFIG_YAML 2>/dev/null
sed -i "/mode: ${p_mode}/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null

else
sed -i "/allow-lan: ${allow_lan}/a\mode: Rule" $CONFIG_YAML 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null
fi
sleep 1

fi
fi

if [ "$subtype" = "v2clash" ];then
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" "https://tgbot.lbyczf.com/v2rayn2clash?url=$v2_url" -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$v2_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
fi
fi

if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration Completed" >$REAL_LOG
sleep 2
Expand All @@ -59,8 +115,5 @@ else
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi


fi

fi
13 changes: 1 addition & 12 deletions root/usr/share/clash/dashboard/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<title>Clash</title>
<link href="main.ad0717ae3407e246a9ab.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.ad0717ae3407e246a9ab.min.js"></script><script type="text/javascript" src="js/bundle.ad0717ae3407e246a9ab.min.js"></script></body>
</html>
<!doctype html><html lang="en" dir="ltr"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png"/><title>Clash Dashboard</title><link href="main.693efc9234a08d249710.css" rel="stylesheet"></head><body><div id="root"></div><script src="js/1.bundle.693efc9234a08d249710.min.js"></script><script src="js/bundle.693efc9234a08d249710.min.js"></script></body></html>

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Loading

0 comments on commit cde2979

Please sign in to comment.