Skip to content

Commit 77d1a5f

Browse files
committed
chore: refine
1 parent d602693 commit 77d1a5f

2 files changed

Lines changed: 20 additions & 26 deletions

File tree

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ config_cus_up()
163163
end" 2>/dev/null >> $LOG_FILE
164164
fi
165165
fi
166-
if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
167-
restart=1
168-
fi
169166
}
170167

171168
config_su_check()
@@ -176,7 +173,6 @@ config_su_check()
176173
if [ "$only_download" -eq 0 ]; then
177174
config_cus_up
178175
fi
179-
180176
cmp -s "$CONFIG_FILE" "$CFG_FILE"
181177
if [ "$?" -ne 0 ]; then
182178
LOG_OUT "Config File【$name】Are Updates, Start Replacing..."
@@ -185,6 +181,7 @@ config_su_check()
185181
else
186182
LOG_OUT "Config File【$name】No Change, Do Nothing!"
187183
rm -rf "$CFG_FILE"
184+
return
188185
fi
189186
else
190187
LOG_OUT "Config File【$name】Download Successful, Start To Create..."
@@ -194,15 +191,15 @@ config_su_check()
194191
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
195192
LOG_OUT "Config File【$name】Update Successful!"
196193
fi
197-
SLOG_CLEAN
194+
if [ "$CONFIG_FILE" == "$CONFIG_PATH" ]; then
195+
restart=1
196+
fi
198197
}
199198

200199
config_error()
201200
{
202201
LOG_OUT "Error:【$name】Update Error, Please Try Again Later..."
203202
rm -rf "$CFG_FILE" 2>/dev/null
204-
SLOG_CLEAN
205-
return 1
206203
}
207204

208205
change_dns()
@@ -273,24 +270,24 @@ server_key_match()
273270
local key_match key_word
274271

275272
if [ -n "$(echo "$1" |grep "^ \{0,\}$")" ] || [ -n "$(echo "$1" |grep "^\t\{0,\}$")" ]; then
276-
return
273+
return
277274
fi
278275

279276
if [ -n "$(echo "$1" |grep "&")" ]; then
280277
key_word=$(echo "$1" |sed 's/&/ /g')
281-
for k in $key_word
282-
do
283-
if [ -z "$k" ]; then
284-
continue
285-
fi
286-
k="(?=.*$k)"
287-
key_match="$key_match$k"
288-
done
289-
key_match="^($key_match).*"
278+
for k in $key_word
279+
do
280+
if [ -z "$k" ]; then
281+
continue
282+
fi
283+
k="(?=.*$k)"
284+
key_match="$key_match$k"
285+
done
286+
key_match="^($key_match).*"
290287
else
291-
if [ -n "$1" ]; then
292-
key_match="($1)"
293-
fi
288+
if [ -n "$1" ]; then
289+
key_match="($1)"
290+
fi
294291
fi
295292

296293
if [ "$2" = "keyword" ]; then
@@ -423,7 +420,6 @@ sub_info_get()
423420
if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -s "$CFG_FILE" ]; then
424421
#prevent ruby unexpected error
425422
sed -i -E 's/protocol-param: ([^,'"'"'"''}( *#)\n\r]+)/protocol-param: "\1"/g' "$CFG_FILE" 2>/dev/null
426-
sed -i '/^ \{0,\}enhanced-mode:/d' "$CFG_FILE" >/dev/null 2>&1
427423
config_test
428424
if [ $? -ne 0 ]; then
429425
LOG_OUT "Error: Config File Tested Faild, Please Check The Log Infos!"
@@ -461,8 +457,6 @@ sub_info_get()
461457
#分别获取订阅信息进行处理
462458
config_load "openclash"
463459
config_foreach sub_info_get "config_subscribe" "$1"
464-
uci -q delete openclash.config.config_update_path
465-
uci commit openclash
466-
460+
SLOG_CLEAN
467461
dec_job_counter_and_restart "$restart"
468-
del_lock
462+
del_lock

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ begin
563563
begin
564564
if enable_custom_dns
565565
if (defaultdns_config = safe_load_yaml('/tmp/yaml_config.defaultdns.yaml')) && defaultdns_config['default-nameserver']
566-
(Value['dns']['default-nameserver'] ||= []).concat(defaultdns_config['default-nameserver']).uniq!
566+
Value['dns']['default-nameserver'] = defaultdns_config['default-nameserver'].uniq
567567
end
568568
end
569569
if add_default_from_dns

0 commit comments

Comments
 (0)