Skip to content

Commit

Permalink
1.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
frainzy1477 committed Feb 7, 2020
1 parent 29f6977 commit fa7e7a2
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 36 deletions.
5 changes: 3 additions & 2 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.5.2
PKG_VERSION:=1.5.3
PKG_MAINTAINER:=frainzy1477


Expand All @@ -12,7 +12,7 @@ define Package/luci-app-clash
CATEGORY:=LuCI
SUBMENU:=2. Clash
TITLE:=LuCI app for clash
DEPENDS:=+luci +luci-base +wget +iptables +coreutils-base64 +coreutils +coreutils-nohup +bash +ipset +libustream-openssl +libopenssl +openssl-util
DEPENDS:=+luci +luci-base +wget +iptables +coreutils-base64 +coreutils +coreutils-nohup +bash +ipset +libustream-openssl +libopenssl +openssl-util +curl +jsonfilter +ca-certificates
PKGARCH:=all
MAINTAINER:=frainzy1477
endef
Expand Down Expand Up @@ -84,6 +84,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
mv /usr/share/clashbackup/config.bak2 /usr/share/clash/config/upload/config.yaml 2>/dev/null
mv /usr/share/clashbackup/config.bak3 /usr/share/clash/config/custom/config.yaml 2>/dev/null
/etc/init.d/clash disable 2>/dev/null
uci set clash.config.p_mode="Rule" && uci commit clash 2>/dev/null
fi

exit 0
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,35 @@
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.5.2">
<img src="https://img.shields.io/badge/luci%20for%20clash-v1.5.2-blue.svg">
<a target="_blank" href="https://github.com/frainzy1477/luci-app-clash/releases/tag/v1.5.3">
<img src="https://img.shields.io/badge/luci%20for%20clash-v1.5.3-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"/>
</a>-->

</p>


## Install
- Upload ipk file to tmp folder

- cd /tmp

- opkg install luci-app-clash_1.5.2_all.ipk
- opkg install luci-app-clash_1.5.2_all.ipk --force-depends
- opkg update
- opkg install luci-app-clash_1.5.3_all.ipk
- opkg install luci-app-clash_1.5.3_all.ipk --force-depends

## Features

- Support Manually config upload (config.yaml / config.yml)
- Support Manually config upload
- GeoIP Database Update
- Iptables udp redirect
- IP Query / Website Access Check
- Proxy Lan IP(Client IP) that go through Proxy
- Bypass Lan IP(Client IP) that can't go through Proxy
- DNS Forwarding
- Ping Custom proxy servers
- Create v2ray & ssr clash config from subscription url
- Create Custom Clash Config
- Tun Support
- Support Proxy Provider [Thanks to @vernesong ](https://github.com/vernesong/OpenClash)
- Support Proxy Provider & Restore Config [Thanks to @vernesong ](https://github.com/vernesong/OpenClash)

## Dependency

Expand All @@ -55,6 +52,9 @@
- libustream-openssl
- libopenssl
- openssl-util
- curl
- jsonfilter
- ca-certificates

## Clash on Other Platforms

Expand Down
4 changes: 4 additions & 0 deletions luasrc/model/cbi/clash/create.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ o:value("1", translate("enabled"))
o:value("0", translate("disabled"))
o.description = translate("Enable to read policy group")

o = s:option(ListValue, "loadprovider", translate("Load Provider"))
o:value("1", translate("enabled"))
o:value("0", translate("disabled"))
o.description = translate("Enable to read Proxy Provider")

local t = {
{Load_Config, Creat_Config, Apply, Delete_Severs, Delete_Groups}
Expand Down
2 changes: 1 addition & 1 deletion luasrc/model/cbi/clash/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
11 changes: 10 additions & 1 deletion po/zh-cn/clash.po
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ msgid "Edit Proxy Provider"
msgstr "编辑代理集配置"

msgid "Provider Type"
msgstr "代理集类型
msgstr "代理集类型"

msgid "Provider Type"
msgstr "代理集的类型"
Expand Down Expand Up @@ -809,6 +809,9 @@ msgstr "强制使用同名"
msgid "Enable to overwrite config file"
msgstr "启用覆盖配置文件"

msgid "Give a name for your config"
msgstr "为配置命名"

msgid "Config Type"
msgstr "Clash配置类型"

Expand Down Expand Up @@ -955,3 +958,9 @@ 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)"

msgid "Load Provider"
msgstr "读取代理集"

msgid "Enable to read Proxy Provider"
msgstr "启用读取代理集"
15 changes: 10 additions & 5 deletions root/etc/init.d/clash
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ rules(){
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
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}"
Expand Down Expand Up @@ -263,7 +263,7 @@ rules(){
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
if [ ! -z "${wan}" ]; then
ipset add localnetwork "${wan}"
fi
if [ "${core}" -eq 3 ];then
Expand Down Expand Up @@ -421,7 +421,7 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"

game_rules >/dev/null 2>&1

if [ "${core}" -eq 1 ];then
if [ "${core}" -eq 1 ];then
nohup $CLASH -d "$CLASH_CONFIG" > /usr/share/clash/clash.txt 2>&1 &

if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
Expand All @@ -447,15 +447,18 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "Clash 计划任务,启动进程守护程序..." >$REAL_LOG
fi
elif [ "${core}" -eq 2 ];then
nohup $CLASHR -d "$CLASH_CONFIG" > /usr/share/clash/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
echo "Clashr 计划任务,启动进程守护程序..." >$REAL_LOG
fi

fi


sh /usr/share/clash/restore.sh >/dev/null 2>&1

sleep 1

if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
Expand Down Expand Up @@ -636,6 +639,8 @@ stop(){

remove_mark >/dev/null 2>&1

sh /usr/share/clash/backup.sh >/dev/null 2>&1

kill -9 $(ps | grep clash-watchdog.sh | grep -v grep | awk '{print $1}') >/dev/null 2>&1

if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
Expand Down
17 changes: 17 additions & 0 deletions root/usr/share/clash/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

CURL_GROUP_CACHE="/usr/share/clashbackup/clash_gorup.json"
CURL_NOW_CACHE="/usr/share/clashbackup/clash_now.json"
CURL_CACHE="/usr/share/clashbackup/clash_curl.json"
HISTORY_PATH="/usr/share/clashbackup/history"
SECRET=$(uci get clash.config.dash_pass 2>/dev/null)
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
PORT=$(uci get clash.config.dash_port 2>/dev/null)

curl -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies > "$CURL_CACHE" 2>/dev/null
if [ "$(sed -n '$p' "$CURL_CACHE")" -eq "200" ]; then
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["name"]' > "$CURL_GROUP_CACHE" 2>/dev/null
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["now"]' > "$CURL_NOW_CACHE" 2>/dev/null
awk 'NR==FNR{a[i]=$0;i++}NR>FNR{print a[j]"#*#"$0;j++}' "$CURL_GROUP_CACHE" "$CURL_NOW_CACHE" > "$HISTORY_PATH" 2>/dev/null
fi
rm -rf /usr/share/clashbackup/clash_*.json 2>/dev/null
4 changes: 2 additions & 2 deletions root/usr/share/clash/clash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else
fi
sleep 1

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

Expand All @@ -63,4 +63,4 @@ else

fi

fi
fi
4 changes: 2 additions & 2 deletions root/usr/share/clash/clash_game_rule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
echo "开始下载【$RULE_FILE_NAME】规则..." >$REAL_LOG
fi

wget -c4 --no-check-certificate --timeout=30 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -O 2>&1 >1 "$TMP_RULE_DIR"
wget --no-check-certificate -c4 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -O 2>&1 >1 "$TMP_RULE_DIR"

if [ "$?" -eq "0" ] && [ "$(ls -l $TMP_RULE_DIR |awk '{print $5}')" -ne 0 ]; then

Expand Down Expand Up @@ -75,4 +75,4 @@
rm -rf $TMP_RULE_DIR >/dev/null 2>&1
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
fi
21 changes: 12 additions & 9 deletions root/usr/share/clash/dns.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@

experimental:
ignore-resolve-fail: true

#authentication:
# - "user1:pass1"
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'

#hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'

dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
#fake-ip-filter:
# - '*.lan'
# - localhost.ptlogin2.qq.com
#fake-ip-filter:
# - '*.lan'
# - localhost.ptlogin2.qq.com
nameserver:
- 114.114.114.114
- udp://114.114.114.114
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- udp://8.8.8.8:53
- udp://8.8.4.4:53
- tcp://1.1.1.1
fallback:
fallback:
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- tcp://1.1.1.1
- tcp://8.8.8.8
fallback-filter:
fallback-filter:
geoip: true
ipcidr:
- 240.0.0.0/4
11 changes: 9 additions & 2 deletions root/usr/share/clash/load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
lang=$(uci get luci.main.lang 2>/dev/null)
loadgroups=$(uci get clash.config.loadgroups 2>/dev/null)
loadservers=$(uci get clash.config.loadservers 2>/dev/null)

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

run_load(){

Expand Down Expand Up @@ -250,7 +250,7 @@ fi

#awk '/^ {0,}Proxy:/,/^ {0,}Proxy Group:/{print}' $load 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_proxy.yaml 2>&1

if [ $loadservers -eq 1 ];then



proxy_len=$(sed -n '/^ \{0,\}Proxy:/=' $load 2>/dev/null)
Expand Down Expand Up @@ -310,6 +310,8 @@ cfg_gett()
{
echo "$(grep "$1" $single_server 2>/dev/null |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null)"
}

if [ $loadservers -eq 1 ];then
#######READ SERVERS START
if [ -f /tmp/yaml_proxy.yaml ];then
while [[ "$( grep -c "config servers" $CFG_FILE )" -ne 0 ]]
Expand Down Expand Up @@ -497,7 +499,10 @@ elif [ $lang == "zh_cn" ];then
fi
fi
#######READ SERVERS END
fi


if [ "${loadprovider}" -eq 1 ];then
#######READ PROVIDER START

if [ -f /tmp/yaml_provider.yaml ];then
Expand Down Expand Up @@ -645,6 +650,8 @@ done
#######READ PROVIDER END
fi
fi


rm -rf /tmp/Proxy_Group /tmp/servers.yaml /tmp/yaml_proxy.yaml /tmp/group_*.yaml /tmp/yaml_group.yaml /tmp/match_servers.list /tmp/yaml_provider.yaml /tmp/provider.yaml /tmp/provider_gen.yaml /tmp/provider_che.yaml /tmp/match_provider.list 2>/dev/null

/usr/share/clash/proxy.sh >/dev/null 2>&1
Expand Down
2 changes: 1 addition & 1 deletion root/usr/share/clash/luci_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.2
1.5.3
1 change: 1 addition & 0 deletions root/usr/share/clash/proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,4 @@ fi
fi



19 changes: 19 additions & 0 deletions root/usr/share/clash/restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

if [ -f /usr/share/clashbackup/history ];then
HISTORY_PATH="/usr/share/clashbackup/history"
SECRET=$(uci get clash.config.dash_pass 2>/dev/null)
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
PORT=$(uci get clash.config.dash_port 2>/dev/null)

if [ ! -z "$(grep "#*#" "$HISTORY_PATH")" ]; then
cat $HISTORY_PATH |while read line
do
GORUP_NAME=$(echo $line |awk -F '#*#' '{print $1}')
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
curl -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GORUP_NAME" >/dev/null 2>&1
done
fi
fi


19 changes: 18 additions & 1 deletion root/usr/share/clash/tundns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@ tun:
device-url: dev://utun
dns-listen: 0.0.0.0:53

#authentication:
# - "user1:pass1"

#hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'

dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
nameserver:
- 114.114.114.114
- udp://114.114.114.114
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- udp://8.8.8.8:53
- udp://8.8.4.4:53
- tcp://1.1.1.1
fallback:
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- tcp://1.1.1.1
- tcp://8.8.8.8
fallback-filter:
geoip: true
ipcidr:
- 240.0.0.0/4



1 change: 1 addition & 0 deletions root/usr/share/clash/yum_change.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,4 @@ else
fi
#===========================================================================================================================


0 comments on commit fa7e7a2

Please sign in to comment.