This is a script to change Cloudflare DNS records automatically with your current IP address
npm install nodejs-cloudflare-ddns-script --save
const cfddns = require('nodejs-cloudflare-ddns-script');
const options = {
"wanIPv4Site": "https://ipv4.icanhazip.com",
// The website which used to get your current public IPv4 address.
// Default: https://ipv4.icanhazip.com
"autoSwitch": false,
//If you don't have any public IPv6 address
//program will use IPv4 automaticly or it will throw an exception.
//Default: false.
"cfKey": "EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEX",
//Your Cloudflare API key
"email": "[email protected]",
//Your Cloudflare email
"zoneName": "example.com",
//Your Cloudflare zone name
"recordType": "A",
//The type of record you want to update.
//Default: A
"recordName": "ddns",
//The name of the record you want to update.
"TTL": 60,
//The TTL of the record you want to update.
//Default: 60
"proxied": false
//Default: false
}
cfddns.update(options);
.then((ret) => {
console.log(ret); //true | false
})
.catch((err) => {
console.error(err);
});
Or create config.json
under your project folder with the content of parameter options
.
Thanks.
:D