support set log level
This commit is contained in:
23
src/core.sh
23
src/core.sh
@@ -167,7 +167,7 @@ show_list() {
|
||||
is_test() {
|
||||
case $1 in
|
||||
number)
|
||||
echo $2 | egrep '^[1-9][0-9]?+$'
|
||||
echo $2 | grep -E '^[1-9][0-9]?+$'
|
||||
;;
|
||||
port)
|
||||
if [[ $(is_test number $2) ]]; then
|
||||
@@ -178,13 +178,13 @@ is_test() {
|
||||
[[ $(is_port_used $2) && ! $is_cant_test_port ]] && echo ok
|
||||
;;
|
||||
domain)
|
||||
echo $2 | egrep -i '^\w(\w|\-|\.)?+\.\w+$'
|
||||
echo $2 | grep -E -i '^\w(\w|\-|\.)?+\.\w+$'
|
||||
;;
|
||||
path)
|
||||
echo $2 | egrep -i '^\/\w(\w|\-|\/)?+\w$'
|
||||
echo $2 | grep -E -i '^\/\w(\w|\-|\/)?+\w$'
|
||||
;;
|
||||
uuid)
|
||||
echo $2 | egrep -i '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
|
||||
echo $2 | grep -E -i '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -911,7 +911,7 @@ add() {
|
||||
;;
|
||||
*)
|
||||
for v in ${protocol_list[@]}; do
|
||||
[[ $(egrep -i "^$is_lower$" <<<$v) ]] && is_new_protocol=$v && break
|
||||
[[ $(grep -E -i "^$is_lower$" <<<$v) ]] && is_new_protocol=$v && break
|
||||
done
|
||||
|
||||
[[ ! $is_new_protocol ]] && err "无法识别 ($1), 请使用: $is_core add [protocol] [args... | auto]"
|
||||
@@ -1061,7 +1061,7 @@ add() {
|
||||
ask set_header_type
|
||||
}
|
||||
for v in ${is_tmp_list[@]}; do
|
||||
[[ $(egrep -i "^${is_use_header_type}${is_use_method}$" <<<$v) ]] && is_tmp_use_type=$v && break
|
||||
[[ $(grep -E -i "^${is_use_header_type}${is_use_method}$" <<<$v) ]] && is_tmp_use_type=$v && break
|
||||
done
|
||||
[[ ! ${is_tmp_use_type} ]] && {
|
||||
warn "(${is_use_header_type}${is_use_method}) 不是一个可用的${is_tmp_use_name}."
|
||||
@@ -1198,8 +1198,8 @@ get() {
|
||||
file)
|
||||
is_file_str=$2
|
||||
[[ ! $is_file_str ]] && is_file_str='.json$'
|
||||
# is_all_json=("$(ls $is_conf_dir | egrep $is_file_str)")
|
||||
readarray -t is_all_json <<<"$(ls $is_conf_dir | egrep -i "$is_file_str" | sed '/dynamic-port-.*-link/d' | head -233)" # limit max 233 lines for show.
|
||||
# is_all_json=("$(ls $is_conf_dir | grep -E $is_file_str)")
|
||||
readarray -t is_all_json <<<"$(ls $is_conf_dir | grep -E -i "$is_file_str" | sed '/dynamic-port-.*-link/d' | head -233)" # limit max 233 lines for show.
|
||||
[[ ! $is_all_json ]] && err "无法找到相关的配置文件: $2"
|
||||
[[ ${#is_all_json[@]} -eq 1 ]] && is_config_file=$is_all_json && is_auto_get_config=1
|
||||
[[ ! $is_config_file ]] && {
|
||||
@@ -1244,7 +1244,7 @@ get() {
|
||||
[[ $? != 0 ]] && err "无法读取动态端口文件: $is_dynamic_port"
|
||||
fi
|
||||
if [[ $is_caddy && $host && -f $is_caddy_conf/$host.conf ]]; then
|
||||
is_tmp_https_port=$(egrep -o "$host:[1-9][0-9]?+" $is_caddy_conf/$host.conf | sed s/.*://)
|
||||
is_tmp_https_port=$(grep -E -o "$host:[1-9][0-9]?+" $is_caddy_conf/$host.conf | sed s/.*://)
|
||||
fi
|
||||
[[ $is_tmp_https_port ]] && is_https_port=$is_tmp_https_port
|
||||
[[ $is_client && $host ]] && port=$is_https_port
|
||||
@@ -1849,8 +1849,9 @@ main() {
|
||||
get_ip
|
||||
msg $ip
|
||||
;;
|
||||
log | logerr)
|
||||
get $@
|
||||
log | logerr | errlog)
|
||||
load log.sh
|
||||
log_set $@
|
||||
;;
|
||||
url | qr)
|
||||
url_qr $@
|
||||
|
Reference in New Issue
Block a user