Skip to content

Easily automate and manage your CloudFlare DNS records with the Node.js and Python3 CloudFlare DNS Manager library. This powerful tool allows developers to seamlessly interact with CloudFlare's DNS API, enabling automatic management of DNS records.

Notifications You must be signed in to change notification settings

0x0Ath/CloudFlare-DNS-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Icon

CloudFlare-DNS-Manager

Easily automate and manage your CloudFlare DNS records with the Node.js and Python3 CloudFlare DNS Manager library. This powerful tool allows developers to seamlessly interact with CloudFlare's DNS API, enabling automatic management of DNS records

Inside

graph LR
A[Library] -- Axios --> B(Cloudflare API)
D --Response--> A(Library)
B -- Communication --> D((Cloudfalre DNS))

Installation

NodeJS required version > 10.2.x

npm install cloudflare-dns-manager@latest

Example:

NodeJS:

const CloudflareAPI = require('cloudflare-dns-manager');

// Replace 'your-email' and 'your-api-key' with your actual CloudFlare credentials
// แทน 'your-email' และ 'your-api-key' ด้วยข้อมูลบัญชี CloudFlare ของคุณ
const cfAPI = new CloudflareAPI('your-email@example.com', 'your-api-key');

// Replace 'your-zone-id' with the actual Zone ID you want to work with
// แทน 'your-zone-id' ด้วย Zone ID ที่คุณต้องการใช้งาน
const zoneId = 'your-zone-id';


// Example: Add a new DNS record
// ตัวอย่าง: เพิ่ม record DNS ใหม่
(async () => {
	const targetIp = '192.168.1.1';
	const recordName = 'example.com';
	const recordType = 'A';
	try {
	    const result = await cfAPI.addDnsRecord(targetIp, recordName, recordType, zoneId);
	    console.log(result);
	} catch (error) {
	    console.error(error);
	}
})();


// Example: Get the list of DNS records
// ตัวอย่าง: ดึงรายการ DNS records
(async () => {	
	try {
	    const result = await cfAPI.dnsScan(zoneId);
	    console.log(result);
	} catch (error) {
	    console.error(error);
	}
})();


// Example: Update a DNS record
// ตัวอย่าง: อัพเดท record DNS
(async () => {	
	const updatedIp = '192.168.1.2';
	const recordIdToUpdate = 'record-id-to-update'; // Replace with the actual record ID
	try {
	    const result = await cfAPI.updateDnsRecord(updatedIp, recordName, recordType, zoneId, recordIdToUpdate);
	    console.log(result);
	    // If you want Data only. หากต้องการสำหรับข้อมูลเท่านั้น.
	    console.log(result.data);
	} catch (error) {
	    console.error(error);
	}
})();


// Example: Delete a DNS record
// ตัวอย่าง: ลบ record DNS
(async () => {	
	const recordIdToDelete = 'record-id-to-delete'; // Replace with the actual record ID
	try {
	    const result = await cfAPI.deleteDnsRecord(zoneId, recordIdToDelete);
	    console.log(result);
	} catch (error) {
	    console.error(error);
	}
})();

FAQ

Class function infromation

Usage for each function in the class.

Class Function Args Response json key
dnsScan zoneId success, exception, message, data
addDnsRecord targetIp, name, recordType, zoneId, comment, ttl success, exception, message, data
updateDnsRecord targetIp, name, recordType, zoneId, comment, ttl success, exception, message, data
deleteDnsRecord zoneId, recordId success, exception, message, data

The default time-to-live (TTL) is set to 300, and the comment is automatically included—there's no need to parse the argument (ttl, comment) through the function.

Record Types

A, AAAA, CAA, CERT, CNAME, DNSKEY, DS, HTTPS, LOC, MX, NAPTR, NS, PTR, SMIMEA, SRV, SSHFP, SVCB, TLSA, TXT, URI

Update

Full advanced library updates & Python3 library is coming soon

About

Easily automate and manage your CloudFlare DNS records with the Node.js and Python3 CloudFlare DNS Manager library. This powerful tool allows developers to seamlessly interact with CloudFlare's DNS API, enabling automatic management of DNS records.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published