Skip to content

Commit

Permalink
Updated - readme & texts
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiIgna committed Jul 26, 2019
1 parent d5ba901 commit d99ee7e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
Uses `dig` command to make DNS requests, has a built-in list of subdomains to test for and has support for auto-discovering subdomains based on records found.

## Highlights
* Retrieves really fast DNS records for a domain.
* Discovers all A, AAAA and CNAME for a domain.
* Provides results in a easy-to-use format.
*
* Retrieves really fast DNS records for a domain
* Discovers all A, AAAA and CNAME for a domain
* Provides results in a easy-to-use format

## Roadmap
Aiming to have these features:
Expand Down Expand Up @@ -62,7 +61,8 @@ const dnsRecords = require('./index.js');
```
Returns a promise which resolves with an `Array` of records found, grouped by type:
```js
{ NS:
{
NS:
[ { name: 'x.com.',
ttl: '3600',
type: 'NS',
Expand Down Expand Up @@ -93,7 +93,8 @@ Returns a promise which resolves with an `Array` of records found, grouped by ty
ttl: '3600',
type: 'MX',
value: '10 mx-van.mail.am0.yahoodns.net.' } ],
TXT: [] }
TXT: []
}
```

## More
Expand Down
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const util = require('util')
const dns = require('dns')
const exec = util.promisify(require('child_process').exec)

// Records to check
const subdomainsToCheck = require('./subdomains.js')
const txtToCheck = [
'_amazonses',
Expand All @@ -13,11 +14,6 @@ const txtToCheck = [
]


// DNS over HTTPS
// https://dns.google.com/resolve?name=laye.red&type=AAAA&cd=1
// curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=laye.red&type=AAAA'


const isTld = tld => {
if (tld.startsWith('.')) {
tld = tld.substring(1)
Expand All @@ -35,7 +31,7 @@ const isDomain = domain => {
const labelTest = /^([a-z0-9-]{1,64}|xn[a-z0-9-]{5,})$/i

return labels.length > 1 && labels.every((label, index) => {
return index ? labelTest.test(label) && !label.startsWith('-') && !label.endsWith('-') : isTld(label)
return index ? !label.startsWith('-') && !label.endsWith('-') && labelTest.test(label) : isTld(label)
})
}

Expand All @@ -44,7 +40,7 @@ const getDnsRecords = async (names, types, server) => {
let cmd = ['dig']

if (!Array.isArray(types)) {
types = [types] || 'A'
types = [types] || ['A']
}

if (!Array.isArray(names)) {
Expand All @@ -66,9 +62,9 @@ const getDnsRecords = async (names, types, server) => {
})
})

let re = await exec(cmd.filter(arg => arg).join(' '))
let re = await exec(cmd.join(' '))

// If dig command fails, it throws an error. This condition catches errors sent with `stderr`
// This step catches errors sent with `stderr` and not sent with `throw`
if (re.stderr) {
throw new Error(re.stderr)
}
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"name": "@layered/dns-records",
"version": "1.0.0",
"description": "Discover publicly available DNS Records for a domain",
"keywords": ["dns", "records", "dns", "ns", "name", "server"],
"keywords": [
"dns",
"records",
"dns",
"ns",
"name",
"server"
],
"author": "Andrei Igna <andrei@laye.red>",
"license": "MIT",
"bugs": {
Expand Down

0 comments on commit d99ee7e

Please sign in to comment.