luci-app-openclash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-03-12 02:06:58 +08:00
parent 346b406b82
commit ca50a20d6c
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 64 additions and 7 deletions

View File

@ -42,7 +42,7 @@ local function is_web()
end
local function is_watchdog()
return luci.sys.exec("ps |grep openclash_watchdog.sh |grep -v grep 2>/dev/null |sed -n 1p")
return luci.sys.call("ps |grep openclash_watchdog.sh |grep -v grep >/dev/null") == 0
end
local function cn_port()

View File

@ -103,6 +103,11 @@ o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
---- exkey
o = s:option(DynamicList, "ex_keyword", font_red..bold_on..translate("Exclude Keyword Match")..bold_off..font_off)
o.description = font_red..bold_on..translate("(eg: hk or tw&bgp)")..bold_off..font_off
o.rmempty = true
local t = {
{Commit, Apply}
}

View File

@ -10,8 +10,8 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
else
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
fi
if [ "$?" -eq "0" ] && [ "$(ls -l $LAST_OPVER 2>/dev/null |awk '{print int($5)}')" -gt 0 ]; then
if [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null)" = "$(sed -n 1p $LAST_OPVER 2>/dev/null)" ]; then
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
if [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F '.' '{print $2$3}')" -ge "$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F '.' '{print $2$3}')" ]; then
sed -i "/^https:/i\CheckTime:${CKTIME}" "$LAST_OPVER" 2>/dev/null
sed -i '/^https:/,$d' $LAST_OPVER
else
@ -20,7 +20,7 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
else
rm -rf "$LAST_OPVER"
fi
elif [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null)" = "$(sed -n 1p $LAST_OPVER 2>/dev/null)" ]; then
elif [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null |awk -F '-' '{print $1}' |awk -F '.' '{print $2$3}')" -ge "$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F '.' '{print $2$3}')" ]; then
sed -i '/^CheckTime:/,$d' $LAST_OPVER
echo "CheckTime:$CKTIME" >>$LAST_OPVER
fi

View File

@ -277,6 +277,7 @@ server_key_get()
config_get "name" "$section" "name" ""
config_get "keyword" "$section" "keyword" ""
config_get "ex_keyword" "$section" "ex_keyword" ""
if [ -z "$name" ]; then
name="config"
@ -286,6 +287,11 @@ server_key_get()
config_keyword="$keyword"
key_section="$1"
fi
if [ ! -z "$ex_keyword" ] && [ "$name.yaml" == "$CONFIG_NAME" ]; then
config_ex_keyword="$ex_keyword"
key_section="$1"
fi
}
@ -323,6 +329,40 @@ server_key_match()
fi
}
server_key_exmatch()
{
if [ "$match" = "false" ] || [ ! -z "$(echo "$1" |grep "^ \{0,\}$")" ] || [ ! -z "$(echo "$1" |grep "^\t\{0,\}$")" ]; then
return
fi
if [ ! -z "$(echo "$1" |grep "&")" ]; then
key_word=$(echo "$1" |sed 's/&/ /g')
match=0
matchs=0
for k in $key_word
do
if [ -z "$k" ]; then
continue
fi
if [ ! -z "$(echo "$2" |grep -i "$k")" ]; then
match=$(( $match + 1 ))
fi
matchs=$(( $matchs + 1 ))
done
if [ "$match" = "$matchs" ]; then
match="false"
else
match="true"
fi
else
if [ ! -z "$(echo "$2" |grep -i "$1")" ]; then
match="false"
fi
fi
}
cfg_new_servers_groups_get()
{
if [ -z "$1" ]; then
@ -371,9 +411,18 @@ do
fi
#匹配关键字订阅节点
if [ "$servers_if_update" = "1" ]; then
if [ ! -z "$config_keyword" ]; then
match="false"
config_list_foreach "$key_section" "keyword" server_key_match "$server_name"
if [ ! -z "$config_keyword" ] || [ ! -z "$config_ex_keyword" ]; then
if [ ! -z "$config_keyword" ] && [ -z "$config_ex_keyword" ]; then
match="false"
config_list_foreach "$key_section" "keyword" server_key_match "$server_name"
elif [ -z "$config_keyword" ] && [ ! -z "$config_ex_keyword" ]; then
match="true"
config_list_foreach "$key_section" "ex_keyword" server_key_exmatch "$server_name"
elif [ ! -z "$config_keyword" ] && [ ! -z "$config_ex_keyword" ]; then
match="false"
config_list_foreach "$key_section" "keyword" server_key_match "$server_name"
config_list_foreach "$key_section" "ex_keyword" server_key_exmatch "$server_name"
fi
if [ "$match" = "false" ]; then
echo "跳过【$server_name】服务器节点..." >$START_LOG

View File

@ -705,6 +705,9 @@ msgstr "(空值无效)"
msgid "Keyword Match"
msgstr "筛选节点"
msgid "Exclude Keyword Match"
msgstr "排除节点"
msgid "(eg: hk or tw&bgp)"
msgstr "(格式示例:香港、台湾&bgp"