Skip to content

Commit d5b712c

Browse files
committed
chore: refine
1 parent c25374a commit d5b712c

File tree

7 files changed

+55
-21
lines changed

7 files changed

+55
-21
lines changed

luci-app-openclash/luasrc/model/cbi/openclash/rule-providers-settings.lua

+3
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ uci:foreach("openclash", "groups",
194194

195195
o:value("DIRECT")
196196
o:value("REJECT")
197+
o:value("REJECT-DROP")
198+
o:value("PASS")
199+
o:value("GLOBAL")
197200
o.rmempty = true
198201

199202
o = s:option(Value, "interval", translate("Rule Providers Interval(s)"))

luci-app-openclash/luasrc/openclash.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ function lanip()
272272
local lan_int_name = uci:get("openclash", "config", "lan_interface_name") or "0"
273273
local lan_ip
274274
if lan_int_name == "0" then
275-
lan_ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'")
275+
lan_ip = SYS.exec("uci -q get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'")
276276
else
277-
lan_ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n'", lan_int_name))
277+
lan_ip = SYS.exec(string.format("ip address show %s 2>/dev/null | grep -w 'inet' 2>/dev/null | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n'", lan_int_name))
278278
end
279279
if not lan_ip or lan_ip == "" then
280280
lan_ip = SYS.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n'")

luci-app-openclash/luasrc/view/openclash/status.htm

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@
507507
else if (status.mode == "redir-host" || status.mode == "redir-host-tun" || status.mode == "redir-host-mix")
508508
{
509509
mode.innerHTML = status.clash && status.watchdog ? "<b style=color:green><%:Redir-Host%></b>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" : '<b style=color:red><%:Not Running%></b>&nbsp;&nbsp;&nbsp;';
510-
radio_run_normal.innerHTML = "<%:Compatible%>"
510+
radio_run_normal.innerHTML = "<%:Compat%>"
511511
};
512512
for (i=0; i<radio_ru.length; i++) {
513513
if (radio_ru[i].value == (status["mode"].split("-")[2] == undefined ? "" : ("-" + status["mode"].split("-")[2])) && ! radio_ru[i].checked) {

luci-app-openclash/root/etc/init.d/openclash

+7-7
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,13 @@ check_core_status()
785785
fi
786786
else
787787
reg4='^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$'
788-
while ( [ -n "$(pidof clash)" ] && [ "$CORE_HTTP_CODE" != "200" ] && [ "$TUN_WAIT" -le 120 ] && [[ "$lan_ip" =~ $reg4 ]] )
788+
while ( [ -n "$(pidof clash)" ] && [ "$CORE_HTTP_CODE" != "200" ] && [ "$TUN_WAIT" -le 120 ] && [ -n "$(echo ${lan_ip} | grep -Eo ${reg4})" ] )
789789
do
790790
CORE_HTTP_CODE=$(curl -m 5 -o /dev/null -s -w '%{http_code}' -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XGET http://${lan_ip}:${cn_port}/group)
791791
let TUN_WAIT++
792792
sleep 1
793793
done >/dev/null 2>&1
794-
if ! [[ "$lan_ip" =~ $reg4 ]]; then
794+
if [ -z "$(echo ${lan_ip} | grep -Eo ${reg4})" ]; then
795795
LOG_OUT "Error: LAN IP Address Get Error, Please Check The LAN Interface Setting or Choose the Correct Interface in the Setting!"
796796
sleep 10
797797
fi
@@ -957,7 +957,7 @@ firewall_rule_exclude()
957957

958958
ipv6_suffix_to_nft_format() {
959959
local ipv6_with_prefix="$1"
960-
if [[ "$ipv6_with_prefix" =~ / ]]; then
960+
if [[ "$ipv6_with_prefix" =~ / ]] || [ -n "$(echo ${ipv6_with_prefix} | grep '/')" ]; then
961961
local suffix="${ipv6_with_prefix%%/*}"
962962
local prefix="${ipv6_with_prefix##*/}"
963963
echo "& $prefix == $suffix"
@@ -1043,7 +1043,7 @@ firewall_rule_exclude()
10431043
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} tcp sport "$i" counter return >/dev/null 2>&1
10441044
nft insert rule inet fw4 openclash_v6 position 0 meta nfproto {ipv6} tcp sport "$i" counter return >/dev/null 2>&1
10451045
else
1046-
if [[ "$dest_ip" =~ , ]]; then
1046+
if [[ "$dest_ip" =~ , ]] || [ -n "$(echo ${dest_ip} | grep ',')" ]; then
10471047
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } tcp sport "$i" counter return >/dev/null 2>&1
10481048
nft insert rule inet fw4 openclash_v6 position 0 ip6 saddr { "$dest_ip" } tcp sport "$i" counter return >/dev/null 2>&1
10491049
else
@@ -1058,7 +1058,7 @@ firewall_rule_exclude()
10581058
if [ -z "$dest_ip" ]; then
10591059
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto {ipv6} udp sport "$i" counter return >/dev/null 2>&1
10601060
else
1061-
if [[ "$dest_ip" =~ , ]]; then
1061+
if [[ "$dest_ip" =~ , ]] || [ -n "$(echo ${dest_ip} | grep ',')" ]; then
10621062
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr { "$dest_ip" } udp sport "$i" counter return >/dev/null 2>&1
10631063
else
10641064
nft insert rule inet fw4 openclash_mangle_v6 position 0 ip6 saddr "$nft_ipv6" udp sport "$i" counter return >/dev/null 2>&1
@@ -2920,9 +2920,9 @@ get_config()
29202920

29212921
lan_interface_name=$(uci -q get openclash.config.lan_interface_name || echo 0)
29222922
if [ "$lan_interface_name" = "0" ]; then
2923-
lan_ip=$(uci -q get network.lan.ipaddr | awk -F '/' '{print $1}' 2>/dev/null | tr -d '\n' || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n')
2923+
lan_ip=$(uci -q get network.lan.ipaddr 2>/dev/null | awk -F '/' '{print $1}' 2>/dev/null | tr -d '\n' || ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w "inet" 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n' || ip addr show 2>/dev/null | grep -w 'inet' | grep 'global' | grep 'brd' | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -n 1 | tr -d '\n')
29242924
else
2925-
lan_ip=$(ip address show $lan_interface_name | grep -w "inet" 2>/dev/null | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n')
2925+
lan_ip=$(ip address show $lan_interface_name 2>/dev/null | grep -w "inet" 2>/dev/null | grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | head -1 | tr -d '\n')
29262926
fi
29272927

29282928
wan_ip4s=$(/usr/share/openclash/openclash_get_network.lua "wanip" 2>/dev/null)

luci-app-openclash/root/etc/openclash/custom/openclash_custom_fake_filter.list

+32-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@
77
*.test
88
*.local
99
*.home.arpa
10+
*.direct
11+
cable.auth.com
12+
network-test.debian.org
13+
detectportal.firefox.com
14+
resolver1.opendns.com
15+
global.turn.twilio.com
16+
global.stun.twilio.com
17+
app.yinxiang.com
18+
injections.adguard.org
19+
localhost.*.weixin.qq.com
20+
*.blzstatic.cn
21+
*.cmpassport.com
22+
id6.me
23+
open.e.189.cn
24+
opencloud.wostore.cn
25+
id.mail.wo.cn
26+
mdn.open.wo.cn
27+
hmrz.wo.cn
28+
nishub1.10010.com
29+
enrichgw.10010.com
30+
*.wosms.cn
31+
*.jegotrip.com.cn
32+
*.icitymobile.mobi
33+
*.pingan.com.cn
34+
*.cmbchina.com
35+
*.10099.com.cn
36+
*.microdone.cn
37+
PDC._msDCS.*.*
38+
DC._msDCS.*.*
39+
GC._msDCS.*.*
1040
#放行NTP服务
1141
time.*.com
1242
time.*.gov
@@ -83,6 +113,7 @@ xbox.*.*.microsoft.com
83113
xbox.*.microsoft.com
84114
xnotify.xboxlive.com
85115
#Wotgame
116+
+.battle.net
86117
+.battlenet.com.cn
87118
+.wotgame.cn
88119
+.wggames.cn
@@ -144,6 +175,6 @@ ps.res.netease.com
144175
#Wifi Calling
145176
+.pub.3gppnetwork.org
146177
#GEOSITE(Meta core)
147-
geosite:category-games
178+
#geosite:category-games
148179
#geosite:apple-cn
149180
#geosite:google-cn

luci-app-openclash/root/usr/share/openclash/yml_change.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ yml_dns_get()
178178
return
179179
fi
180180

181-
if [[ "$ip" =~ "$regex" ]]; then
181+
if [[ "$ip" =~ "$regex" ]] || [ -n "$(echo ${ip} |grep -Eo ${regex})" ]; then
182182
ip="[${ip}]"
183183
fi
184184

luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ set_groups()
5252
return
5353
fi
5454

55-
if [ "$1" = "all" ] || [[ "$3" =~ ${1} ]]; then
55+
if [ "$1" = "all" ] || [[ "$3" =~ ${1} ]] || [ -n "$(echo ${3} |grep -Eo ${1})" ]; then
5656
set_group=1
5757
add_for_this=1
5858
echo " - \"${2}\"" >>$GROUP_FILE
@@ -76,7 +76,7 @@ set_relay_groups()
7676
fi
7777

7878
if [ -n "$server_relay_num" ]; then
79-
if [[ "$3" =~ ${server_group_name} ]] || [ "$server_group_name" = "all" ]; then
79+
if [[ "$3" =~ ${server_group_name} ]] || [ -n "$(echo ${3} |grep -Eo ${server_group_name})" ] || [ "$server_group_name" = "all" ]; then
8080
set_group=1
8181
add_for_this=1
8282
echo "$server_relay_num # - \"${2}\"" >>/tmp/relay_server
@@ -140,7 +140,7 @@ add_other_group()
140140
return
141141
fi
142142

143-
if [ "$2" = "all" ] || [[ "$name" =~ ${2} ]]; then
143+
if [ "$2" = "all" ] || [[ "$name" =~ ${2} ]] || [ -n "$(echo ${name} |grep -Eo ${2})" ]; then
144144
set_group=1
145145
echo " - ${name}" >>$GROUP_FILE
146146
fi
@@ -153,31 +153,31 @@ set_other_groups()
153153
return
154154
fi
155155

156-
if [[ "$1" =~ "DIRECT" ]]; then
156+
if [[ "$1" =~ "DIRECT" ]] || [ -n "$(echo ${1} |grep 'DIRECT')" ]; then
157157
set_group=1
158158
echo " - DIRECT" >>$GROUP_FILE
159159
return
160160
fi
161161

162-
if [[ "$1" =~ "REJECT" ]]; then
162+
if [[ "$1" =~ "REJECT" ]] || [ -n "$(echo ${1} |grep 'REJECT')" ]; then
163163
set_group=1
164164
echo " - REJECT" >>$GROUP_FILE
165165
return
166166
fi
167167

168-
if [[ "$1" =~ "REJECT-DROP" ]]; then
168+
if [[ "$1" =~ "REJECT-DROP" ]] || [ -n "$(echo ${1} |grep 'REJECT-DROP')" ]; then
169169
set_group=1
170170
echo " - REJECT-DROP" >>$GROUP_FILE
171171
return
172172
fi
173173

174-
if [[ "$1" =~ "PASS" ]]; then
174+
if [[ "$1" =~ "PASS" ]] || [ -n "$(echo ${1} |grep 'PASS')" ]; then
175175
set_group=1
176176
echo " - PASS" >>$GROUP_FILE
177177
return
178178
fi
179179

180-
if [[ "$1" =~ "GLOBAL" ]]; then
180+
if [[ "$1" =~ "GLOBAL" ]] || [ -n "$(echo ${1} |grep 'GLOBAL')" ]; then
181181
set_group=1
182182
echo " - GLOBAL" >>$GROUP_FILE
183183
return
@@ -223,7 +223,7 @@ set_provider_groups()
223223
return
224224
fi
225225

226-
if [[ "$3" =~ ${1} ]] || [ "$1" = "all" ]; then
226+
if [[ "$3" =~ ${1} ]] || [ -n "$(echo ${3} |grep -Eo ${1})" ] || [ "$1" = "all" ]; then
227227
set_proxy_provider=1
228228
add_for_this=1
229229
echo " - ${2}" >>$GROUP_FILE

0 commit comments

Comments
 (0)