mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-19 14:08:55 +03:00
fix: Support comments in user domain/subnet parsing
This commit is contained in:
@@ -299,33 +299,11 @@ parse_domain_or_subnet_string_to_commas_string() {
|
|||||||
local string="$1"
|
local string="$1"
|
||||||
local type="$2"
|
local type="$2"
|
||||||
|
|
||||||
local result
|
tmpfile=$(mktemp)
|
||||||
for item in $string; do
|
printf "%s\n" "$string" | sed 's/\/\/.*//' | tr ', ' '\n' | grep -v '^$' > "$tmpfile"
|
||||||
case "$type" in
|
|
||||||
domains)
|
|
||||||
if ! is_domain_suffix "$item"; then
|
|
||||||
log "'$item' is not a valid domain" "debug"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
subnets)
|
|
||||||
if ! is_ipv4_ip_or_ipv4_cidr "$item"; then
|
|
||||||
log "'$item' is not IPv4 or IPv4 CIDR" "debug"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log "Unknown type: $type" "error"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -z "$result" ]; then
|
result="$(parse_domain_or_subnet_file_to_comma_string "$tmpfile" "$type")"
|
||||||
result="$item"
|
rm -f "$tmpfile"
|
||||||
else
|
|
||||||
result="$result,$item"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "$result"
|
echo "$result"
|
||||||
}
|
}
|
||||||
@@ -345,6 +323,8 @@ parse_domain_or_subnet_file_to_comma_string() {
|
|||||||
|
|
||||||
local result
|
local result
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
|
log "!!! $line"
|
||||||
[ -z "$line" ] && continue
|
[ -z "$line" ] && continue
|
||||||
|
|
||||||
case "$type" in
|
case "$type" in
|
||||||
|
|||||||
Reference in New Issue
Block a user