fix: 修改ip校验规则
This commit is contained in:
+7
-3
@@ -196,15 +196,19 @@ input_lan_ip() {
|
||||
valid_ipv4() {
|
||||
local ip="$1"
|
||||
|
||||
# 第一层:检查格式,必须是4段数字
|
||||
echo "$ip" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' || return 1
|
||||
|
||||
# 第二层:检查每段范围
|
||||
echo "$ip" | awk -F. '
|
||||
NF==4 &&
|
||||
$1>=0 && $1<=255 &&
|
||||
$2>=0 && $2<=255 &&
|
||||
$3>=0 && $3<=255 &&
|
||||
$4>=0 && $4<=255
|
||||
'
|
||||
}
|
||||
' | grep -q . || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
project_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$project_dir"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user