Skip to content

Commit 06d9e71

Browse files
committed
fix bug because api changes
1 parent b6e494a commit 06d9e71

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README-EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This script is a DDNS script based on the cloudflare API, which supports IPV4 an
1111
1. A liunx device that can be connected to the Internet.
1212
2. Have a domain name.
1313
3. Register a CloudFlare account ( www.cloudflare.com ), add the domain to the account. After the configuration is complete, add an AAAA resolution to the IPV6 address of the service device as required, and set it to perform DNS resolution only.
14-
4. Query the Globe ID of CloudFlare account and record it for subsequent configuration.
14+
4. Query the Globe API Key of CloudFlare account and record it for subsequent configuration.
1515

1616
### Instructions
1717
Open a terminal window and execute the following procedure:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1. 一台可联网的liunx设备
1414
2. 拥有一个域名,免费的或者收费的都可以(中国大陆的域名需要备案)
1515
3. 注册一个CloudFlare账户 ( www.cloudflare.com ), 并将需要使用的域名添加到账户上,完成配置后根据需要添加服务设备的IPV6地址添加一个AAAA解析,并设为仅进行DNS解析
16-
4. 查询CloudFlare账户的Globel ID并记录下来,用于后续配置
16+
4. 查询CloudFlare账户的Globel API Key并记录下来,用于后续配置
1717

1818
### 使用方法
1919
打开命令窗口,执行以下程序:

cloudflare-ddns.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,24 @@ if [ -f $id_file ] && [ $(wc -l $id_file | cut -d " " -f 1) == 2 ]; then
7070
zone_identifier=$(head -1 $id_file)
7171
record_identifier=$(tail -1 $id_file)
7272
else
73-
zone_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$zone_name" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" | grep -Po '(?<="id":")[^"]*' | head -1 )
74-
record_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?name=$record_name" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" | grep -Po '(?<="id":")[^"]*')
73+
zone_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$zone_name" \
74+
-H "X-Auth-Email: $auth_email" \
75+
-H "X-Auth-Key: $auth_key" \
76+
-H "Content-Type: application/json" | grep -Po '(?<="id":")[^"]*' | head -1 )
77+
record_identifier=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?name=$record_name" \
78+
-H "X-Auth-Email: $auth_email" \
79+
-H "X-Auth-Key: $auth_key"
80+
-H "Content-Type: application/json" | grep -Po '(?<="id": ")[^"]*')
7581
echo "$zone_identifier" > $id_file
7682
echo "$record_identifier" >> $id_file
7783
fi
7884

7985
#更新DNS记录 update the dns
80-
update=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" --data "{\"id\":\"$zone_identifier\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$ip\"}")
86+
update=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier" \
87+
-H "X-Auth-Email: $auth_email" \
88+
-H "X-Auth-Key: $auth_key" \
89+
-H "Content-Type: application/json" \
90+
--data "{\"id\":\"$zone_identifier\",\"type\":\"$record_type\",\"name\":\"$record_name\",\"content\":\"$ip\"}")
8191

8292

8393
#反馈更新情况 gave the feedback about the update statues

0 commit comments

Comments
 (0)