https://github.com/nikhiljohn10/ddnslab
Cloudflare DDNS Worker API
https://github.com/nikhiljohn10/ddnslab
cloudflare-api ddns-worker
Last synced: 4 months ago
JSON representation
Cloudflare DDNS Worker API
- Host: GitHub
- URL: https://github.com/nikhiljohn10/ddnslab
- Owner: nikhiljohn10
- License: mit
- Created: 2019-06-19T16:42:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-01T18:33:20.000Z (about 3 years ago)
- Last Synced: 2025-02-01T13:35:19.528Z (about 1 year ago)
- Topics: cloudflare-api, ddns-worker
- Language: CSS
- Homepage: https://ddnslab.nikz.in/
- Size: 3.24 MB
- Stars: 18
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare DDNS Worker API
**Author: Nikhil John [(@nikhiljohn10 / @nikzjon)](https://github.com/nikhiljohn10)**
### Prerequisite
- Owns a Domain Name which uses CLoudFlare (eg: example.com).
- Cloudflare API Token created with Zone.Zone.Read & Zone.DNS.Edit permissions.
### Usage
**HTTPS Request**
```
Method: POST
URL: https://ddnslab.nikz.in
ContentType: application/json
Body: {
apiToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
recordName: "The A Record name created for DDNS client",
proxied: true/false
}
```
Example using CURL for Linux Terminal:
```
curl -X POST "https://ddnslab.nikz.in/" -H "Content-Type: application/json" --data '{"apiToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","recordName":"home.example.com","proxied": true}'
```
Example using Node.JS for Linux Users:
```
const https = require('https')
const data = JSON.stringify({
"apiToken":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"recordName":"home.example.com",
"proxied": true
})
const options = {
hostname: 'https://ddnslab.nikz.in/',
port: 443,
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}
const req = https.request(options, (res) => {
res.on('data', (d) => {
process.stdout.write(d)
})
})
req.on('error', (error) => {
console.error(error)
})
req.write(data)
req.end()
```
Example using Batch File for Windows Users:
```
@echo off
title CloudFlare DDNS Service
echo Initiating service...
:loop
curl https://ddnslab.nikz.in/ -H Content-Type:application/json --data "{\"apiToken\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\"recordName\":\"home.example.com\",\"proxied\":true}"
echo ^: %date% %time%
timeout /t 60 /nobreak > NUL
goto loop
pause
```
**Notes:**
1. API Token is to be created in CloudFlare (My Profile > API Tokens > Create Token)
2. API Token permissions needed are Zone.Zone.Read & Zone.DNS.Edit
3. Note down the API Token somewhere safe after creation as there is no option to display it again
4. Use only HTTPS protocol for security reason.
5. Set proxied to false if you wish to access DDNS location with port which are not allowed by CloudFlare.
### References
[CloudFlare API Documentation](https://api.cloudflare.com)
[DDNS Worker Code](https://github.com/jwala-diamonds/ddnslab.tech/blob/master/worker.js)
[CloudFlare Worker Documentation](https://developers.cloudflare.com/workers/)