luci-app-clash: update

This commit is contained in:
CN_SZTL 2019-09-07 16:46:11 +08:00
parent 358a2cb793
commit eec53489e4
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 1891 additions and 14 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=0.37.1
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_MAINTAINER:=frainzy1477
@ -63,6 +63,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/ipdb.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dns.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/rule.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/custom_rule.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash_version $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/check_version.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/check_core_version.sh $(1)/usr/share/clash/

View File

@ -1,7 +1,30 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
local fs = require "luci.clash"
local clash = "clash"
local SYS = require "luci.sys"
local uci = luci.model.uci.cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
s.anonymous = true
s.addremove=false
local rule = "/usr/share/clash/custom_rule.yaml"
sev = s:option(TextValue, "rule")
sev.description = translate("NB: Attention to Proxy Group and Rule when making changes to this section")
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(rule) or ""
end
sev.write = function(self, section, value)
NXFS.writefile(rule, value:gsub("\r\n", "\n"))
end
k = Map(clash)
--k.pageaction = false
@ -76,4 +99,7 @@ function o.cfgvalue(...)
end
return k
return k, m

View File

@ -338,4 +338,7 @@ msgid "Skip Cert Verify"
msgstr "忽略许可验证"
msgid "None"
msgstr "未配置"
msgstr "未配置"
msgid "NB: Attention to Proxy Group and Rule when making changes to this section"
msgstr "注意:更改时,请注意代理组和规则"

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,26 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
if pidof clash >/dev/null; then
/etc/init.d/clash stop 2>/dev/null
else
uci set clash.config.enable=1 2> /dev/null
uci commit clash 2> /dev/null
fi
enable_create=$(uci get clash.config.enable_servers 2>/dev/null)
if [ "$enable_create" == "1" ];then
status=$(ps|grep -c /usr/share/clash/proxy.sh)
[ "$status" -gt "3" ] && exit 0
CONFIG_YAML_RULE="/usr/share/clash/rule.yaml"
CONFIG_YAML_RULE="/usr/share/clash/custom_rule.yaml"
SERVER_FILE="/tmp/servers.yaml"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_BAK="/etc/clash/config.bak"
TEMP_FILE="/tmp/dns_temp.yaml"
SERVERS="/tmp/servers_temp.yaml"
Proxy_Group="/tmp/Proxy_Group"
Proxy_Group_url="/tmp/Proxy_url"
RULE_PROXY="/tmp/tempserv.yaml"
servers_set()
{
local section="$1"
@ -182,13 +190,28 @@ sed -i "1i\Proxy:" $SERVER_FILE
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
sed -i "1i " $Proxy_Group
sed -i "2i\Proxy Group:" $Proxy_Group
sed -i "3i\ - name: Proxy" $Proxy_Group
sed -i "4i\ type: select" $Proxy_Group
sed -i "5i\ proxies:" $Proxy_Group
cat $Proxy_Group $CONFIG_YAML_RULE > $RULE_PROXY
cat >> "$Proxy_Group_url" <<-EOF
- name: Auto - UrlTest
type: url-test
proxies:
EOF
cat $Proxy_Group >> $Proxy_Group_url 2>/dev/null
cat >> "$Proxy_Group_url" <<-EOF
url: http://www.gstatic.com/generate_204
interval: "600"
- name: Proxy
type: select
proxies:
- Auto - UrlTest
- DIRECT
EOF
cat $Proxy_Group >> $Proxy_Group_url 2>/dev/null
sed -i "1i " $Proxy_Group_url
sed -i "2i\Proxy Group:" $Proxy_Group_url
cat $Proxy_Group_url $CONFIG_YAML_RULE > $RULE_PROXY
mode=$(uci get clash.config.mode 2>/dev/null)
da_password=$(uci get clash.config.dash_pass 2>/dev/null)
@ -243,7 +266,8 @@ rm -rf $CONFIG_YAML
fi
cat $SERVERS $RULE_PROXY > $CONFIG_YAML
rm -rf $SERVERS $RULE_PROXY $Proxy_Group $TEMP_FILE
rm -rf $SERVERS $RULE_PROXY $Proxy_Group $TEMP_FILE $Proxy_Group_url
fi
rm -rf $SERVER_FILE
fi
fi
/etc/init.d/clash restart 2>/dev/null