An open API service indexing awesome lists of open source software.

https://github.com/nasriyasoftware/nasriyadns

DNS manager for your domains
https://github.com/nasriyasoftware/nasriyadns

a-record dns ip ip-address ipaddress proxy

Last synced: 2 months ago
JSON representation

DNS manager for your domains

Awesome Lists containing this project

README

        

[![N|Solid](https://static.wixstatic.com/media/72ffe6_da8d2142d49c42b29c96ba80c8a91a6c~mv2.png)](https://nasriya.net)
# NasriyaDNS.
[![Static Badge](https://img.shields.io/badge/license-Free_(Restricted)-blue)](https://github.com/nasriyasoftware/NasriyaDNS?tab=License-1-ov-file) ![Repository Size](https://img.shields.io/github/repo-size/nasriyasoftware/NasriyaDNS.svg) ![Last Commit](https://img.shields.io/github/last-commit/nasriyasoftware/NasriyaDNS.svg) [![Status](https://img.shields.io/badge/Status-Stable-green.svg)](link-to-your-status-page)
##### Visit us at [www.nasriya.net](https://nasriya.net).

NasriyaDNS is a DNS manager for your domains.

Made with ❤️ in **Palestine** 🇵🇸

> [!IMPORTANT]
> 🌟 **Support Our Open-Source Development!** 🌟
> We need your support to keep our projects going! If you find our > work valuable, please consider contributing. Your support helps us > continue to develop and maintain these tools.
>
> **[Click here to support us!](https://fund.nasriya.net/)**
>
> Every contribution, big or small, makes a difference. Thank you for > your generosity and support!
___
If your server is running behind a dynamic IP address you can make use of **Nasriya DNS manager** to update the [DNS records](https://www.cloudflare.com/learning/dns/dns-records/) of your domain.

**Notes:**
- **NasriyaDNS** is part of [HyperCloud](https://www.npmjs.com/package/@nasriya/HyperCloud)'s HTTP2 server framework.
___
## Quick Start Guide

### Installation
```shell
npm i @nasriya/dns
```

### Importing
Import in **ES6** modules
```ts
import hyperCloudDNS from '@nasriya/dns';
```

Import in **CommonJS (CJS)**
```js
const hyperCloudDNS = require('@nasriya/dns').default;
```
### Usage
Start by getting the new IP address:
```ts
// Get the machine's public IP
const public_ip: string = await hyperCloudDNS.helpers.getPublicIP();
```

##### DuckDNS
```ts
// Initialize a provider:
const duckdns: DuckDNSManager = hyperCloudDNS.duckdns(process.env.DUCKDNS_API_TOKEN);

// Update the IP address
await duckdns.records.update('', public_ip);
```

##### Cloudflare
```ts
import hyperCloudDNS from "nasriya-dns";
const cloudflare = hyperCloudDNS.cloudflare(process.env.CLOUDFLARE_API_TOKEN);

// If you know the Zone ID of your domain, uncomment the below line
// const zone_id = process.env.CLOUDFLARE_ZONE_ID;

// If you don't know the Zone ID. Comment the following 4 lines if you do
const zone_id: string = await cloudflare.zone.list({
accountName: '',
just_ids: true
}).then(list => list[0]) as string;

// Get all A records:
const records = await cloudflare.records.list(zone_id, {
type: 'A',
simplified: true
})

// Prepare the promises
const promises = records.map(record => {
return new Promise((resolve, reject) => {
cloudflare.records.update({
zone_id,
record,
record_id: record.id,
}).then(res => resolve(res)).catch(err => reject(err));
})
})

// Invoke promises
await Promise.allSettled(promises).then(res => {
const fulfilled = (res.filter(i => i.status === 'fulfilled') as unknown as PromiseFulfilledResult[]).map(i => i.value);
const rejected = (res.filter(i => i.status === 'rejected') as unknown as PromiseRejectedResult[]).map(i => i.reason);

if (fulfilled.length === res.length) {
return Promise.resolve({ status: 'success', result: fulfilled });
} else {
return Promise.resolve({ status: 'failed', result: rejected });
}
})
```
___
## License
Please read the license from [here](https://github.com/nasriyasoftware/NasriyaDNS?tab=License-1-ov-file).