mirror of
https://github.com/tiennm99/old-free-domains.git
synced 2026-10-15 20:15:52 +00:00
test: use original code
This commit is contained in:
1 parent
6dfdf5b90c
commit
29ca6d7ecb
1 file changed
+26
-27
@@ -29,33 +29,32 @@ jobs:
|
||||
run: |
|
||||
cd domains
|
||||
for file in *.json; do
|
||||
if [[ -f $file && ! -d $file ]]; then
|
||||
while read -r line; do
|
||||
record_type=$(echo "$line" | jq -r 'keys[]')
|
||||
record_value=$(echo "$line" | jq -r '.[]')
|
||||
|
||||
if [[ "$record_type" =~ ^(A|AAAA)$ ]]; then
|
||||
IFS=$'\n' read -r -a record_values <<< "$record_value"
|
||||
for val in "${record_values[@]}"; do
|
||||
ping_result=$(ping -c 1 "$val")
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "PASS ${file%.json} $record_type $val"
|
||||
else
|
||||
echo "FAIL ${file%.json} $record_type $val"
|
||||
fi
|
||||
done
|
||||
elif [[ "$record_type" == "CNAME" ]]; then
|
||||
ping_result=$(ping -c 1 "$record_value")
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "PASS ${file%.json} $record_type $record_value"
|
||||
else
|
||||
echo "FAIL ${file%.json} $record_type $record_value"
|
||||
fi
|
||||
fi
|
||||
done < <(jq -c '.records | to_entries[] | {"key": .key, "value": .value}' "$file")
|
||||
fi
|
||||
if [[ -f $file && ! -d $file ]]; then
|
||||
while read -r line; do
|
||||
record_type=$(echo "$line" | jq -r 'keys[]')
|
||||
record_value=$(echo "$line" | jq -r '.[]')
|
||||
if [[ "$record_type" =~ ^(A|AAAA)$ ]]; then
|
||||
IFS=$'\n' read -r -a record_values <<< "$record_value"
|
||||
for val in "${record_values[@]}"; do
|
||||
ping_result=$(ping -c 1 "$val")
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "PASS ${file%.json} $record_type $val"
|
||||
else
|
||||
echo "FAIL ${file%.json} $record_type $val"
|
||||
fi
|
||||
done
|
||||
elif [[ "$record_type" == "CNAME" ]]; then
|
||||
ping_result=$(ping -c 1 "$record_value")
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "PASS ${file%.json} $record_type $record_value"
|
||||
echo "PASS ${file%.json} $record_type $record_value" >> ../ping_results.txt
|
||||
else
|
||||
echo "FAIL ${file%.json} $record_type $record_value"
|
||||
echo "FAIL ${file%.json} $record_type $record_value" >> ../ping_results.txt
|
||||
fi
|
||||
fi
|
||||
done < <(jq -c '.records | to_entries[] | {"key": .key, "value": .value}' "$file")
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Push Data
|
||||
|
||||
Reference in new issue
Block a user