├── .gitignore ├── package.json ├── LICENSE ├── index.js ├── README.md └── functions.js /.gitignore: -------------------------------------------------------------------------------- 1 | local.js 2 | .detaignore 3 | .deta 4 | node_modules -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dns-checker", 3 | "version": "1.0.0", 4 | "description": "Check any domains for DNS records", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/rareseu/DNSChecker.git" 12 | }, 13 | "keywords": [ 14 | "dns", 15 | "checker", 16 | "api", 17 | "unlimited" 18 | ], 19 | "author": "RaresEU", 20 | "license": "ISC", 21 | "bugs": { 22 | "url": "https://github.com/rareseu/DNSChecker/issues" 23 | }, 24 | "homepage": "https://github.com/rareseu/DNSChecker#readme", 25 | "dependencies": { 26 | "express": "^4.18.2" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2022 DNSChecker 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 14 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const app = express() 3 | const { IP_DNS, MIX_DNS, ALL_DNS, domainRegex } = require('./functions.js'); 4 | 5 | app.use(express.json()); 6 | app.use(express.urlencoded({ extended: true })); 7 | app.set('trust proxy', true) 8 | app.set('json spaces', 2) 9 | 10 | app.get('/', (req, res) => { res.send('Go to https://dnschecker.rares.eu.org/ for documentation!') }) 11 | 12 | app.get('/all/:url/:dns?', domainRegex, async (req, res) => { 13 | res.send(await ALL_DNS(req.params.url)) 14 | }) 15 | 16 | app.get('/a/:url/:dns?', domainRegex, async (req, res) => { 17 | res.json(await IP_DNS(req.params.url, 1)) 18 | }) 19 | 20 | app.get('/aaaa/:url/:dns?', domainRegex, async (req, res) => { 21 | res.json(await IP_DNS(req.params.url, 2)) 22 | }) 23 | 24 | app.get('/:type(mx|ns|soa|txt|caa|cname|naptr|ptr|srv)/:url/:dns?', domainRegex, async (req, res) => { 25 | res.json(await MIX_DNS(req.params.url, req.params.type.toUpperCase())) 26 | }) 27 | 28 | app.get('/ping', (req, res) => { res.send('pong') }) 29 | 30 | app.use((req, res, next) => { 31 | res.status(404).json({ message: 'Ohh you are lost, read the API documentation to find your way back home :)' }) 32 | }) 33 | 34 | module.exports = app -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DNS Checker API - Unlimited use 2 | 3 | Open source DNS Checker API with unlimited use, no restrictions applied. 4 | 5 | ## API Reference (Usage) 6 | 1. [https://projects.rares.eu/dns](https://projects.rares.eu/dns) 7 | 8 | Using any of the above link, make GET requests following: 9 | 10 | ```http 11 | GET https://projects.rares.eu/dns/type/url/dns? 12 | ``` 13 | 14 | | Parameter | Type | Description | 15 | | :-------- | :------- | :-------------------------------- | 16 | | `type` | `string` | **Required**. Type (A, AAAA, ...); List below.| 17 | | `url` | `string` | **Required**. Please note: the domain value should be sent without **`http://`** or **`https://`**| 18 | | `dns` | `string` | **Optional**. *default: **Google DNS***.
Available: Google, Cloudflare, OpenDNS, Verisign, DNSWatch, Freenom, AliDNS & Dyn. List from [publicdns.xyz](https://www.publicdns.xyz/) | 19 | 20 | _Please note:_ All parameters are case-insensitive. 21 | 22 | Supported types: 23 | - A (including ttl) 24 | - AAAA (including ttl) 25 | - MX 26 | - NS 27 | - SOA 28 | - TXT 29 | - CAA 30 | - CNAME 31 | - NAPTR 32 | - PTR 33 | - SRV 34 | - ALL (when using /all/, the API will return A, AAAA, CAA, CNAME, MX, NS, SOA, SRV and SRV values) 35 | 36 | Examples: 37 | - [https://projects.rares.eu/dns/a/google.com](https://projects.rares.eu/dns/a/google.com) 38 | - [https://projects.rares.eu/dns/txt/google.com](https://projects.rares.eu/dns/a/google.com) 39 | 40 | ## Contributing 41 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 42 | 43 | Please make sure to update tests as appropriate. 44 | 45 | ## License 46 | [MIT](https://choosealicense.com/licenses/mit/) 47 | 48 | This project is tested with [BrowserStack](https://www.browserstack.com/). 49 | -------------------------------------------------------------------------------- /functions.js: -------------------------------------------------------------------------------- 1 | const dns = require('dns'); 2 | const dnsPromises = dns.promises; 3 | 4 | const errHandler = (error) => { 5 | if(!error) return 'error' 6 | if(error.code == 'ENODATA') return null 7 | else if(error.code == 'ENOTFOUND') return null 8 | else if(error.code == 'ESERVFAIL') return 'Server Failed' 9 | else return error 10 | } 11 | 12 | const IP_DNS = async (url, type) => { 13 | let array = []; 14 | try { 15 | if(type == 1) array = await dnsPromises.resolve4(url, { ttl : true }); 16 | else if(type == 2) array = await dnsPromises.resolve6(url, { ttl : true }); 17 | for(let i=0; i { 29 | try { return await dnsPromises.resolve(url, type) } 30 | catch (error) { return errHandler(error) } 31 | } 32 | 33 | const ALL_DNS = async (url) => { 34 | let array = {"timestamp": new Date().getTime(), "req": {"url": url, "ts": new Date(), "id": require("crypto").randomBytes(10).toString('hex')}, "data": {"A": await IP_DNS(url, 1), "AAAA": await IP_DNS(url, 2)}, "serversUsed": await dnsPromises.getServers()}, all = ['CAA', 'CNAME', 'MX', 'NS', 'SOA', 'SRV', 'TXT' ]; 35 | for(let i=0; i { 41 | let url = req.params.url; 42 | if(!url) return res.send('Missing /URL') 43 | if(!url.match(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/)) return res.send('invalid domain') 44 | else { 45 | let dnses = { 46 | google: ['8.8.8.8','2001:4860:4860::8888','8.8.4.4','2001:4860:4860::8844'], cloudflare: ['1.1.1.1','1.0.0.1','2606:4700:4700::1111','2606:4700:4700::1001'], 47 | opendns: ['208.67.222.222','208.67.220.220','2620:119:35::35','2620:119:53::53'], 48 | verisign: ['64.6.64.6', '64.6.65.6', '2620:74:1b::1:1', '2620:74:1c::2:2'], 49 | dnswatch: ['84.200.69.80', '84.200.70.40', '2001:1608:10:25::1c04:b12f', '2001:1608:10:25::9249:d69b'], 50 | freenom: ['80.80.80.80', '80.80.81.81'], 51 | alidns: ['223.5.5.5', '223.6.6.6'], 52 | dyn: ['216.146.35.35', '216.146.36.36'] 53 | }; 54 | if(req.params.dns) { 55 | let dns = req.params.dns.toLowerCase() 56 | if(dnses[dns] && dnses[dns].length) await dnsPromises.setServers(dnses[dns]) 57 | else await dnsPromises.setServers(dnses['google']) 58 | } else await dnsPromises.setServers(dnses['google']) 59 | return next() 60 | } 61 | } 62 | 63 | module.exports = { 64 | IP_DNS, 65 | MIX_DNS, 66 | ALL_DNS, 67 | domainRegex 68 | } --------------------------------------------------------------------------------