更新 choose.sh
This commit is contained in:
parent
5868e22589
commit
b7d5c13963
14
choose.sh
14
choose.sh
@ -3,11 +3,11 @@
|
|||||||
# 以下变量需要填写
|
# 以下变量需要填写
|
||||||
API_KEY="your_cloudflare_api_key"
|
API_KEY="your_cloudflare_api_key"
|
||||||
EMAIL="your_email@example.com"
|
EMAIL="your_email@example.com"
|
||||||
RECORD_ID="your_dns_record_id"
|
|
||||||
ZONE_ID="your_zone_id"
|
ZONE_ID="your_zone_id"
|
||||||
DOMAIN="your_domain.com"
|
DOMAIN="your_domain.com"
|
||||||
SUBDOMAIN="sub.your_domain.com"
|
SUBDOMAIN="sub.your_domain.com"
|
||||||
SCAN_PROGRAM_PATH="your_scan_program_path"
|
SCAN_PROGRAM_PATH="your_scan_program_path"
|
||||||
|
TTL=300
|
||||||
|
|
||||||
# 克隆git仓库
|
# 克隆git仓库
|
||||||
git clone https://git.18g.me/feiwujia/iplist || { echo "Git clone failed"; exit 1; }
|
git clone https://git.18g.me/feiwujia/iplist || { echo "Git clone failed"; exit 1; }
|
||||||
@ -64,13 +64,21 @@ done
|
|||||||
while IFS= read -r ip
|
while IFS= read -r ip
|
||||||
do
|
do
|
||||||
# 使用Cloudflare API更新DNS记录
|
# 使用Cloudflare API更新DNS记录
|
||||||
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
|
response=$(curl -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \
|
||||||
-H "X-Auth-Email: ${EMAIL}" \
|
-H "X-Auth-Email: ${EMAIL}" \
|
||||||
-H "X-Auth-Key: ${API_KEY}" \
|
-H "X-Auth-Key: ${API_KEY}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data '{"type":"A","name":"'${SUBDOMAIN}'","content":"'${ip}'","ttl":1,"proxied":false}' || { echo "curl failed"; exit 1; }
|
--data '{"type":"A","name":"'${SUBDOMAIN}'","content":"'${ip}'","ttl":'${TTL}',"proxied":false}' 2>/dev/null)
|
||||||
|
|
||||||
|
# 检查返回值中的success字段是否为true
|
||||||
|
if echo "$response" | grep -q '"success":true'; then
|
||||||
|
echo "IP $ip added successfully"
|
||||||
|
else
|
||||||
|
echo "IP $ip failed to add"
|
||||||
|
fi
|
||||||
done < use/use.txt
|
done < use/use.txt
|
||||||
|
|
||||||
# 删除iplist文件夹
|
# 删除iplist文件夹
|
||||||
cd .. && rm -rf iplist || { echo "Remove iplist folder failed"; exit 1; }
|
cd .. && rm -rf iplist || { echo "Remove iplist folder failed"; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user