Skip to content

Commit

Permalink
By not specifying the "proxied" field the Cloudflare API defaults tha…
Browse files Browse the repository at this point in the history
…t value to false. (#5)

* batch-beta branch is no longer required

* make proxy property configurable

* ttl is a required field

* readme proxy details
  • Loading branch information
ashtacore authored Nov 17, 2022
1 parent f15c7c9 commit 9d54714
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ RECORD_ID = 372e67954025e0ba6aaa6d586b9e0b59
#example
NAME = example.com
```

- Specify whether to use Cloudflare's proxying feature. Must be "true" or "false".
```
#example
PROXIED = true
```

- Get the ZONE_ID under dash.cloudflare.com -> Your domain -> Overview -> API -> Zone ID
```
#example
Expand Down
6 changes: 3 additions & 3 deletions cloudflare-ddns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ echo "AUTH_EMAIL are not defined, will use API Bearer Token method"
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\"}"
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\",\"proxied\":$PROXIED,\"ttl\":1}"

else
echo "AUTH_EMAIL is defined, will use AUTH_KEY Method"
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
-H "X-Auth-Email: $AUTH_EMAIL" \
-H "X-Auth-Key: $AUTH_KEY" \
-H "Content-Type: application/json" \
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\"}"
fi
--data "{\"type\":\"A\",\"name\":\"$NAME\",\"content\":\"`curl ifconfig.co`\",\"proxied\":$PROXIED,\"ttl\":1}"
fi
4 changes: 3 additions & 1 deletion k8s-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: cloudflare-ddns
Expand All @@ -24,4 +24,6 @@ spec:
value: ""
- name: NAME
value: ""
- name: PROXIED
value: ""
restartPolicy: OnFailure

0 comments on commit 9d54714

Please sign in to comment.